-
Notifications
You must be signed in to change notification settings - Fork 26.3k
max_pool_with_indices: return valid indices if all input elements are -inf #23161
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
|
@pytorchbot retest this please. |
|
If all inputs are -inf, what would be the correct max_pool index to return? |
|
I extended the existing algorithm, where the first index wins in case of a tie, to infinities: >>> m = MaxPool2d(kernel_size=2, return_indices=True)
>>> v = 1.0
>>> t = torch.tensor([[[v, v], [v, v]]])
>>> m(t)
(tensor([[[1.]]]), tensor([[[0]]]))
>>>
>>> v = float("-inf")
>>> t = torch.tensor([[[v, v], [v, v]]])
>>> m(t)
(tensor([[[-inf]]]), tensor([[[0]]])) |
|
Compare with the current behavior: >>> m = MaxPool2d(kernel_size=2, return_indices=True)
>>> v = float("-inf")
>>> t = torch.tensor([[[v, v], [v, v]]])
>>> m(t)
(tensor([[[-3.4028e+38]]]), tensor([[[-1]]])) |
|
I was more concerned if the existing clamping to |
|
@pytorchbot retest this please. |
|
@ezyang I think this is ready for review. The issue is probably best summarized by the two code examples in this PR. The open questions are whether returning [The test failures look like known CI issues and GitHub outage fallout.] |
|
@pytorchbot retest this please. |
|
@pytorchbot rebase this please |
ezyang
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.
Thank you, this is a very nice fix!
Blame would probably be the only way to find out, but my guess is that the person who wrote this kernel just tried to find "some minimum value" and picked the wrong one. |
|
Waiting on CI. |
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.
… -inf (#23161) Summary: Fixes pytorch/pytorch#20465. Pull Request resolved: pytorch/pytorch#23161 Differential Revision: D16442672 Pulled By: ezyang fbshipit-source-id: 8c2ee13acd73954c7307720c01c732f460266a63
Fixes #20465.