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

[ONNX] Fix issue with absent value in onnx.ConstantOfShape #3713

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

zjgarvey
Copy link
Collaborator

Previously, if the value was absent, this conversion was creating a dense resource of value 0 with shape equal to the result shape, then later re-extracting a splat value. This only works if the shape is statically known, and even when the shape is known, this is completely unnecessary since the value's shape should be [1] and not the result shape.

This patch simply sets the splatvalue to a torch.constant.float 0.0 when the onnx op's value attr is absent, and adds nullptr checks to the subsequent conditionals to avoid them in the case where an attr is not given.

Addresses nod-ai/SHARK-ModelDev#831.

Copy link
Collaborator

@jinchen62 jinchen62 left a comment

Choose a reason for hiding this comment

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

LGTM!

@zjgarvey zjgarvey merged commit d2c387d into llvm:main Sep 17, 2024
3 checks passed
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.

2 participants