Skip to content

Conversation

@ifedan
Copy link
Contributor

@ifedan ifedan commented Jul 2, 2019

Generate avg_pool2d/avg_pool3d for LongTensor for CPU.
Added divisor_override parameter.

@pytorchbot pytorchbot added oncall: jit Add this issue/PR to JIT oncall triage queue module: cuda Related to torch.cuda, and CUDA support in general module: internals Related to internal abstractions in c10 and ATen module: mkldnn Related to Intel IDEEP or oneDNN (a.k.a. mkldnn) integration module: nn Related to torch.nn module: operators labels Jul 2, 2019
@pytorchbot pytorchbot added the module: cpp Related to C++ API label Jul 3, 2019
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ifedan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ifedan
Copy link
Contributor Author

ifedan commented Jul 3, 2019

This PR depends on pytorch/vision#1083

@ifedan ifedan requested a review from gchanan July 15, 2019 17:46

template<>
struct ScalarTypeToCType<at::ScalarType::Long> {
using type = int64_t ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spacing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

int padT, int padH, int padW,
bool count_include_pad,
int offsetZ)
int offsetZ, int divisor_override)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I asked this before, but is there a reason that optional doesn't work herE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not allowed to call a host function c10::optional::value from a global function

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, you might be able to fix that by making value a C10_HOST_DEVICE function, but this seems fine.

to compute the output shape. Default: ``False``
count_include_pad: when True, will include the zero-padding in the
averaging calculation. Default: ``True``
divisor_override: if specified, it will be used as divisor, otherwise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is accurate, count_include_pad is also potentially used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

to compute the output shape
count_include_pad: when True, will include the zero-padding in the
averaging calculation
divisor_override: if specified, it will be used as divisor, otherwise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

def symbolic_fn(g, input, kernel_size, stride, padding, ceil_mode, count_include_pad, divisor_override=None):
if ceil_mode and input.type().kind() != "CompleteTensorType":
return _unimplemented(name, "input size not accesible")
if divisor_override and divisor_override.node().kind() != 'prim::Constant':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this check if it's None type or something? This looks like a constant would pass but not actually be passed to the operator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's similar to ceil_mode. In case if the value will be provided, type().kind() == "ONNX:Constant"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see what ceil_mode has to do with it. @houseroad can you look at this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked two cases: divisor_override not provided, divisor_override is provided. And if divisor_override is not provided it will converted to prim::Constant, otherwise it will be ONNX:Constant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the meaning of divisor_override? We would like to check the value of divisor_override to determine whether we can express it in ONNX or not. If not, call _unimplemented is the right choice.

@ifedan ifedan requested a review from gchanan July 15, 2019 22:35
@ifedan
Copy link
Contributor Author

ifedan commented Jul 16, 2019

@pytorchbot retest this please

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ifedan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ifedan
Copy link
Contributor Author

ifedan commented Jul 16, 2019

@pytorchbot retest this please

Copy link
Contributor

@gchanan gchanan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would prefer if @houseroad would take a look at the onnx stuff.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ifedan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ifedan
Copy link
Contributor Author

ifedan commented Jul 17, 2019

@pytorchbot retest this please

@ifedan
Copy link
Contributor Author

ifedan commented Jul 17, 2019

@ailzhang can we do the changes on XLA side? We blocked on rocm failures

@ifedan
Copy link
Contributor Author

ifedan commented Jul 17, 2019

@ailzhang I also can create PR for review

@ailzhang
Copy link
Contributor

@ifedan This should be easy to follow I think. Feel free to land when it's ready. I will prepare a fix on xla side. :)

@ifedan
Copy link
Contributor Author

ifedan commented Jul 17, 2019

@ifedan This should be easy to follow I think. Feel free to land when it's ready. I will prepare a fix on xla side. :)

@ailzhang PR is ready to land, but I'm not able to do it, because XLA test is failing. So should wait for the fix first

@ailzhang pytorch/xla#831

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ifedan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@ifedan merged this pull request in c2df54d.

zdevito pushed a commit to zdevito/ATen that referenced this pull request Jul 18, 2019
Summary:
Generate avg_pool2d/avg_pool3d for LongTensor for CPU.
Added divisor_override parameter.
Pull Request resolved: pytorch/pytorch#22433

Differential Revision: D16108809

Pulled By: ifedan

fbshipit-source-id: 8de7ff585a0479702cceafb5ccf9dfea62a9cc50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: cpp Related to C++ API module: cuda Related to torch.cuda, and CUDA support in general module: internals Related to internal abstractions in c10 and ATen module: mkldnn Related to Intel IDEEP or oneDNN (a.k.a. mkldnn) integration module: nn Related to torch.nn module: onnx Related to torch.onnx oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants