-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[ONNX] Make the ONNX Importer More Static #7429
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
9303222 to
52f09ee
Compare
70894a1 to
6e7b71c
Compare
electriclilies
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.
Overall, looks good to me -- I just left one comment about code style.
6e7b71c to
9c2c5a6
Compare
|
@masahi @jwfromm @tmoreau89 I think this is ready for review |
junrushao
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.
Really nice work @mbrookhart!!
|
Thank you @mbrookhart @electriclilies @junrushao1994 the PR has been merged |
* Construct static Ops if inputs are Constant * Expose FoldConstant as a function in addition to the pass * refactor onnx importer to do more static imports by constant folding fix pylint * fix test regressions * fix style, two bugs * pipe freeze_params through sub_graphs when importing loops and control flow
* Construct static Ops if inputs are Constant * Expose FoldConstant as a function in addition to the pass * refactor onnx importer to do more static imports by constant folding fix pylint * fix test regressions * fix style, two bugs * pipe freeze_params through sub_graphs when importing loops and control flow
We've been hitting a lot of issues in more complicated ONNX models where results of something like dynamic strided slice feed into an op like dynamic reshape, causing dynamic ranks to appear and crash the importer. To fix this, I decided it might be good to try to progagate constant information through the importer during import instead of trying to retroactively remove dynamic ops in a pass. To do that, I changed the freeze_params behavior of the importer to create constants before import, and made the importer fold constants through the importer as they are seen. Additionally, I edited the ops to only construct dynamic ops if the inputs are not constant.
In sum, this ends up creating many fewer dynamic ops in the ONNX importer, and so we see many fewer dynamic rank issues when importing models.
cc @masahi @jwfromm @electriclilies
@tmoreau89 found a serious performance regression on #7368, this change takes the import + dynamic_to_static of ONNX Bert Large from 20+ minutes to < 30s.