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

convert to double before float materialization in scalarize shapes #3887

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

zjgarvey
Copy link
Collaborator

Addresses a bug when trying to materialize a non fp64 attr to a constant float op in scalarize shapes.

@jinchen62
Copy link
Collaborator

@zjgarvey I'm a bit confused, why are we converting all FloatAttr to double.

@zjgarvey
Copy link
Collaborator Author

@zjgarvey I'm a bit confused, why are we converting all FloatAttr to double.

Torch::ConstantFloatOp has a value attribute that needs to be a f64 or double. Not converting FloatAttrs to double and trying to create a constant float op will result in the error you saw:

error: 'torch.constant.float' op attribute 'value' failed to satisfy constraint: 64-bit float attribute
    %908 = torch.operator "onnx.Cast"(%907) {torch.onnx.to = 1 : si64} : (!torch.vtensor<[1],si64>) -> !torch.vtensor<[1],f32>
note: see current operation: %777 = "torch.constant.float"() <{value = 3.000000e+00 : f32}> : () -> !torch.float

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 0913b96 into llvm:main Nov 22, 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