nod-ai / SHARK-ModelDev

Unified compiler/runtime for interfacing with PyTorch Dynamo.
Apache License 2.0
95 stars 48 forks source link

Regression: Crash due to recent changes #831

Closed pdhirajkumarprasad closed 1 month ago

pdhirajkumarprasad commented 2 months ago

Seeing crash for below IR while earlier it was failing with legalization and is seen across multiple model

module {
  func.func @"torch-jit-export"(%arg0: !torch.vtensor<[2],si64>, %arg1: !torch.vtensor<[1],si64> ) -> (!torch.vtensor<[?,1,?],f32>) attributes {torch.onnx_meta.ir_version = 7 : si64, torch.onnx_meta.opset_version = 21 : si64, torch.onnx_meta.producer_name = "pytorch", torch.onnx_meta.producer_version = "1.11.0"} {
    %1 = torch.operator "onnx.ConstantOfShape"(%arg0)  : (!torch.vtensor<[2],si64>) -> !torch.vtensor<[?,?],f32> 
    %2 = torch.operator "onnx.Unsqueeze"(%1, %arg1) : (!torch.vtensor<[?,?],f32>, !torch.vtensor<[1],si64>) -> !torch.vtensor<[?,1,?],f32> 
    return %2 : !torch.vtensor<[?,1,?],f32>
  }
}
ScottTodd commented 2 months ago

Do you have logs and/or a callstack for the crash?

pdhirajkumarprasad commented 2 months ago

Crash log

iree-compile: /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/mlir/lib/IR/BuiltinAttributes.cpp:1349: static mlir::DenseElementsAttr mlir::DenseIntOrFPElementsAttr::getRaw(mlir::ShapedType, ArrayRef<char>): Assertion `type.hasStaticShape() && "type must have static shape"' failed.
Please report issues to https://github.com/iree-org/iree/issues and include the crash backtrace.
Stack dump:
0.  Program arguments: iree-compile --mlir-print-debuginfo --mlir-print-op-on-diagnostic=false --iree-hal-target-backends=llvm-cpu t1.mlir
 #0 0x00007fcf657bf027 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13
 #1 0x00007fcf657bd260 llvm::sys::RunSignalHandlers() /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/llvm/lib/Support/Signals.cpp:106:18
 #2 0x00007fcf657bf6ea SignalHandler(int) /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #3 0x00007fcf5ef80520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007fcf5efd49fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007fcf5efd49fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007fcf5efd49fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007fcf5ef80476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007fcf5ef667f3 abort ./stdlib/abort.c:81:7
 #9 0x00007fcf5ef6671b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007fcf5ef77e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00007fcf6581e730 mlir::DenseIntOrFPElementsAttr::getRaw(mlir::ShapedType, llvm::ArrayRef<char>) /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/mlir/lib/IR/BuiltinAttributes.cpp:1352:3
#12 0x00007fcf6581d7a8 mlir::DenseElementsAttr::get(mlir::ShapedType, llvm::ArrayRef<mlir::Attribute>) /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/mlir/lib/IR/BuiltinAttributes.cpp:982:10
#13 0x00007fcf665118aa mlir::torch::onnx_c::populateDefaultDomainAtoF(mlir::torch::onnx_c::OnnxCustomOpConversionPattern&)::$_50::operator()(mlir::torch::onnx_c::OpBinder, mlir::ConversionPatternRewriter&) const /proj/rdi/staff/dhirajp/localBuild/iree/third_party/torch-mlir/lib/Conversion/TorchOnnxToTorch/DefaultDomainAtoF.cpp:2794:15
#14 0x00007fcf665118aa mlir::torch::onnx_c::populateDefaultDomainAtoF(mlir::torch::onnx_c::OnnxCustomOpConversionPattern&)::$_50::__invoke(mlir::torch::onnx_c::OpBinder, mlir::ConversionPatternRewriter&) /proj/rdi/staff/dhirajp/localBuild/iree/third_party/torch-mlir/lib/Conversion/TorchOnnxToTorch/DefaultDomainAtoF.cpp:2750:7
#15 0x00007fcf6651f05b llvm::LogicalResult::succeeded() const /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:40:45
#16 0x00007fcf6651f05b llvm::succeeded(llvm::LogicalResult) /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:67:61
#17 0x00007fcf6651f05b mlir::torch::onnx_c::OnnxCustomOpConversionPattern::matchAndRewrite(mlir::torch::Torch::OperatorOp, mlir::torch::Torch::OperatorOpAdaptor, mlir::ConversionPatternRewriter&) const /proj/rdi/staff/dhirajp/localBuild/iree/third_party/torch-mlir/lib/Conversion/TorchOnnxToTorch/Patterns.cpp:35:9
#18 0x00007fcf664d4862 mlir::OpConversionPattern<mlir::torch::Torch::OperatorOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::ConversionPatternRewriter&) const /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/mlir/include/mlir/Transforms/DialectConversion.h:545:3
#19 0x00007fcf69af39f2 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:1655:10
#20 0x00007fcf69b33ede mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>)::$_2::operator()() const /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/mlir/lib/Rewrite/PatternApplicator.cpp:212:13
#21 0x00007fcf69b33ede void llvm::function_ref<void ()>::callback_fn<mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>)::$_2>(long) /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#22 0x00007fcf69b30f1f mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>) /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/mlir/lib/Rewrite/PatternApplicator.cpp:233:9
#23 0x00007fcf69af48d9 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:0:0
#24 0x00007fcf69af3a57 mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:0:0
#25 0x00007fcf69af4adf llvm::LogicalResult::failed() const /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43
#26 0x00007fcf69af4adf llvm::failed(llvm::LogicalResult) /proj/rdi/staff/dhirajp/localBuild/iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:71:58

Complete crash log present in below file:

crash.log

zjgarvey commented 2 months ago

Crashes on --convert-torch-onnx-to-torch. I'm looking into it.

Args: torch-mlir-opt --convert-torch-onnx-to-torch repro.mlir --debug 
Load new dialect in Context builtin
ImplicitTypeIDRegistry::lookupOrInsert(mlir::ShapedType)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::MemRefLayoutAttrInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::TypedAttr)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::ElementsAttr)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::DistinctAttr)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::BytecodeOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::SymbolOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpAsmOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::RegionKindInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::ConditionallySpeculatable)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::MemoryEffectOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::ResourceBlobManagerDialectInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpAsmDialectInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::BytecodeDialectInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::detail::AffineBinaryOpExprStorage)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::detail::AffineConstantExprStorage)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::detail::AffineDimExprStorage)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::detail::AffineMapStorage)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::detail::IntegerSetStorage)
Load new dialect in Context builtin
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::ZeroOperands<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::OneRegion<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::ZeroResults<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::ZeroSuccessors<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::NoRegionArguments<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::NoTerminator<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::SingleBlock<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::OpInvariants<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::BytecodeOpInterface::Trait<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::AffineScope<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::IsIsolatedFromAbove<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::SymbolTable<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::SymbolOpInterface::Trait<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpAsmOpInterface::Trait<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::RegionKindInterface::Trait<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::HasOnlyGraphRegion<Empty>)
Load new dialect in Context func
ImplicitTypeIDRegistry::lookupOrInsert(mlir::CallOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::SymbolUserOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::CallableOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::FunctionOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::RegionBranchTerminatorOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::DialectInlinerInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::ConvertToLLVMPatternInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::bufferization::BufferizableOpInterface)
Load new dialect in Context cf
Load new dialect in Context arith
ImplicitTypeIDRegistry::lookupOrInsert(mlir::arith::ArithFastMathInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::VectorUnrollOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::InferTypeOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::InferIntRangeInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::arith::ArithIntegerOverflowFlagsInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::CastOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::arith::ArithRoundingModeInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::SelectLikeOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::bufferization::BufferDeallocationOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::ValueBoundsOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::BranchOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::AutomaticAllocationScope<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::CallableOpInterface::Trait<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::FunctionOpInterface::Trait<Empty>)
Load new dialect in Context torch
ImplicitTypeIDRegistry::lookupOrInsert(mlir::RegionBranchOpInterface)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::VariadicRegions<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::VariadicResults<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::VariadicOperands<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::torch::Torch::OpTrait::AllowsTypeRefinement<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::torch::Torch::detail::OperatorOpGenericAdaptorBase::Properties)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::ZeroRegions<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::HasParent<mlir::func::FuncOp>::Impl<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::ConditionallySpeculatable::Trait<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::AlwaysSpeculatableImplTrait<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::MemoryEffectOpInterface::Trait<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::MemRefsNormalizable<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::RegionBranchTerminatorOpInterface::Trait<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::ReturnLike<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::IsTerminator<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::detail::OpToOpPassAdaptor)

//===-------------------------------------------===//
Legalizing operation : 'func.func'(0x5647ea30edc0) {
  * Fold {
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::ConstantLike<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::DialectFoldInterface)
  } -> FAILURE : unable to fold
} -> FAILURE : no matched legalization pattern
//===-------------------------------------------===//

//===-------------------------------------------===//
Legalizing operation : 'torch.operator'(0x5647ea2e54d0) {
  %0 = "torch.operator"(%arg0) <{name = "onnx.ConstantOfShape"}> : (!torch.vtensor<[2],si64>) -> !torch.vtensor<[?,?],f32>

  * Fold {
  } -> FAILURE : unable to fold

  * Pattern : 'torch.operator -> ()' {
Trying to match ""
ImplicitTypeIDRegistry::lookupOrInsert(mlir::torch::Torch::detail::ConstantIntOpGenericAdaptorBase::Properties)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::OneResult<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::OneTypedResult<mlir::torch::Torch::IntType>::Impl<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::torch::Torch::OpTrait::AllowedInModuleInitializer<Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::InferTypeOpInterface::Trait<Empty>)
    ** Insert  : 'torch.constant.int'(0x5647ea315cc0)
    ** Insert  : 'torch.constant.int'(0x5647ea31c2d0)
    ** Insert  : 'torch.aten.select.int'(0x5647ea293a40)
    ** Insert  : 'torch.aten.item'(0x5647ea31c390)
    ** Insert  : 'torch.constant.int'(0x5647ea31c450)
    ** Insert  : 'torch.aten.select.int'(0x5647ea31c4e0)
    ** Insert  : 'torch.aten.item'(0x5647ea31c5e0)
    ** Insert  : 'torch.prim.ListConstruct'(0x5647ea2e45a0)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::OneTypedResult<mlir::torch::Torch::NoneType>::Impl<Empty>)
    ** Insert  : 'torch.constant.none'(0x5647ea31d000)
torch-mlir-opt: /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/IR/BuiltinAttributes.cpp:1349: static mlir::DenseElementsAttr mlir::DenseIntOrFPElementsAttr::getRaw(mlir::ShapedType, ArrayRef<char>): Assertion `type.hasStaticShape() && "type must have static shape"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: torch-mlir-opt --convert-torch-onnx-to-torch repro.mlir --debug
 #0 0x00005647e82847f7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13
 #1 0x00005647e8282940 llvm::sys::RunSignalHandlers() /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/lib/Support/Signals.cpp:106:18
 #2 0x00005647e8284e9a SignalHandler(int) /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #3 0x00007f0215cbc520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f0215d109fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007f0215cbc476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007f0215ca27f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007f0215ca271b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007f0215cb3e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00005647e8191220 mlir::DenseIntOrFPElementsAttr::getRaw(mlir::ShapedType, llvm::ArrayRef<char>) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/IR/BuiltinAttributes.cpp:1352:3
#10 0x00005647e8190318 mlir::DenseElementsAttr::get(mlir::ShapedType, llvm::ArrayRef<mlir::Attribute>) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/IR/BuiltinAttributes.cpp:982:10
#11 0x00005647e741bdb0 mlir::torch::onnx_c::populateDefaultDomainAtoF(mlir::torch::onnx_c::OnnxCustomOpConversionPattern&)::$_50::operator()(mlir::torch::onnx_c::OpBinder, mlir::ConversionPatternRewriter&) const /home/zjgar/code/torch-mlir/lib/Conversion/TorchOnnxToTorch/DefaultDomainAtoF.cpp:2811:15
#12 0x00005647e741bdb0 mlir::torch::onnx_c::populateDefaultDomainAtoF(mlir::torch::onnx_c::OnnxCustomOpConversionPattern&)::$_50::__invoke(mlir::torch::onnx_c::OpBinder, mlir::ConversionPatternRewriter&) /home/zjgar/code/torch-mlir/lib/Conversion/TorchOnnxToTorch/DefaultDomainAtoF.cpp:2767:7
#13 0x00005647e7480d5c llvm::LogicalResult::succeeded() const /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/Support/LogicalResult.h:40:45
#14 0x00005647e7480d5c llvm::succeeded(llvm::LogicalResult) /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/Support/LogicalResult.h:67:61
#15 0x00005647e7480d5c mlir::torch::onnx_c::OnnxCustomOpConversionPattern::matchAndRewrite(mlir::torch::Torch::OperatorOp, mlir::torch::Torch::OperatorOpAdaptor, mlir::ConversionPatternRewriter&) const /home/zjgar/code/torch-mlir/lib/Conversion/TorchOnnxToTorch/Patterns.cpp:35:9
#16 0x00005647e70177ff mlir::OpConversionPattern<mlir::torch::Torch::OperatorOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::Value>, mlir::ConversionPatternRewriter&) const /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/../mlir/include/mlir/Transforms/DialectConversion.h:545:3
#17 0x00005647e7d89ccb mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:1656:10
#18 0x00005647e7dbf187 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>)::$_2::operator()() const /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Rewrite/PatternApplicator.cpp:212:13
#19 0x00005647e7dbf187 void llvm::function_ref<void ()>::callback_fn<mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>)::$_2>(long) /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#20 0x00005647e7dbc07f mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Rewrite/PatternApplicator.cpp:233:9
#21 0x00005647e7d8abd6 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:0:0
#22 0x00005647e7d89d57 mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:0:0
#23 0x00005647e7d8adff llvm::LogicalResult::failed() const /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43
#24 0x00005647e7d8adff llvm::failed(llvm::LogicalResult) /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/Support/LogicalResult.h:71:58
#25 0x00005647e7d8adff mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:2484:9
#26 0x00005647e7d90b8b mlir::applyPartialConversion(llvm::ArrayRef<mlir::Operation*>, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:3285:22
#27 0x00005647e7d90b8b mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Transforms/Utils/DialectConversion.cpp:3291:10
#28 0x00005647e73fdc8c (anonymous namespace)::ConvertTorchOnnxToTorch::runOnOperation() /home/zjgar/code/torch-mlir/lib/Conversion/TorchOnnxToTorch/TorchOnnxToTorch.cpp:76:16
#29 0x00005647e7e0c154 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_7::operator()() const /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:0:17
#30 0x00005647e7e0c154 void llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_7>(long) /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#31 0x00005647e7e0c154 llvm::function_ref<void ()>::operator()() const /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#32 0x00005647e7e0c154 void mlir::MLIRContext::executeAction<mlir::PassExecutionAction, mlir::Pass&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, mlir::Pass&) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/include/mlir/IR/MLIRContext.h:275:7
#33 0x00005647e7e0c154 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:521:21
#34 0x00005647e7e0c7c1 llvm::LogicalResult::failed() const /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43
#35 0x00005647e7e0c7c1 llvm::failed(llvm::LogicalResult) /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/Support/LogicalResult.h:71:58
#36 0x00005647e7e0c7c1 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:593:9
#37 0x00005647e7e11d1b mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_15::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:818:5
#38 0x00005647e7e0dc0b llvm::LogicalResult::failed() const /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43
#39 0x00005647e7e0dc0b llvm::failed(llvm::LogicalResult) /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/Support/LogicalResult.h:71:58
#40 0x00005647e7e0dc0b llvm::LogicalResult mlir::failableParallelForEach<__gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_15&>(mlir::MLIRContext*, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_15&) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/include/mlir/IR/Threading.h:46:11
#41 0x00005647e7e0dc0b llvm::LogicalResult mlir::failableParallelForEach<std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>&, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_15&>(mlir::MLIRContext*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>&, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_15&) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/include/mlir/IR/Threading.h:92:10
#42 0x00005647e7e0dc0b mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:823:14
#43 0x00005647e7e0c2f2 mlir::detail::OpToOpPassAdaptor::runOnOperation(bool) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:0:5
#44 0x00005647e7e0c2f2 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_7::operator()() const /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:525:20
#45 0x00005647e7e0c2f2 void llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_7>(long) /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#46 0x00005647e7e0c2f2 llvm::function_ref<void ()>::operator()() const /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#47 0x00005647e7e0c2f2 void mlir::MLIRContext::executeAction<mlir::PassExecutionAction, mlir::Pass&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, mlir::Pass&) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/include/mlir/IR/MLIRContext.h:275:7
#48 0x00005647e7e0c2f2 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:521:21
#49 0x00005647e7e0eb23 llvm::LogicalResult::failed() const /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43
#50 0x00005647e7e0eb23 llvm::failed(llvm::LogicalResult) /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/Support/LogicalResult.h:71:58
#51 0x00005647e7e0eb23 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:593:9
#52 0x00005647e7e0eb23 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:904:10
#53 0x00005647e7e0eb23 mlir::PassManager::run(mlir::Operation*) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Pass/Pass.cpp:884:60
#54 0x00005647e6d056c7 llvm::LogicalResult::failed() const /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43
#55 0x00005647e6d056c7 llvm::failed(llvm::LogicalResult) /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/Support/LogicalResult.h:71:58
#56 0x00005647e6d056c7 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:413:7
#57 0x00005647e6d05334 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPoolInterface*) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:478:12
#58 0x00005647e6d05334 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_3::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:561:12
#59 0x00005647e6d05334 llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_3>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#60 0x00005647e8225249 llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /home/zjgar/code/torch-mlir/externals/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#61 0x00005647e8225249 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Support/ToolUtilities.cpp:27:12
#62 0x00005647e6cfecf1 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:564:10
#63 0x00005647e6cfefa3 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:605:14
#64 0x00005647e6cff282 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) /home/zjgar/code/torch-mlir/externals/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:621:10
#65 0x00005647e6cfd702 main /home/zjgar/code/torch-mlir/tools/torch-mlir-opt/torch-mlir-opt.cpp:49:33
#66 0x00007f0215ca3d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#67 0x00007f0215ca3e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#68 0x00005647e6cfd335 _start (/home/zjgar/code/torch-mlir/build/bin/torch-mlir-opt+0x17c335)
Aborted
zjgarvey commented 1 month ago

The primary issue is addressed in https://github.com/llvm/torch-mlir/pull/3713

The unsqueeze op in this IR will still fail to lower. I'd be happy to try and work out some support for this, since we should be able to infer that the dim is 1 from that result shape. However, the fact that we knew the result shape has a static 1 in dim 1 means that the original model was able to infer the unsqueeze dim; hence, the unsqueeze dim shouldn't be a graph input for this reproducer.

pdhirajkumarprasad commented 1 month ago

The crash is no more there so closing this issue. Ops lowering, we are going to track with different issue