Skip to content
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

Fix max_pool2d with ceil_mode bug #46558

Closed

Conversation

heitorschueroff
Copy link
Contributor

@heitorschueroff heitorschueroff commented Oct 19, 2020

Stack from ghstack:

This PR fixes a bug with how pooling output shape was computed.

BC Breaking Notes

Previously, a bug in the pooling code allowed a sliding window to be entirely off bounds. Now, sliding windows must start inside the input or left padding (not right padding, see #46929) and may only go off-bounds if ceil_mode=True.

Note

Updating the code to allow the sliding window to start within the right padded region would break many internal assumptions. We may address this in a future PR.

fixes #45357

TODO

  • Ensure existing tests are checking for the correct output size

Differential Revision: D24633372

heitorschueroff added a commit that referenced this pull request Oct 19, 2020
ghstack-source-id: b2eb789f8760cf997efc065535abd0eeac30de87
Pull Request resolved: #46558
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Oct 19, 2020

💊 CI failures summary and remediations

As of commit ff7053d (more details on the Dr. CI page):


  • 1/1 failures possibly* introduced in this PR
    • 1/1 non-CircleCI failure(s)---

Extra GitHub checks: 1 failed


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 3 times.

@dr-ci
Copy link

dr-ci bot commented Oct 19, 2020

💊 CI failures summary and remediations

As of commit a4f0899 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 39 times.

This PR fixes a bug with how pooling output shape was computed. Previously, it did not consider the right padding as "part of the image" but the docs do. Now, in ceil mode it allows a kernel window to go off bounds as long as it starts within the image including both paddings. The boolean condition was also wrong, it should be ceil_mode.

fixes #45357

[ghstack-poisoned]
heitorschueroff added a commit that referenced this pull request Oct 20, 2020
ghstack-source-id: 32f9000630b256797535a5dae77bd2dc135eedc2
Pull Request resolved: #46558
@heitorschueroff heitorschueroff added the module: bc-breaking Related to a BC-breaking change label Oct 20, 2020
This PR fixes a bug with how pooling output shape was computed. Previously, it did not consider the right padding as "part of the image" but the docs do. Now, in ceil mode it allows a kernel window to go off bounds as long as it starts within the image including both paddings. The boolean condition was also wrong, it should be ceil_mode.

fixes #45357

TODO

- [ ] Ensure existing tests are checking for the correct output size

[ghstack-poisoned]
heitorschueroff added a commit that referenced this pull request Oct 21, 2020
ghstack-source-id: 61d608ceac4abd4cd329fb92dc61ea4c2757cd00
Pull Request resolved: #46558
This PR fixes a bug with how pooling output shape was computed. 

## BC Breaking Notes
Previously, the pooling code allowed a kernel window to be entirely outside the input and it did not consider right padding as part of the input in the computations. Now, in ceil mode it allows a kernel window to go off bounds as long as it starts within the input including both paddings. If ceil_mode=False, then all kernel windows have to start inside the input, again including both paddings.

fixes #45357

TODO

- [ ] Ensure existing tests are checking for the correct output size

[ghstack-poisoned]
heitorschueroff added a commit that referenced this pull request Oct 23, 2020
ghstack-source-id: 154dd1690c0001cd0808cc166495914ede0b891d
Pull Request resolved: #46558
test/test_nn.py Outdated Show resolved Hide resolved
test/test_nn.py Outdated Show resolved Hide resolved
This PR fixes a bug with how pooling output shape was computed. 

## BC Breaking Notes
Previously, the pooling code allowed a kernel window to be entirely outside the input and it did not consider right padding as part of the input in the computations. Now, in ceil mode it allows a kernel window to go off bounds as long as it starts within the input including both paddings. If ceil_mode=False, then all kernel windows have to start inside the input, again including both paddings.

fixes #45357

TODO

- [x] Ensure existing tests are checking for the correct output size

[ghstack-poisoned]
heitorschueroff added a commit that referenced this pull request Oct 27, 2020
ghstack-source-id: aa499843a0cd91df9b92a4470d2aaf22b6e2b75b
Pull Request resolved: #46558
This PR fixes a bug with how pooling output shape was computed. 

## BC Breaking Notes
Previously, the pooling code allowed a kernel window to be entirely outside the input and it did not consider right padding as part of the input in the computations. Now, in ceil mode it allows a kernel window to go off bounds as long as it starts within the input including both paddings. If ceil_mode=False, then all kernel windows have to start inside the input, again including both paddings.

fixes #45357

TODO

- [x] Ensure existing tests are checking for the correct output size

[ghstack-poisoned]
heitorschueroff added a commit that referenced this pull request Oct 27, 2020
ghstack-source-id: 5d42f05c70b85d499daf8fd9f7e3c7cb4ac323d5
Pull Request resolved: #46558
@mruberry mruberry removed the request for review from apaszke October 27, 2020 19:29
Copy link
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

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

Just two small fixes (doc strings + exact test case from issue). Cool fix!

This PR fixes a bug with how pooling output shape was computed.

## BC Breaking Notes
Previously, a bug in the pooling code allowed a sliding window to be entirely off bounds. Now, sliding windows must start inside the input or left padding (not right padding, see #46929) and may only go off-bounds if ceil_mode=True.

fixes #45357

TODO

- [x] Ensure existing tests are checking for the correct output size

[ghstack-poisoned]
heitorschueroff added a commit that referenced this pull request Oct 27, 2020
ghstack-source-id: 4f9c04b7291b44e20cc5600ebb224994f5411de1
Pull Request resolved: #46558
This PR fixes a bug with how pooling output shape was computed.

## BC Breaking Notes
Previously, a bug in the pooling code allowed a sliding window to be entirely off bounds. Now, sliding windows must start inside the input or left padding (not right padding, see #46929) and may only go off-bounds if ceil_mode=True.

fixes #45357

TODO

- [x] Ensure existing tests are checking for the correct output size

[ghstack-poisoned]
heitorschueroff added a commit that referenced this pull request Oct 29, 2020
ghstack-source-id: a08a0c29403cd88328bad8927c26fbed8e5348dd
Pull Request resolved: #46558
@facebook-github-bot
Copy link
Contributor

@heitorschueroff merged this pull request in 2643800.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug in max_pool2d with ceil_mode under certain conditions
3 participants