<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/70633>70633</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir][tosa] --canonicalize crashed with assertion failure "invalid index for shaped type"
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
anonymousMCS
</td>
</tr>
</table>
<pre>
git version: dbeaee61af9985a8dcdbe363d40530792b7e7904
system: ```Ubuntu 20.04.6 LTS (Focal Fossa)```
reproduced with: ```mlir-opt --canonicalize a.mlir```
a.mlir:
```
func.func nested @func1() {
%c655216653_i32 = arith.constant 655216653 : i32
%13 = tensor.empty() : tensor<21x8x26xf32>
%splat = tensor.splat %c655216653_i32 : tensor<15x8x26xi32>
// %c655216653_i32 out of bounds
%67 = tosa.transpose %13, %splat : (tensor<21x8x26xf32>, tensor<15x8x26xi32>) -> tensor<21x8x26xf32>
%99 = math.floor %67 : tensor<21x8x26xf32>
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 --canonicalize a.mlir
#0 0x000055ad60655bef llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/bin/llvm-project/build/bin/mlir-opt+0x15d3bef)
#1 0x000055ad60652c84 SignalHandler(int) Signals.cpp:0:0
#2 0x00007f29f6af2420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007f29f65dd00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007f29f65bc859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00007f29f65bc729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#6 0x00007f29f65cdfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#7 0x000055ad60a0c71a (/data/bin/llvm-project/build/bin/mlir-opt+0x198a71a)
#8 0x000055ad6243b1bf TransposeIsReshape::matchAndRewrite(mlir::tosa::TransposeOp, mlir::PatternRewriter&) const (/data/bin/llvm-project/build/bin/mlir-opt+0x33b91bf)
#9 0x000055ad62432d68 mlir::detail::OpOrInterfaceRewritePatternBase<mlir::tosa::TransposeOp>::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data/bin/llvm-project/build/bin/mlir-opt+0x33b0d68)
#10 0x000055ad65ea53f8 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) (/data/bin/llvm-project/build/bin/mlir-opt+0x6e233f8)
#11 0x000055ad63265fcc (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#12 0x000055ad6326a43b mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data/bin/llvm-project/build/bin/mlir-opt+0x41e843b)
#13 0x000055ad631d01fa (anonymous namespace)::Canonicalizer::runOnOperation() Canonicalizer.cpp:0:0
#14 0x000055ad631b114e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin/llvm-project/build/bin/mlir-opt+0x412f14e)
#15 0x000055ad631b162a 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+0x412f62a)
#16 0x000055ad631b1e54 mlir::PassManager::run(mlir::Operation*) (/data/bin/llvm-project/build/bin/mlir-opt+0x412fe54)
#17 0x000055ad631a271b performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#18 0x000055ad631a3bd4 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
#19 0x000055ad631a3d84 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
#20 0x000055ad632a0794 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+0x421e794)
#21 0x000055ad6319d057 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+0x411b057)
#22 0x000055ad631a40ab mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/bin/llvm-project/build/bin/mlir-opt+0x41220ab)
#23 0x000055ad6058dbcb main (/data/bin/llvm-project/build/bin/mlir-opt+0x150bbcb)
#24 0x00007f29f65be083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#25 0x000055ad606263fe _start (/data/bin/llvm-project/build/bin/mlir-opt+0x15a43fe)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWV1v27wV_jXKDRGDIvV5kQvHibcADRIkGXZpHIlHNleZ1Eiqb9JfP1CSHclx3qR10b1b0bq2RD7nOZ88JMFauVaIF0F8GcRXZ9C6jTYXoLR62erW3i4ezwotXi7W0pFvaKzUKuBzIgoExCSEKs-zGDJRigJ5wkVEY07TnBUppjmNAnoV0Hn_aV-sw62fHSS0__uPolWuJYzOaDRLyJenRxKwbKlLqMlSWwsBy_eDx1gGG6NFW6Igf0i3mYBua2nOdePI-XnpFZEl1PI7Epj5N0fhhld8-HkwpmpVOfMfRKF1KEgQUf8zDFgWsJwE6WU_kJCAxWUSxyxMkpivJGck4FcEjHSbWamVdaAc2Q8gnrfkbDQ75N0Mh8pqM8Nt4152Uvh8eBzwBQufs2eWPFecBfx6NN82NbgxxPDgCK8RXBj3cPIAbhmw5ZG5unVEV6TQrRJ2JDxJe8nawswZULbRFnutArYY05t7P7-nDVu8y4zl5Dzg158wRJ53XLbgNrOq1trsCX5oRoOuNYoMsZBeHQ2K_tMZKPG9uNkFYq_uUoCDgC0LqQK2rOtv2_PG6H9h6fzDVtYiYEundW0DtuzCkS2lKutW4OuDm4eALS9bWTupnl4avFEOTQUl2tlmJlUZ8HmYx11YKZdEK0d2gc3njxtoUPhZ_e81uiu5fZTfMWBZq7pCIPw8b-UuWD3O3Fo0TmrlE0yKZxLwBVmjewD1dReZLAlYQgLGpPoGtfQgAp9JpQ2xnVDivFTGApaSCmSNYtab6P7L9fzxmti22EpHgBTt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