-
Notifications
You must be signed in to change notification settings - Fork 25k
Disabling ONNX IR v4 sematics for opset 8 or lower. #28990
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
Disabling ONNX IR v4 sematics for opset 8 or lower. #28990
Conversation
test/onnx/test_operators.py
Outdated
# and initializers are listed as ONNX graph input, in accordance | ||
# with ONNX IR v3 semantics (which apply to opset version <= 8). | ||
x = torch.ones(20, 16, 50, 40, requires_grad=True) | ||
self.assertONNX(nn.Conv2d(16, 13, 3, bias=False), x, opset_version=8, |
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.
can we use a smaller kernel and zero them, otherwise, we may problem due to the randomness in the initializers.
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.
Yes, that makes sense. I have updated the PR to use a smaller kernel and all ones weights. Thanks.
cfaba28
to
2112fcf
Compare
@houseroad - updated the PR based on your comment. |
@houseroad - there's only one failing job, which is unrelated and seems to be a stall ( |
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, 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.
@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 509d963. |
Currently,
keep_initializers_as_input
argument intorch.onnx.export
API can be used to choose whether to export an ONNX model with IR v3 or v4 semantics. Currently, the implementation does not check for which opset is being used for export. This is an issue because ONNX IR v4 is valid only for opset 9 and above (as listed here), and opset 8 or lower export withkeep_initializers_as_input=False
will create a illegal ONNX graph.This change fixes this by introducing a check on opset version when deciding whether to export ONNX IR v3 or v4.