Issue 74237
Summary [mlir] --tosa-infer-shapes crashed with assertion failure "invalid index for shaped type".
Labels mlir
Assignees
Reporter anonymousMCS
    git version: e9c6f3f5e7e23b23de4eeaa182ebfcb7d2188495

system: ```Ubuntu 20.04.6 LTS (Focal Fossa)```

reproduced with: ```mlir-opt --tosa-infer-shapes a.mlir```

a.mlir:
```
func.func nested @func2() {
  %c16 = arith.constant 16 : index
  %c29 = arith.constant 29 : index
  %13 = tensor.empty(%c16, %c29) : tensor<?x?xi1>
  %26 = tosa.reduce_prod %13 {axis = 0 : i32} : (tensor<?x?xi1>) -> tensor<1x?xi1>
  %44 = tosa.logical_not %26 : (tensor<1x?xi1>) -> tensor<1x?xi1>
  %73 = tensor.empty() : tensor<i32>
  %138 = tosa.transpose %44, %73 : (tensor<1x?xi1>, tensor<i32>) -> tensor<1x?xi1>
 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 --tosa-infer-shapes a.mlir
 #0 0x000056132fa89e8f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/bin/llvm-project/build/bin/mlir-opt+0x1640e8f)
 #1 0x000056132fa86ee4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007ff4dea84420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007ff4de56f00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007ff4de54e859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007ff4de54e729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007ff4de55ffd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x000056133550108a mlir::ShapeAdaptor::getDimSize(int) const (/data/bin/llvm-project/build/bin/mlir-opt+0x70b808a)
 #8 0x00005613319056d4 mlir::tosa::TransposeOp::inferReturnTypeComponents(mlir::MLIRContext*, std::optional<mlir::Location>, mlir::tosa::TransposeOpAdaptor, llvm::SmallVectorImpl<mlir::ShapedTypeComponents>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x34bc6d4)
 #9 0x0000561331905c89 mlir::detail::InferShapedTypeOpInterfaceInterfaceTraits::Model<mlir::tosa::TransposeOp>::inferReturnTypeComponents(mlir::MLIRContext*, std::optional<mlir::Location>, mlir::ValueShapeRange, mlir::DictionaryAttr, mlir::OpaqueProperties, mlir::RegionRange, llvm::SmallVectorImpl<mlir::ShapedTypeComponents>&) (/data/bin/llvm-project/build/bin/mlir-opt+0x34bcc89)
#10 0x000056133196f624 (anonymous namespace)::propagateShapesInRegion(mlir::Region&) TosaInferShapes.cpp:0:0
#11 0x00005613319715fa (anonymous namespace)::TosaInferShapes::runOnOperation() TosaInferShapes.cpp:0:0
#12 0x00005613326fd85e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x42b485e)
#13 0x00005613326fdd3a 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+0x42b4d3a)
#14 0x00005613326fe73c mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::'lambda'(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&)::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0
#15 0x00005613326fce95 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/data/bin/llvm-project/build/bin/mlir-opt+0x42b3e95)
#16 0x00005613326fd5fa mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x42b45fa)
#17 0x00005613326fdd3a 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+0x42b4d3a)
#18 0x00005613326fe564 mlir::PassManager::run(mlir::Operation*) (/data/bin/llvm-project/build/bin/mlir-opt+0x42b5564)
#19 0x00005613326ef2d3 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#20 0x00005613326f07a4 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
#21 0x00005613326f0954 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
#22 0x00005613327efc44 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+0x43a6c44)
#23 0x00005613326e91b7 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+0x42a01b7)
#24 0x00005613326f0aa1 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x42a7aa1)
#25 0x00005613326f0f06 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x42a7f06)
#26 0x000056132f9c150b main (/data/bin/llvm-project/build/bin/mlir-opt+0x157850b)
#27 0x00007ff4de550083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#28 0x000056132fa5a1ee _start (/data/bin/llvm-project/build/bin/mlir-opt+0x16111ee)
Aborted (core dumped)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to