-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[JIT] canonicalize aten::rsub #65014
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
Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/) [ghstack-poisoned]
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit 1ee85d2 (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 to the (internal) Dr. CI Users group. |
Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/) ghstack-source-id: 138056629 Pull Request resolved: #65014
eellison
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.
Looks good!! a few comments from me. test ?
| // Normalize rsub such that `rsub(x,y) = sub(x,y)` | ||
| bool normalizeRSub(graph_node_list_iterator& iter) { | ||
| ArrayRef<Value*> args = iter->inputs(); | ||
| if (iter->kind() == aten::rsub) { |
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.
we all overloads for any particular symbol, so it's possible unlikely that there are other aten::rsub operators with different typed inputs for which this substitution isnt valid. just to be safe and future proof we should check the full schema here. you can use the node->matches("rsub.Tensor(Tensor self, Tensor other, *, Scalar alpha=1) -> Tensor") api.
See https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/native_functions.yaml#L4880, for this operator what we're doing isnt valid
|
|
||
| // Normalize rsub such that `rsub(x,y) = sub(x,y)` | ||
| bool normalizeRSub(graph_node_list_iterator& iter) { | ||
| ArrayRef<Value*> args = iter->inputs(); |
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.
nit: move args into the if block
| bool normalizeRSub(graph_node_list_iterator& iter) { | ||
| ArrayRef<Value*> args = iter->inputs(); | ||
| if (iter->kind() == aten::rsub) { | ||
| iter->replaceWithNewSymbol(aten::sub); |
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.
replaceWithNewSymbol returns the updated node, so the replacements we're doing in the following lines will not affect it but the existing node we're destroying
Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/) [ghstack-poisoned]
Pull Request resolved: #65014 ghstack-source-id: 138181235 Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/)
|
I tried running the test through buck: |
Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/) [ghstack-poisoned]
Pull Request resolved: #65014 ghstack-source-id: 138221870 Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/)
|
Ran tests |
eellison
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.
Nice! just one small comment
test/jit/test_peephole.py
Outdated
| FileCheck().check("conv").check("dim").run(conv_dim.graph) | ||
|
|
||
| def test_normalized_rsub(self): | ||
| def convertible_rsub(x: int, y: int): |
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.
i think we should be checking tensor inputs here
Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/) [ghstack-poisoned]
Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/) [ghstack-poisoned]
Pull Request resolved: #65014 ghstack-source-id: 138262596 Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/)
Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/) [ghstack-poisoned]
Pull Request resolved: #65014 ghstack-source-id: 138331729 Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/)
| {aten::true_divide_, aten::div_}, | ||
| {aten::concat, aten::cat}, | ||
| {aten::row_stack, aten::vstack}, | ||
| {aten::rsub, aten::sub}, |
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.
Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/) [ghstack-poisoned]
Pull Request resolved: #65014 ghstack-source-id: 138386559 Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/)
Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/) [ghstack-poisoned]
Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/) [ghstack-poisoned]
Pull Request resolved: #65014 ghstack-source-id: 138562901 Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/)
eellison
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.
Awesome!! 🚢 🚢 🚢
| if dtype == torch.float32: | ||
| # TODO: no reason why we cant run this with tracing graph | ||
| if support_script: | ||
| if support_script and op.name != "rsub": |
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.
@alanwaketan this is an example of an annoying test quirk that your PR will fix
Pull Request resolved: #65014 ghstack-source-id: 138656948 Differential Revision: [D30941389](https://our.internmc.facebook.com/intern/diff/D30941389/)
Summary: Pull Request resolved: #65014 ghstack-source-id: 138656948 Test Plan: ``` (pytorch) [[email protected] ~/pytorch] python3 test/test_jit.py TestPeephole CUDA not available, skipping tests monkeytype is not installed. Skipping tests for Profile-Directed Typing ........s...................... ---------------------------------------------------------------------- Ran 31 tests in 0.393s OK (skipped=1) (pytorch) [[email protected] ~/pytorch] python3 test/test_jit.py TestPeephole.test_normalized_rsub CUDA not available, skipping tests monkeytype is not installed. Skipping tests for Profile-Directed Typing . ---------------------------------------------------------------------- Ran 1 test in 0.015s OK ``` Reviewed By: eellison Differential Revision: D30941389 fbshipit-source-id: 03f0416d99090845c9bfb1e5fcf771d5f1d7a050
Summary: After a recent optimization pytorch/pytorch#65014 we started to normalize `aten::rsub` as `aten::sub`, so the test started to fail. This diff makes sure the test is passing. Reviewed By: wushirong Differential Revision: D31153947 fbshipit-source-id: 3ea52f8b7b99d164084390548be22a82e9f09c8c
Summary: Pull Request resolved: pytorch#5824 After a recent optimization pytorch/pytorch#65014 we started to normalize `aten::rsub` as `aten::sub`, so the test started to fail. This diff makes sure the test is passing. Reviewed By: wushirong Differential Revision: D31153947 fbshipit-source-id: b2a299274e5c440cd52342087cfcdb0b387cc4fb
Summary: Pull Request resolved: pytorch#5824 After a recent optimization pytorch/pytorch#65014 we started to normalize `aten::rsub` as `aten::sub`, so the test started to fail. This diff makes sure the test is passing. Reviewed By: wushirong Differential Revision: D31153947 fbshipit-source-id: d7034b18c2e44f4ce76481ed68e7ebf94c1bcfa1
Summary: Pull Request resolved: #5824 After a recent optimization pytorch/pytorch#65014 we started to normalize `aten::rsub` as `aten::sub`, so the test started to fail. This diff makes sure the test is passing. Reviewed By: wushirong Differential Revision: D31153947 fbshipit-source-id: 2aab03647a9910fddeb974a6d451ce3fa5376e4b

Stack from ghstack:
Differential Revision: D30941389