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 torch.nn.FractionalMaxPool2d output_size error #99507

Closed
wants to merge 4 commits into from
Closed

Fix torch.nn.FractionalMaxPool2d output_size error #99507

wants to merge 4 commits into from

Conversation

tfsingh
Copy link
Contributor

@tfsingh tfsingh commented Apr 19, 2023

Fixes #99148 , raising an error if output_ratio's size > 2.

Justification for changes:

If an output size is not specified but an output ratio is, we call fractional_max_pool2d_with_indices. We then generate the value of output_size based on the first two integers of the output_ratio (line ~480 of torch.nn.functional.py).

Thus, we should raise a value error in the case that the user passes an output_ratio (instead of an output_size) and the number of elements in output_ratio exceeds two. We must raise an error before calling torch._C._nn.franctional_max_pool2d as the value of output_size passed into torch._C._nn.fractional_max_pool2d is guaranteed to be of size 2 (as the existing code generates it from the first two indices of the passed in ratio).

I would be happy to iterate on this if there are any issues.

cc @albanD

@pytorch-bot
Copy link

pytorch-bot bot commented Apr 19, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/99507

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 1 Failures

As of commit 513d3d2:

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@tfsingh tfsingh changed the title Output error Fix torch.nn.FractionalMaxPool2d output_size error Apr 19, 2023
Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

The change looks good. Could you please add a one off test in test_nn.py to make sure that this error is properly raised?

@albanD albanD added release notes: nn release notes category topic: bug fixes topic category labels Apr 19, 2023
@tfsingh
Copy link
Contributor Author

tfsingh commented Apr 19, 2023

Of course, just added it. Please let me know if there are any issues, I would be happy to iterate on them.

Copy link
Contributor

@mikaylagawarecki mikaylagawarecki left a comment

Choose a reason for hiding this comment

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

To fix the failing lint job running setup_lint and quicklint from your local pytorch directory and following the corresponding instructions should be sufficient, see here

test/test_nn.py Outdated
arg_3_0 = arg_3_0_tensor.clone()
arg_3 = [arg_3_0,]

with self.assertRaises(ValueError):
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could you use self.assertRaisesRegex instead to verify the correct error message is raised please

See here for an example of how to use assertRaisesRegex

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course, this + the lint issues should be fixed now!

@mikaylagawarecki
Copy link
Contributor

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Apr 20, 2023
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: trunk / macos-12-py3-arm64 / test (default, 1, 3, macos-m1-12)

Details for Dev Infra team Raised by workflow job

@mikaylagawarecki
Copy link
Contributor

@pytorchbot merge -f "sympy import error unrelated"

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged open source release notes: nn release notes category topic: bug fixes topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

torch.nn.FractionalMaxPool2d output_size error
5 participants