Skip to content

[mlir] --convert-amdgpu-to-rocdl crashed with assertion failure "invalid index for shaped type" #67761

@ghost

Description

git version: 8c12707

system: Ubuntu 20.04.6 LTS (Focal Fossa)

reproduced with: mlir-opt --convert-amdgpu-to-rocdl a.mlir

a.mlir:

func.func nested @func2() {
  %c0 = arith.constant 0 : index
  %c22 = arith.constant 22 : index
  %22 = tensor.empty(%c22) : tensor<?x10xi32>
  %64 = tosa.reduce_min %22 {axis = 0 : i32} : (tensor<?x10xi32>) -> tensor<1x10xi32>
  %90 = tosa.slice %64 {size = array<i64>, start = array<i64>} : (tensor<1x10xi32>) -> tensor<i32>
  vector.warp_execute_on_lane_0(%c0)[32] {
    %155 = tosa.reverse %90 {axis = 0 : i32} : (tensor<i32>) -> tensor<1x10xi32>
  }
  return
}

trace:

mlir-opt: /data/bin/llvm-project/build/tools/mlir/include/mlir/IR/BuiltinTypeInterfaces.h.inc:195: int64_t mlir::ShapedType::getDimSize(unsigned int) const: Assertion `idx < getRank() && "invalid index for shaped type"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /data/bin/llvm-project/build/bin/mlir-opt --convert-amdgpu-to-rocdl a.mlir
 #0 0x000055bfe0860d4f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/bin/llvm-project/build/bin/mlir-opt+0x157cd4f)
 #1 0x000055bfe085dde4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fec00a8c420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007fec0057700b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007fec00556859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007fec00556729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007fec00567fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x000055bfe2561570 auto llvm::dyn_cast_if_present<mlir::DenseElementsAttr, mlir::Attribute>(mlir::Attribute const&) (/data/bin/llvm-project/build/bin/mlir-opt+0x327d570)
 #8 0x000055bfe25675d3 mlir::tosa::ReverseOp::fold(mlir::tosa::ReverseOpGenericAdaptor<llvm::ArrayRef<mlir::Attribute>>) (/data/bin/llvm-project/build/bin/mlir-opt+0x32835d3)
 #9 0x000055bfe24d73e9 mlir::LogicalResult llvm::detail::UniqueFunctionBase<mlir::LogicalResult, mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&>::CallImpl<mlir::Op<mlir::tosa::ReverseOp, mlir::OpTrait::ZeroRegions, mlir::OpTrait::OneResult, mlir::OpTrait::OneTypedResult<mlir::TensorType>::Impl, mlir::OpTrait::ZeroSuccessors, mlir::OpTrait::OneOperand, mlir::OpTrait::OpInvariants, mlir::BytecodeOpInterface::Trait, mlir::InferShapedTypeOpInterface::Trait, mlir::ConditionallySpeculatable::Trait, mlir::OpTrait::AlwaysSpeculatableImplTrait, mlir::MemoryEffectOpInterface::Trait, mlir::tosa::TosaOp::Trait>::getFoldHookFn()::'lambda'(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) const>(void*, mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x31f33e9)
#10 0x000055bfe254e8a6 mlir::RegisteredOperationName::Model<mlir::tosa::ReverseOp>::foldHook(mlir::Operation*, llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x326a8a6)
#11 0x000055bfe349c3e2 mlir::Operation::fold(llvm::ArrayRef<mlir::Attribute>, llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x41b83e2)
#12 0x000055bfe349c728 mlir::Operation::fold(llvm::SmallVectorImpl<mlir::OpFoldResult>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x41b8728)
#13 0x000055bfe33cec6a mlir::OpBuilder::tryFold(mlir::Operation*, llvm::SmallVectorImpl<mlir::Value>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x40eac6a)
#14 0x000055bfe333bbcb (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#15 0x000055bfe333c687 (anonymous namespace)::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>, llvm::function_ref<void (mlir::Diagnostic&)>) DialectConversion.cpp:0:0
#16 0x000055bfe333eaf4 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, llvm::DenseSet<mlir::Operation*, llvm::DenseMapInfo<mlir::Operation*, void>>*) (/data/bin/llvm-project/build/bin/mlir-opt+0x405aaf4)
#17 0x000055bfe2827b25 (anonymous namespace)::ConvertAMDGPUToROCDLPass::runOnOperation() AMDGPUToROCDL.cpp:0:0
#18 0x000055bfe3293e8e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x3fafe8e)
#19 0x000055bfe329436a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/bin/llvm-project/build/bin/mlir-opt+0x3fb036a)
#20 0x000055bfe3294b94 mlir::PassManager::run(mlir::Operation*) (/data/bin/llvm-project/build/bin/mlir-opt+0x3fb0b94)
#21 0x000055bfe328546b performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#22 0x000055bfe3286924 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) MlirOptMain.cpp:0:0
#23 0x000055bfe3286ad4 mlir::LogicalResult llvm::function_ref<mlir::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&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#24 0x000055bfe3384f84 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/data/bin/llvm-project/build/bin/mlir-opt+0x40a0f84)
#25 0x000055bfe327fef7 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/bin/llvm-project/build/bin/mlir-opt+0x3f9bef7)
#26 0x000055bfe3286dfb mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x3fa2dfb)
#27 0x000055bfe0799feb main (/data/bin/llvm-project/build/bin/mlir-opt+0x14b5feb)
#28 0x00007fec00558083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#29 0x000055bfe0831a0e _start (/data/bin/llvm-project/build/bin/mlir-opt+0x154da0e)
Aborted (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions