Skip to content
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

Fix onnx importer to treat Constant values as static #2780

Merged
merged 14 commits into from
Jan 22, 2024

Conversation

daveliddell
Copy link
Collaborator

Fixes #2764

In the case of OPT, there are ConstantOfShape ops whose input shape is not static (that is, an initializer), but rather comes from a Constant op. The importer can't handle such non-static input shapes.

The fix here is to create initializers for a subset of Constant ops (ones with "value" attributes), so that their outputs can be used statically. Additionally, there was no case for creating a splat of int64, so I added that as well.

@daveliddell daveliddell marked this pull request as ready for review January 21, 2024 19:03
Copy link
Collaborator

@stellaraccident stellaraccident left a comment

Choose a reason for hiding this comment

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

A few small nits then good to go. Thanks!

python/torch_mlir/extras/onnx_importer.py Outdated Show resolved Hide resolved
python/torch_mlir/extras/onnx_importer.py Outdated Show resolved Hide resolved
python/torch_mlir/extras/onnx_importer.py Outdated Show resolved Hide resolved
@stellaraccident
Copy link
Collaborator

Interesting that this kind of thing doesn't seem to be in the onnx test suite... (would have caused an xfail to start passing)

@stellaraccident stellaraccident merged commit d452c4f into llvm:main Jan 22, 2024
5 checks passed
@daveliddell daveliddell deleted the dliddell-2764-const branch January 22, 2024 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Importing ONNX model for facebook/opt-125M into torch-mlir fails
2 participants