-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[ONNX] Support exporting tensor factories from scripting #20255
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
2650c07 to
8470fc0
Compare
|
There is one part of common change in test_pytorch_onnx_caffe2.py to enable tests for models using ScriptModule in this PR #20256. Let's first get that one in, and I'll rebase this one accordingly. |
8470fc0 to
87b4beb
Compare
torch/onnx/symbolic_opset9.py
Outdated
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.
Confused here, why change the pin_memory to value instead of bool?
And why remove the pin_memory check?
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.
In short, since pin_memory is not used, changing from bool to value matches how other unused parameters like layout and device are handled, and unblocks the above issue.
=============
In more details, this is related to the default argument issue we discussed regarding ScriptModule models.
If pin_memory is not provided, it will be created as an empty prim::Constant in PTIR graph.
For most of the ops, that part is not handled today. The onnx exporter has no idea what's the default argument value, so the default value has to be added explicitly in symbolic method.
Some ops tried to resolve it by setting that param to 'v', and explicitly checking if it is empty.
pytorch/torch/onnx/symbolic_opset9.py
Line 826 in 987f1cc
| if weight is None or weight.node().mustBeNone(): |
pytorch/torch/onnx/symbolic_opset9.py
Line 831 in 987f1cc
| if bias is None or bias.node().mustBeNone(): |
Again, since pin_memory is not supported in onnx anyway, the latter checking part is ignored.
c16ee07 to
3e067e9
Compare
8e0fc04 to
27c443a
Compare
27c443a to
2993c43
Compare
houseroad
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.
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.
@houseroad has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
@houseroad merged this pull request in 12b0ded. |
No description provided.