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

torch.aten.view to linalg #568

Open
saienduri opened this issue Mar 28, 2024 · 2 comments
Open

torch.aten.view to linalg #568

saienduri opened this issue Mar 28, 2024 · 2 comments
Assignees

Comments

@saienduri
Copy link
Contributor

saienduri commented Mar 28, 2024

We are running into these issues when lowering torch.aten.view to linalg in these models (bart-large, mit-b0, t5-base, t5-large, ShuffleNet_v2_x2_0_vaiq_int8). Repro instructions can be found here:

bart-large.default.pytorch.torch.mlir:362:12: error: failed to legalize operation 'torch.aten.view' that was explicitly marked illegal
    %309 = torch.aten.reshape %281, %308 : !torch.vtensor<[?,9,1024],f32>, !torch.list<int> -> !torch.vtensor<[1,?,16,64],f32>
           ^
bart-large.default.pytorch.torch.mlir:362:12: note: see current operation: %834 = "torch.aten.view"(%832, %833) : (!torch.vtensor<[?,9,1024],f32>, !torch.list<int>) -> !torch.vtensor<[1,?,16,64],f32>
mit-b0.default.pytorch.torch.mlir:296:12: error: failed to legalize operation 'torch.aten.view' that was explicitly marked illegal
    %250 = torch.aten.reshape %247, %249 : !torch.vtensor<[?,?,?],f32>, !torch.list<int> -> !torch.vtensor<[1,32,128,128],f32>
           ^
mit-b0.default.pytorch.torch.mlir:296:12: note: see current operation: %938 = "torch.aten.view"(%936, %937) : (!torch.vtensor<[?,?,?],f32>, !torch.list<int>) -> !torch.vtensor<[1,32,128,128],f32>
t5-base.default.pytorch.torch.mlir:1860:13: error: failed to legalize operation 'torch.aten.view' that was explicitly marked illegal
    %1163 = torch.aten.tile %1155, %1162 : !torch.vtensor<[?,?,512],si64>, !torch.list<int> -> !torch.vtensor<[?,?,512],si64>
            ^
t5-base.default.pytorch.torch.mlir:1860:13: note: see current operation: %10542 = "torch.aten.view"(%10531, %10541) : (!torch.vtensor<[1,?,512,?,1,512],si64>, !torch.list<int>) -> !torch.vtensor<[?,512,?,1,512],si64>
t5-large.default.pytorch.torch.mlir:3480:13: error: failed to legalize operation 'torch.aten.view' that was explicitly marked illegal
    %2171 = torch.aten.tile %2163, %2170 : !torch.vtensor<[?,?,512],si64>, !torch.list<int> -> !torch.vtensor<[?,?,512],si64>
            ^
t5-large.default.pytorch.torch.mlir:3480:13: note: see current operation: %20514 = "torch.aten.view"(%20503, %20513) : (!torch.vtensor<[1,?,512,?,1,512],si64>, !torch.list<int>) -> !torch.vtensor<[?,512,?,1,512],si64>
torch-mlir-opt --convert-torch-onnx-to-torch  --torch-decompose-complex-ops --cse --canonicalize --convert-torch-to-linalg ./ShuffleNet_v2_x2_0_vaiq_int8.default.torch-onnx.mlir 
./ShuffleNet_v2_x2_0_vaiq_int8.default.torch-onnx.mlir:364:12: error: failed to legalize operation 'torch.aten.view' that was explicitly marked illegal
    %360 = torch.operator "onnx.Reshape"(%344, %359) {torch.onnx.allowzero = 0 : si64} : (!torch.vtensor<[?,?,?,?],f32>, !torch.vtensor<[5],si64>) -> !torch.vtensor<[?,?,?,?,?],f32> 
           ^
./ShuffleNet_v2_x2_0_vaiq_int8.default.torch-onnx.mlir:364:12: note: see current operation: %2002 = "torch.aten.view"(%1941, %1205) : (!torch.vtensor<[?,?,?,?],f32>, !torch.list<int>) -> !torch.vtensor<[?,?,?,?,?],f32>
@saienduri saienduri changed the title aten view op torch.aten.view Mar 28, 2024
@saienduri saienduri changed the title torch.aten.view Lowering to torch.aten.view Mar 28, 2024
@AmosLewis AmosLewis changed the title Lowering to torch.aten.view Lowering torch.aten.view to linalg Apr 19, 2024
@AmosLewis AmosLewis changed the title Lowering torch.aten.view to linalg torch.aten.view to linalg Apr 19, 2024
@Shukla-Gaurav
Copy link

Shukla-Gaurav commented May 14, 2024

Current status on above models: @kumardeepakamd @AmosLewis

  1. bart-large:
iree-compile: /home/gashukla/MLIR/iree/third_party/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:156: T llvm::PointerUnion<mlir::Attribute, mlir::Value>::get() const [PT = <mlir::Attribute,
 mlir::Value>, T = mlir::Value]: Assertion `isa<T>(*this) && "Invalid accessor called"' failed.
Please report issues to https://github.com/iree-org/iree/issues and include the crash backtrace.

It's failing in fold-unit-dims pass. further debugging.

  1. mit-b0: iree-compile passed, [mismatch] issue.

  2. t5-base and t5-large: both passed successfully.

  3. shufflenet_vaiq_int8: iree-compile passed, [mismatch] issue.

@vivekkhandelwal1
Copy link
Contributor

Hi @Shukla-Gaurav, are you still working on this op? If not, then can you please update the issue?

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

No branches or pull requests

3 participants