Open gabeweisz opened 7 months ago
https://github.com/llvm/torch-mlir/pull/2969#issuecomment-2018724958
The above issue implements lowering for onnx.LSTM and i'm having similar issues lowering to linalg
from what @qedawkins told me, the "failure destroying a value" error might be a spurious error message generated by the unrolling process in the dialect conversion framework.
@gabeweisz could you post the full log & full error message of torch-mlir-opt?
It might be - I'm actually running this in the iree compiler. I posted this here rather than in their github because that is what the instructions at the top of the error message told me to do
Full stack when running on the .mlir file attached:
iree-compile: /path_to/iree/third_party/llvm-project/mlir/include/mlir/IR/UseDefLists.h:198: mlir::IRObjectWithUseList
@gabeweisz when i encountered this error, there were two error messages & two stack traces. do you see the same or is this all you got?
This is all that I got - I'm running iree-compile (commit aa72368e1c9803ea1bfc37aac984d08a4c274cb4 from March 21) with the attached file and no other options. It is a "release with debug info" build
If I were triaging this I'd run the reproducer .mlir file through the compiler with --mlir-print-before-all
(and possibly also -debug
, but start with just the IR) then attach the IR (and pass name) just before the crash to the issue.
iree-build/tools/iree-compile model_small.mlir --print-before-all --debug >stdout.txt 2>stderr.txt
Without --debug I did not get anything printed but the stack trace,
This is what is right before the crash:
//===-------------------------------------------===//
Legalizing operation : 'torch.aten.view'(0x56194dc70670) {
%182 = "torch.aten.view"(%168, %181) : (!torch.vtensor<[?,16,768],f32>, !torch.list
Fold { } -> FAILURE : unable to fold
Pattern : 'torch.aten.view -> ()' {
Trying to match "(anonymous namespace)::ConvertAtenViewOp"
Insert : 'arith.constant'(0x7f99080568c0)
Insert : 'tensor.dim'(0x7f990803cdf0)
Insert : 'arith.constant'(0x7f9908033b90)
Insert : 'arith.constant'(0x7f99080569b0)
Insert : 'arith.constant'(0x7f9908033980)
Insert : 'arith.constant'(0x7f9908038ba0)
Insert : 'torch_c.to_i64'(0x7f9908037280)
Insert : 'torch_c.to_i64'(0x7f9908038c10)
** Failure : unimplemented: found unhandled case of expansion/collapse in aten.view
"(anonymous namespace)::ConvertAtenViewOp" result 0
} -> FAILURE : pattern failed to match
Pattern : 'torch.aten.view -> ()' { Trying to match "(anonymous namespace)::ConvertAtenScalarToTensorLike" ** Failure : not a supported Scalar to Tensor like op "(anonymous namespace)::ConvertAtenScalarToTensorLike" result 0 } -> FAILURE : pattern failed to match
Pattern : 'torch.aten.view -> ()' { Trying to match "(anonymous namespace)::ConvertElementwiseOp" ** Failure : not a supported elementwise op "(anonymous namespace)::ConvertElementwiseOp" result 0 } -> FAILURE : pattern failed to match
Pattern : 'torch.aten.view -> ()' { Trying to match "(anonymous namespace)::ConvertReductionOp" ** Failure : not a supported reduce op "(anonymous namespace)::ConvertReductionOp" result 0 } -> FAILURE : pattern failed to match } -> FAILURE : no matched legalization pattern
If I add the right flag for "--mlir-print-ir-before-all" I get this stderr stderr.txt
The last thing printed was:
// -----// IR Dump Before ConvertTorchToArith (convert-torch-to-arith) //----- //
func.func @forward(%arg0: tensor<?x16xi32>) -> (tensor<?x16x50280xf32>, tensor<1x?x1536x16xf32>, tensor<1x?x1536x3xf32>) attributes {torch.args_schema = "[1, {\22type\22: \22builtins.tuple\22,iree-compile: /home/gweisz/iree/third_party/llvm-project/mlir/include/mlir/IR/UseDefLists.h:198: mlir::IRObjectWithUseList
Still fails with commit 5cd0a0ccd941db51936a059ed9f096717a8312e5
Some more from the log (with --mlir-print-ir-before-all --debug) : //===-------------------------------------------===//
//===-------------------------------------------===// Legalizing operation : 'torch.aten.mul.int'(0x556fc1511760) { %180 = "torch.aten.mul.int"(%55, %24) : (!torch.int, !torch.int) -> !torch.int
Fold { } -> FAILURE : unable to fold
Pattern : 'torch.aten.mul.int -> ()' { Trying to match "(anonymous namespace)::ConvertAtenScalarToTensorLike" ** Failure : not a supported Scalar to Tensor like op "(anonymous namespace)::ConvertAtenScalarToTensorLike" result 0 } -> FAILURE : pattern failed to match
Pattern : 'torch.aten.mul.int -> ()' { Trying to match "(anonymous namespace)::ConvertElementwiseOp" ** Failure : not a supported elementwise op "(anonymous namespace)::ConvertElementwiseOp" result 0 } -> FAILURE : pattern failed to match
Pattern : 'torch.aten.mul.int -> ()' { Trying to match "(anonymous namespace)::ConvertReductionOp" ** Failure : not a supported reduce op "(anonymous namespace)::ConvertReductionOp" result 0 } -> FAILURE : pattern failed to match } -> FAILURE : no matched legalization pattern //===-------------------------------------------===//
//===-------------------------------------------===//
Legalizing operation : 'torch.prim.ListConstruct'(0x556fc1511da0) {
%181 = "torch.prim.ListConstruct"(%180, %12) : (!torch.int, !torch.int) -> !torch.list
Fold { } -> FAILURE : unable to fold
Pattern : 'torch.prim.ListConstruct -> ()' { Trying to match "(anonymous namespace)::ConvertAtenScalarToTensorLike" ** Failure : not a supported Scalar to Tensor like op "(anonymous namespace)::ConvertAtenScalarToTensorLike" result 0 } -> FAILURE : pattern failed to match
Pattern : 'torch.prim.ListConstruct -> ()' { Trying to match "(anonymous namespace)::ConvertElementwiseOp" ** Failure : not a supported elementwise op "(anonymous namespace)::ConvertElementwiseOp" result 0 } -> FAILURE : pattern failed to match
Pattern : 'torch.prim.ListConstruct -> ()' { Trying to match "(anonymous namespace)::ConvertReductionOp" ** Failure : not a supported reduce op "(anonymous namespace)::ConvertReductionOp" result 0 } -> FAILURE : pattern failed to match } -> FAILURE : no matched legalization pattern //===-------------------------------------------===//
//===-------------------------------------------===//
Legalizing operation : 'torch.aten.view'(0x556fc1511eb0) {
%182 = "torch.aten.view"(%168, %181) : (!torch.vtensor<[?,16,768],f32>, !torch.list
Fold { } -> FAILURE : unable to fold
Pattern : 'torch.aten.view -> ()' {
Trying to match "(anonymous namespace)::ConvertAtenViewOp"
Insert : 'arith.constant'(0x7f2ab4000bc0)
Insert : 'tensor.dim'(0x7f2ab401a080)
Insert : 'arith.constant'(0x7f2ab40337d0)
Insert : 'arith.constant'(0x7f2ab4000c30)
Insert : 'arith.constant'(0x7f2ab4000ca0)
Insert : 'arith.constant'(0x7f2ab4000d10)
Insert : 'torch_c.to_i64'(0x7f2ab404f820)
Insert : 'torch_c.to_i64'(0x7f2ab4040920)
** Failure : unimplemented: found unhandled case of expansion/collapse in aten.view
"(anonymous namespace)::ConvertAtenViewOp" result 0
} -> FAILURE : pattern failed to match
Pattern : 'torch.aten.view -> ()' { Trying to match "(anonymous namespace)::ConvertAtenScalarToTensorLike" ** Failure : not a supported Scalar to Tensor like op "(anonymous namespace)::ConvertAtenScalarToTensorLike" result 0 } -> FAILURE : pattern failed to match
Pattern : 'torch.aten.view -> ()' { Trying to match "(anonymous namespace)::ConvertElementwiseOp" ** Failure : not a supported elementwise op "(anonymous namespace)::ConvertElementwiseOp" result 0 } -> FAILURE : pattern failed to match
Pattern : 'torch.aten.view -> ()' { Trying to match "(anonymous namespace)::ConvertReductionOp" ** Failure : not a supported reduce op "(anonymous namespace)::ConvertReductionOp" result 0 } -> FAILURE : pattern failed to match } -> FAILURE : no matched legalization pattern
What happened?
iree-compile: /_pathto/iree/third_party/llvm-project/mlir/include/mlir/IR/UseDefLists.h:198: mlir::IRObjectWithUseList::~IRObjectWithUseList() [OperandType = mlir::OpOperand]: Assertion `use_empty() && "Cannot destroy a value that still has uses!"' failed.
Steps to reproduce your issue
iree-build/tools/iree-compile model_small.mlir.txt model_small.mlir.txt
What component(s) does this issue relate to?
No response
Version information
No response
Additional context
No response