- 
                Notifications
    
You must be signed in to change notification settings  - Fork 609
 
Description
I got a vit model and I have already transform it to torch mlir file with print(mb.module) in python.
1st Problem is :
However, when I run "run_pipeline_with_repro_report( mb.module, "builtin.module(torch-backend-to-tosa-backend-pipeline)", "Lowering Torch Backend IR -> TOSA Backend IR")", it fails like this:
"python exception: Failure while executing pass pipeline:
error: unknown: failed to legalize operation 'torch.prim.NumToTensor.Scalar' that was explicitly marked illegal
note: unknown: see current operation: %3 = "torch.prim.NumToTensor.Scalar"(%2) : (!torch.int) -> !torch.tensor<[],si64>
error: "/home/tianyi/anaconda3/envs/torch-mlir/lib/python3.10/site-packages/torch/nn/modules/linear.py":114:0: aten.Linear called but weight rank not 2 or 3
note: "/home/tianyi/anaconda3/envs/torch-mlir/lib/python3.10/site-packages/torch/nn/modules/linear.py":114:0: see current operation: %3 = "torch.aten.linear"(%0, %2, %1) : (!torch.tensor<[4,4,192],f32>, !torch.tensor, !torch.tensor) -> !torch.tensor<[4,4,32],f32>
error: "/home/tianyi/anaconda3/envs/torch-mlir/lib/python3.10/site-packages/torch/nn/modules/linear.py":114:0: failed to legalize operation 'torch.aten.linear' that was explicitly marked illegal
note: "/home/tianyi/anaconda3/envs/torch-mlir/lib/python3.10/site-packages/torch/nn/modules/linear.py":114:0: see current operation: %3 = "torch.aten.linear"(%0, %2, %1) : (!torch.tensor<[4,4,192],f32>, !torch.tensor, !torch.tensor) -> !torch.tensor<[4,4,32],f32>
error: "/home/tianyi/anaconda3/envs/torch-mlir/lib/python3.10/site-packages/torch/nn/modules/linear.py":114:0: aten.Linear called but weight rank not 2 or 3
note: "/home/tianyi/anaconda3/envs/torch-mlir/lib/python3.10/site-packages/torch/nn/modules/linear.py":114:0: see current operation: %3 = "torch.aten.linear"(%0, %1, %2) : (!torch.tensor<[16,32],f32>, !torch.tensor, !torch.none) -> !torch.tensor<[16,576],f32>
error: "/home/tianyi/anaconda3/envs/torch-mlir/lib/python3.10/site-packages/torch/nn/modules/linear.py":114:0: failed to legalize operation 'torch.aten.linear' that was explicitly marked illegal
note: "/home/tianyi/anaconda3/envs/torch-mlir/lib/python3.10/site-packages/torch/nn/modules/linear.py":114:0: see current operation: %3 = "torch.aten.linear"(%0, %1, %2) : (!torch.tensor<[16,32],f32>, !torch.tensor, !torch.none) -> !torch.tensor<[16,576],f32>"
Then I use " torch-mlir-opt  --convert-torch-to-tosa  SimpleVIT.mlir" to lower this torch mlir file, and
2nd Problem comes:
"torch-mlir-opt: /home/tianyi/Torchmlir/torch-mlir-main/externals/llvm-project/llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From&) [with To = mlir::RankedTensorType; From = mlir::Type]: Assertion isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. torch-mlir-opt: /home/tianyi/Torchmlir/torch-mlir-main/externals/llvm-project/llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From&) [with To = mlir::RankedTensorType; From = mlir::Type]: Assertion isa(Val) && "cast() argument of incompatible type!"' failed.
Aborted (core dumped)"
The 1st problem occurs in python script and give more information, the 2nd problem occurs without too much information. So what is the reason for these 2 problems, and how can I debug in the 2nd problem?