-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[Testing] Adding reference tests to OpInfo class
#59369
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
Ready to be WIP in upstream
💊 CI failures summary and remediationsAs of commit e82dd34 (more details on the Dr. CI page and at hud.pytorch.org/pr/59369):
ci.pytorch.org: 1 failedThis 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 to the (internal) Dr. CI Users group. |
|
Examples of few edge cases encountered so far:
NumPy does not support integers as input and negative integers as powers (a There are 2 possible solutions to this:
(I can only think of these 2 right now, more suggestions and opinions are welcome).
The implementation of For now, only the above 2 ops have shown divergent behavior in any way out of 3 tested ( |
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 @krshrimali! Had a cursory look. Made a few comments and suggestions.
Apologies but I am a bit confused about the roadmap.
Will this PR try to add multiple operators or this PR plans to introduce the infrastructure and add reference for few operators and then gradually update the remaining operators in follow-up PRs? (Second one makes more sense to me.)
Thanks, it's a good question. I'll make the description clearer, but this is how I'm thinking the roadmap to be: (suggestions/feedback welcome)
Does this sound good? @kshitij12345 |
Since you'll be testing them locally already it would make sense to add them to this PR. This would serve two purposes.
Otherwise sounds good to me. Thanks! |
|
While testing on a other ops, here are a few more observations: Consider >>> torch.subtract(torch.tensor(1, dtype=torch.uint8), 3)
tensor(254, dtype=torch.uint8)
>>> np.subtract(np.array(1, dtype=np.uint8), 3)
-2The assertion for both of them to be equal will obviously fail since both the values and dtypes are different. One solution would be to mention dtype in such ops using
Since I have noticed this as an issue with Scalars/Numbers, so one solution could be to convert each scalar to a tensor (with dtype as the input dtype, here >>> np.subtract(np.array(1, dtype=np.uint8), np.array(3, dtype=np.uint8))
254But this solution won't work for the inputs: >>> torch.add(torch.tensor(1, dtype=torch.bool), 1)
2
>>> np.add(np.array(1, dtype=torch.bool), np.array(1, dtype=torch.bool))
TrueHere are a few ideas I have in my mind:
I'm oriented towards the 1st solution (to only run reference checks for non-scalar inputs), but there can be a better and logical solution to this, can't think of one right now. Any inputs/suggestions are welcome. @mruberry @pmeier @kshitij12345 |
|
Hey @krshrimali! Thanks for taking a close look at what references might look like, and what issues we may have when implementing references. A few concepts for us to work with:
Does that make sense? What are your thoughts? |
|
Made some simplifying comments, @krshrimali. Once they're incorporated I think this PR should be close to being ready; be sure to check that the lint issue is resolved, too. Other failures look unrelated. |
Thanks @mruberry for the review. I'e addressed the comments, and revised this PR testing for |
|
Remember to flake8 locally before submitting with a command like This has a conflict that needs to be resolved |
Sure, thanks for the suggestion! Will take care of this.
Thanks, I've resolved this @mruberry. |
|
Mac build should be fixed now; would you rebase this to retrigger that and the other tests? Sorry about that |
Done, thanks @mruberry! :) |
|
The test failure looks unrelated to this PR. Rest of the tests seem to pass, please let me know if there are any changes suggested whenever you find time. @mruberry Thanks! :) |
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.
Nice work, @krshrimali!
|
@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
|
Thanks @mruberry, @kshitij12345, @pmeier and @rgommers for helping in reviewing the PR. 🎉 |
Summary: This PR adds `complex64` dtype testing, following conversation from: pytorch/xla#3019 ([comment](pytorch/xla#3019 (comment))). Original PR that added OpInfo reference testing: #59369. cc: mruberry kshitij12345 Pull Request resolved: #61627 Reviewed By: gchanan Differential Revision: D29710560 Pulled By: mruberry fbshipit-source-id: 55b2e5ff47f031069335a0c75a45d4f4885ef9ac
This PR will ideally add
refargument toOpInfobase class. The idea is to add reference checks for all the ops eligible. For more discussion, please check #58294UnaryUfuncOpInfoclass toOpInfobase class.uint64isn't implemented in PyTorch but is there in NumPy, and this needs to be handled -- more on this later) -- Update: We decided that these reference tests should only test for values and not types.Remove reference tests from(Update: We won't be touching Unary Ufunc reference tests in this PR)test_unary_ufuncs.pyand test to make sure that nothing breaks.Note: To keep the PR description short, examples of edge cases encountered have been mentioned in the comments below.
cc: @mruberry @pmeier @kshitij12345