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
[ONNX] Fix graph position to insert clone node for inplace op removal #50123
[ONNX] Fix graph position to insert clone node for inplace op removal #50123
Conversation
💊 CI failures summary and remediationsAs of commit 8aeda1f (more details on the Dr. CI page):
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages: pytorch_linux_backward_compatibility_check_test (1/1)Step: "Run tests" (full log | diagnosis details | 🔁 rerun)
|
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 for fixing this.
Would you please show the graph for the test you added in comments?
Is this testing insertion into subblocks?
Showing before and after graph comparison. # before
graph(%x.1 : Float(3, 16, strides=[16, 1], requires_grad=0, device=cpu),
%fc.weight : Float(16, 16, strides=[16, 1], requires_grad=0, device=cpu),
%fc.bias.1 : Float(16, strides=[1], requires_grad=0, device=cpu)):
%3 : int = prim::Constant[value=2]() # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1663:22
%4 : int = prim::Constant[value=1]()
%5 : int = aten::dim(%x.1) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1663:7
%6 : bool = aten::eq(%5, %3) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1663:7
%out.1 : Tensor = prim::If(%6) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1663:4
block0():
%8 : Tensor = aten::t(%fc.weight) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1665:39
%ret.2 : Tensor = aten::addmm(%fc.bias.1, %x.1, %8, %4, %4) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1665:14
-> (%ret.2)
block1():
%10 : Tensor = aten::t(%fc.weight) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1667:30
%22 : None = prim::Constant()
### <----- %fc.bias clone inserted here
%fc.bias : Float(16, strides=[1], requires_grad=0, device=cpu) = aten::clone(%fc.bias.1, %22)
%output.2 : Tensor = aten::matmul(%x.1, %10) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1667:17
%23 : Tensor = aten::add(%output.2, %fc.bias, %4) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1669:12
-> (%23)
%13 : int = aten::dim(%out.1) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1663:7
%14 : bool = aten::eq(%13, %3) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1663:7
%out.3 : Tensor = prim::If(%14) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1663:4
block0():
%16 : Tensor = aten::t(%fc.weight) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1665:39
### <----- %fc.bias clone used in another block
%ret.1 : Tensor = aten::addmm(%fc.bias, %out.1, %16, %4, %4) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1665:14
-> (%ret.1)
block1():
%18 : Tensor = aten::t(%fc.weight) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1667:30
%output.1 : Tensor = aten::matmul(%out.1, %18) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1667:17
%24 : Tensor = aten::add(%output.1, %fc.bias, %4) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1669:12
-> (%24)
return (%out.3) # after
graph(%x.1 : Float(3, 16, strides=[16, 1], requires_grad=0, device=cpu),
%fc.weight : Float(16, 16, strides=[16, 1], requires_grad=0, device=cpu),
%fc.bias.1 : Float(16, strides=[1], requires_grad=0, device=cpu)):
%22 : None = prim::Constant()
### <----- %fc.bias clone inserted at the earliest after %fc.bias.1
%fc.bias : Float(16, strides=[1], requires_grad=0, device=cpu) = aten::clone(%fc.bias.1, %22)
%3 : int = prim::Constant[value=2]() # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1663:22
%4 : int = prim::Constant[value=1]()
%5 : int = aten::dim(%x.1) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1663:7
%6 : bool = aten::eq(%5, %3) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1663:7
%out.1 : Tensor = prim::If(%6) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1663:4
block0():
%8 : Tensor = aten::t(%fc.weight) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1665:39
%ret.2 : Tensor = aten::addmm(%fc.bias.1, %x.1, %8, %4, %4) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1665:14
-> (%ret.2)
block1():
%10 : Tensor = aten::t(%fc.weight) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1667:30
%output.2 : Tensor = aten::matmul(%x.1, %10) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1667:17
%23 : Tensor = aten::add(%output.2, %fc.bias, %4) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1669:12
-> (%23)
%13 : int = aten::dim(%out.1) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1663:7
%14 : bool = aten::eq(%13, %3) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1663:7
%out.3 : Tensor = prim::If(%14) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1663:4
block0():
%16 : Tensor = aten::t(%fc.weight) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1665:39
### <----- %fc.bias clone used here
%ret.1 : Tensor = aten::addmm(%fc.bias, %out.1, %16, %4, %4) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1665:14
-> (%ret.1)
block1():
%18 : Tensor = aten::t(%fc.weight) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1667:30
%output.1 : Tensor = aten::matmul(%out.1, %18) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1667:17
%24 : Tensor = aten::add(%output.1, %fc.bias, %4) # /home/bowbao/repos/pytorch_test/torch/nn/functional.py:1669:12
-> (%24)
return (%out.3) |
33f26ed
to
4db8cb4
Compare
873a151
to
4ab9c02
Compare
f3f8813
to
f347359
Compare
bb0c4ca
to
6497181
Compare
6497181
to
1cc7997
Compare
…#50123) Previous insertBefore approach might end-up inserting clone node in inner sub-blocks, while then the node being used later at other outside call sites. [ghstack-poisoned]
… op removal (#50123)" Previous insertBefore approach might end-up inserting clone node in inner sub-blocks, while then the node being used later at other outside call sites. [ghstack-poisoned]
… op removal (#50123)" Previous insertBefore approach might end-up inserting clone node in inner sub-blocks, while then the node being used later at other outside call sites. Differential Revision: [D26203124](https://our.internmc.facebook.com/intern/diff/D26203124) [ghstack-poisoned]
…#50123) (#51520) Summary: Pull Request resolved: #51520 Previous insertBefore approach might end-up inserting clone node in inner sub-blocks, while then the node being used later at other outside call sites. Test Plan: Imported from OSS Reviewed By: pbelevich Differential Revision: D26203124 Pulled By: SplitInfinity fbshipit-source-id: 999511e901ad1087f360bb689fcdfc3743c78aa4
…pytorch#50123) Previous insertBefore approach might end-up inserting clone node in inner sub-blocks, while then the node being used later at other outside call sites. ghstack-source-id: e9179a4d525906e0197289e31072f895d289637e Pull Request resolved: pytorch#51520
…pytorch#50123) Previous insertBefore approach might end-up inserting clone node in inner sub-blocks, while then the node being used later at other outside call sites.
Previous insertBefore approach might end-up inserting clone node in inner sub-blocks, while then the node being used later at other outside call sites.