-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Improve torch.norm functionality, errors, and tests
#41956
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
Improve torch.norm functionality, errors, and tests
#41956
Conversation
💊 CI failures summary and remediationsAs of commit ab7546e (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. This comment has been revised 30 times. |
ba0fcdc to
50b7cca
Compare
torch.norm behaviortorch.norm functionality, errors, and tests
50b7cca to
933fcc9
Compare
|
I'm pretty sure the |
It's not. Unfortunately that build's very flaky, sorry. Also, I hope to get a chance to look at this later today. Sorry to keep you waiting, @kurtamohler. |
|
No worries @mruberry ! |
mruberry
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.
Hey @kurtamohler! This looks pretty good to me. I added a couple requests for comments and suggested some changes to the test for coverage and maintainability.
This will be BC-breaking for users who were using keepdims previously, right? Would you write a "BC-Breaking Note" section at the top of the PR summary describing the before/after? We use these notes to write the release docs.
* Fix keepdim behavior in nuclear_norm and norm * Throw descriptive errors for unsupported sparse norm args * Increase unit test coverage for these cases and for complex inputs
bc37b5f to
ab7546e
Compare
|
Thanks for the review @mruberry! I believe I've addressed all your suggestions now. Also added the BC breaking note in the description. |
mruberry
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.
Thanks @kurtamohler! Looks great.
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.
@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
BC-Breaking Note:
BC breaking changes in the case where keepdim=True. Before this change, when calling
torch.normwith keepdim=True and p='fro' or p=number, leaving all other optional arguments as their default values, the keepdim argument would be ignored. Also, any timetorch.normwas called with p='nuc' and keepdim=True, the result would have one fewer dimension than the input, and the dimensions could be out of order depending on which dimensions were being reduced. After the change, for each of these cases, the result has the same number and order of dimensions as the input.PR Summary:
These changes were taken from part of PR #40924. That PR is not going to be merged because it overrides
torch.norm's interface, which we want to avoid. But these improvements are still useful.Issue #24802