-
Notifications
You must be signed in to change notification settings - Fork 26.3k
DilatedMaxPool: expand incomplete kernel_size for the C++ API #22073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
facebook-github-bot
left a comment
There was a problem hiding this 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.
mrshenli
left a comment
There was a problem hiding this 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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing!
|
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 [I think it is reasonable to permit single integers in the C++ API, but it would be nice to sync behavior with the JIT.] |
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? |
|
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. |
|
I think ideally it would work the same way in C++. |
|
I'm landing the PR. if you want to send tests, please do so in a follow-up PR |
Summary: Fixes pytorch/pytorch#22032. Pull Request resolved: pytorch/pytorch#22073 Differential Revision: D15944471 Pulled By: mrshenli fbshipit-source-id: 84b265be00d67aa7f13508ede0646763d2339f1d
|
Yes, tests will be part of #22277 (more functions need to be changed in ATen). |
Fixes #22032.