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 onnx.Shape lowering with scalar input #3716

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

jinchen62
Copy link
Collaborator

@zjgarvey
Copy link
Collaborator

I get a segfault with this when running

--convert-torch-onnx-to-torch --convert-torch-to-linalg

on

module {
  func.func @main(%arg0: !torch.vtensor<[],f32>) -> !torch.vtensor<[?],si64> attributes {torch.onnx_meta.ir_version = 10 : si64, torch.onnx_meta.opset_version = 21 : si64, torch.onnx_meta.producer_name = "", torch.onnx_meta.producer_version = ""} {
    %none = torch.constant.none
    %0 = torch.operator "onnx.Shape"(%arg0) : (!torch.vtensor<[],f32>) -> !torch.vtensor<[?],si64> 
    return %0 : !torch.vtensor<[?],si64>
  }
}

As a side note, I ran an onnx model with this setup in onnxruntime, and the output was literally an empty numpy array...

array([], dtype=int64)

@jinchen62
Copy link
Collaborator Author

@zjgarvey I tested this case and it got lowered. Let me double check.

@jinchen62 jinchen62 force-pushed the shape_scalar branch 3 times, most recently from 6cd11ac to 2a5cd4d Compare September 26, 2024 16:53
Copy link
Collaborator

@zjgarvey zjgarvey left a comment

Choose a reason for hiding this comment

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

LGTM

@jinchen62 jinchen62 merged commit a33d123 into llvm:main Sep 27, 2024
3 checks passed
@jinchen62 jinchen62 deleted the shape_scalar branch September 27, 2024 20:30
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