-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Use integer floor division for pooling shape computation #22304
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
|
The test I added failed, so the test seems good. I don't see what's wrong with the implementation, though. When testing locally, it does not seem to call Quick one-liner to test the implementation: python -c 'import torch; print(torch.nn.functional.max_pool1d(torch.zeros((1, 1, 4)), 3, stride=2, padding=0, dilation=2, ceil_mode=False).shape)'This should raise a RuntimeError, but right now it prints |
|
Okay, I grepped the source code for my |
0dd2b88 to
d54b7d6
Compare
|
Amended my commit to change all copies of the code. Fingers crossed. Is there a way to get rid of the copies? Can THNN and THCUNN use the ATen version? Or is there another shared place for such things? |
d54b7d6 to
5deb60e
Compare
|
Status: My test passes, but there's another test that relied on the broken pooling behavior. Will look into that later (maybe not today); marked as WIP again. |
Yes please! There is no technical barrier here, it's purely a matter of code organization. |
The THNN version has been extended with support for asymmetric padding, though (in #21310), which neither the THCUNN nor the ATen version have. Shall this be ported over then? Otherwise THNN cannot use ATen. Is ATen supposed to replace THNN and THCUNN in the long run, or are they meant to co-exist? |
|
ATen is meant to replace THNN/THCUNN; the way we are killing the old code is by porting it to ATen (most notable change in a port is removal of manual refcounting). We should not have accepted the previous PR if there was already a copy of the code in ATen. @akyrola do you have an opinion here? The correct fix at this point is to make sure asymmetric padding works for all versions of the code (and deduplicate code, if there are multiple copies). I have not actually looked into the situation. |
|
@ezyang i am not really involved with pytorch development at this point, so don't have an opinion |
Ok. As far as I understand, asymmetric padding was added to support I will then try deleting the THNN and THCUNN versions to see if anything else still depends on them that should be using ATen instead. Does that make sense? Finally, I will check the test that relied on the broken pooling behavior. |
That'd be great! Thank you for your hard work! |
|
The failing existing test had a python implementation of the pooling shape computation, but used float division instead of an integer division. The test only failed now that the pooling shape computation in torch was corrected. Fixed the python implementation. There were two references to the THNN pooling shape function; I replaced them with the ATen version and removed the THNN and THCUNN versions completely. |
|
I think this is good to go, I'll remove the WIP label. The only failing test has nothing to do with me, as far as I see: |
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.
@ezyang is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: Fixes pytorch/pytorch#21935 by using the integer floor division that was introduced for convolution shapes in pytorch/pytorch#9640. Without this fix, the pooling operators can produce a 1-element output in cases they shouldn't. Disclaimer: I couldn't properly test it locally (it's not picking up the modified version for some reason). I'm marking this WIP until I checked what the CI tools say... Pull Request resolved: pytorch/pytorch#22304 Differential Revision: D16181955 Pulled By: ezyang fbshipit-source-id: a2405372753572548b40616d1206848b527c8121
Fixes #21935 by using the integer floor division that was introduced for convolution shapes in #9640. Without this fix, the pooling operators can produce a 1-element output in cases they shouldn't.
Disclaimer: I couldn't properly test it locally (it's not picking up the modified version for some reason). I'm marking this WIP until I checked what the CI tools say...