Skip to content

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

Conversation

spandantiwari
Copy link

@spandantiwari spandantiwari commented Oct 31, 2019

Currently, keep_initializers_as_input argument in torch.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 with keep_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.

# 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,
Copy link
Member

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.

Copy link
Author

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.

@spandantiwari spandantiwari force-pushed the spandantiwari/restrict_irv4_on_opset branch from cfaba28 to 2112fcf Compare November 4, 2019 22:23
@spandantiwari
Copy link
Author

@houseroad - updated the PR based on your comment.

@spandantiwari
Copy link
Author

@houseroad - there's only one failing job, which is unrelated and seems to be a stall (Too long with no output (exceeded 1h30m0s)). All others have passed.

Copy link
Member

@houseroad houseroad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

@facebook-github-bot
Copy link
Contributor

@houseroad merged this pull request in 509d963.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants