Skip to content

Conversation

@skrah
Copy link
Contributor

@skrah skrah commented Jun 21, 2019

Fixes #22032.

@pytorchbot pytorchbot added module: cuda Related to torch.cuda, and CUDA support in general module: operators labels Jun 21, 2019
@skrah skrah added module: cpp Related to C++ API open source module: porting Issues related to porting TH/THNN legacy to ATen native and removed module: operators module: cuda Related to torch.cuda, and CUDA support in general labels Jun 21, 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.

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

Copy link
Contributor

@mrshenli mrshenli left a comment

Choose a reason for hiding this comment

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

Shall we add a test to cover the case where max_pool2d and max_pool3d passes an integer as the kernel size?

Copy link
Contributor

@mrshenli mrshenli left a comment

Choose a reason for hiding this comment

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

Thanks for fixing!

@skrah
Copy link
Contributor Author

skrah commented Jun 21, 2019

I guess we should add tests if this is the official C++ API (I'm not sure if it is documented in this level of detail).

Looking at #20866, the JIT does extra work to expand single integer arguments into lists, see e.g.:

@weak_script
def _max_pool2d(input, kernel_size, stride=None, padding=0, dilation=1,
                ceil_mode=False, return_indices=False):
    # type: (Tensor, BroadcastingList2[int], Optional[BroadcastingList2[int]], BroadcastingList2[int], BroadcastingList2[int], bool, bool) -> Tensor  # noqa
    if stride is None:
        stride = torch.jit.annotate(List[int], [])
    return torch.max_pool2d(
        input, kernel_size, stride, padding, dilation, ceil_mode)

So the JIT takes care not to pass single integers to torch::max_pool2d. The question I have is whether it does so for internal convenience or because the C++ API was originally intended that way.

[I think it is reasonable to permit single integers in the C++ API, but it would be nice to sync behavior with the JIT.]

@mrshenli
Copy link
Contributor

I guess we should add tests if this is the official C++ API.

Good point! I am inclined to think C++ should have the same behavior as Python, i.e., auto-expanding kernel_size, but I am not sure either. @gchanan has this been discussed before?

@skrah
Copy link
Contributor Author

skrah commented Jun 21, 2019

Agreed, I also think that C++ should have the same behavior as Python, mostly because a lot of other Python idioms work on the C++ level.

@gchanan
Copy link
Contributor

gchanan commented Jun 21, 2019

I think ideally it would work the same way in C++.

@soumith
Copy link
Contributor

soumith commented Jun 24, 2019

I'm landing the PR. if you want to send tests, please do so in a follow-up PR

zdevito pushed a commit to zdevito/ATen that referenced this pull request Jun 24, 2019
Summary:
Fixes pytorch/pytorch#22032.
Pull Request resolved: pytorch/pytorch#22073

Differential Revision: D15944471

Pulled By: mrshenli

fbshipit-source-id: 84b265be00d67aa7f13508ede0646763d2339f1d
@facebook-github-bot
Copy link
Contributor

@mrshenli merged this pull request in 2372e7e.

@skrah
Copy link
Contributor Author

skrah commented Jun 26, 2019

Yes, tests will be part of #22277 (more functions need to be changed in ATen).

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: porting Issues related to porting TH/THNN legacy to ATen native open source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

max_pool2d_with_indices: internal error

7 participants