<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61530>61530</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR]`-sparse-compiler` triggers Assertion Failure `t < numTensors && i < numLoops && lvl < lvlToLoop[t].size() && isValidDLT(dlt)'
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
BealZephyr
</td>
</tr>
</table>
<pre>
Test on commit: https://github.com/llvm/llvm-project/commit/8d2885c2ef98b81927c1f816691ec4e77cfc7f3f
steps to reproduce:
```
mlir-opt -linalg-fold-unit-extent-dims=fold-one-trip-loops-only -sparse-compiler=enable-amx=true test.mlir
```
test case:
```
#map = affine_map<(d0, d1) -> (d0, d1)>
#map1 = affine_map<(d0, d1) -> (d1)>
module {
func.func @main(%8:tensor<1x77xi1>,%arg9: tensor<1x77xi1>) -> tensor<1x77xi1> {
%9 = tensor.empty() : tensor<1x77xi1>
%10 = linalg.generic {indexing_maps = [#map, #map, #map], iterator_types = ["parallel", "parallel"]} ins(%8, %arg9 : tensor<1x77xi1>, tensor<1x77xi1>) outs(%9 : tensor<1x77xi1>) {
^bb0(%in: i1, %in_0: i1, %out: i1):
%11 = arith.addi %in, %in_0 : i1
linalg.yield %11 : i1
} -> tensor<1x77xi1>
return %10 : tensor<1x77xi1>
}
}
```
crash trace:
```
mlir-opt: /home/ty/llvm-project/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h:430: void mlir::sparse_tensor::Merger::setLevelAndType(mlir::sparse_tensor::TensorId, mlir::sparse_tensor::LoopId, mlir::sparse_tensor::Level, mlir::sparse_tensor::DimLevelType): Assertion `t < numTensors && i < numLoops && lvl < lvlToLoop[t].size() && isValidDLT(dlt)' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /home/ty/llvm-project/build/bin/mlir-opt -linalg-fold-unit-extent-dims=fold-one-trip-loops-only -sparse-compiler=enable-amx=true test.mlir
#0 0x00005625f8bc94ea llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/ty/llvm-project/build/bin/mlir-opt+0x2244ea)
#1 0x00005625f8bc677c SignalHandler(int) Signals.cpp:0:0
#2 0x00007f15ba937980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#3 0x00007f15b9a2fe87 raise /build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#4 0x00007f15b9a317f1 abort /build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
#5 0x00007f15b9a213fa __assert_fail_base /build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
#6 0x00007f15b9a21472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
#7 0x00005625f982ab4e (/home/ty/llvm-project/build/bin/mlir-opt+0xe85b4e)
#8 0x00005625f982b731 findAffine(mlir::sparse_tensor::Merger&, unsigned int, unsigned long, mlir::AffineExpr, mlir::sparse_tensor::DimLevelType, unsigned int&, bool) Sparsification.cpp:0:0
#9 0x00005625f9834093 (anonymous namespace)::GenericOpSparsifier::matchAndRewrite(mlir::linalg::GenericOp, mlir::PatternRewriter&) const Sparsification.cpp:0:0
#10 0x00005625f90deb97 mlir::detail::OpOrInterfaceRewritePatternBase<mlir::linalg::GenericOp>::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/home/ty/llvm-project/build/bin/mlir-opt+0x739b97)
#11 0x00005625fa87ca49 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&)>) (/home/ty/llvm-project/build/bin/mlir-opt+0x1ed7a49)
#12 0x00005625fa522a2d (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#13 0x00005625fa525d3a mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig) (/home/ty/llvm-project/build/bin/mlir-opt+0x1b80d3a)
#14 0x00005625f9802ea9 (anonymous namespace)::SparsificationPass::runOnOperation() SparseTensorPasses.cpp:0:0
#15 0x00005625fa491fe9 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/ty/llvm-project/build/bin/mlir-opt+0x1aecfe9)
#16 0x00005625fa49230a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/home/ty/llvm-project/build/bin/mlir-opt+0x1aed30a)
#17 0x00005625fa492cd4 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (mlir::OpPassManager&, mlir::Operation*)>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::'lambda'(mlir::OpPassManager&, mlir::Operation*)>(long, mlir::OpPassManager&, mlir::Operation*) Pass.cpp:0:0
#18 0x00005625fa648b57 mlir::sparse_tensor::SparsificationAndBufferizationPass::runOnOperation() (/home/ty/llvm-project/build/bin/mlir-opt+0x1ca3b57)
#19 0x00005625fa491fe9 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/ty/llvm-project/build/bin/mlir-opt+0x1aecfe9)
#20 0x00005625fa492e43 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (.constprop.495) Pass.cpp:0:0
#21 0x00005625fa49352d mlir::PassManager::run(mlir::Operation*) (/home/ty/llvm-project/build/bin/mlir-opt+0x1aee52d)
#22 0x00005625fa486453 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#23 0x00005625fa486b89 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
#24 0x00005625fa486eb1 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
#25 0x00005625fa551ce0 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) (/home/ty/llvm-project/build/bin/mlir-opt+0x1bacce0)
#26 0x00005625fa483b93 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/home/ty/llvm-project/build/bin/mlir-opt+0x1adeb93)
#27 0x00005625fa4872a6 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&, bool) (/home/ty/llvm-project/build/bin/mlir-opt+0x1ae22a6)
#28 0x00005625f8b95650 main (/home/ty/llvm-project/build/bin/mlir-opt+0x1f0650)
#29 0x00007f15b9a12c87 __libc_start_main /build/glibc-CVJwZb/glibc-2.27/csu/../csu/libc-start.c:344:0
#30 0x00005625f8ba84aa _start (/home/ty/llvm-project/build/bin/mlir-opt+0x2034aa)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsOttu2zjaT8PcEDYkUseLXLh2_P9dNEjQZGeBuTEo8ZPNHYrSklQaz9MvSMmO5cSJOy52ugegdUTqO59pmhkj1grgGsWfULy4Yp3dNPr6EzD5K7Sbrb4qGr69fgRjcaNw2dS1sIjO8Mba1iA6Q2SJyHIt7KYrpmVTI7KU8mn3Z9Lq5u9QWkSWAypZZpxkWVwSqPKsyMKcpGVYZWGS5CGUEaRpWZVpRSsULFAw6z-NhdZg22ANrW54V4Jj3QMkwfDPL2sp9KRpLZ5IoZhcT6pG8kmnhJ3AswVlJ1zUBtGF328UTKwW7UQ2TWsmjZJbPDEt0wYmZVO3QoJGdAGKFRImrH5GdGF1B9iCsVPH600h-k8Hg0tmTsqKCK1ZixFdYFZVQsGqZi2ic0QyHiAyxzxEJMcTRG_weA_Rm0MS4fk0Rth1wzsJGKWf-jXGVafKqfvAKApqJhQiGSJxhujMgjKNRnQePqfpswgdFTJHJGZ6nbuQeBNgYP3GuwO2iMS5V6EHm0Ld2q3n7LbfpjwIjB1yGHjs3uPTNSjQonT0heLwLNTaGcV4GBfn3mbONq-e4oVbCAua2Uav7LaFAzTSMs2kBIkI6ZFGO_ECpQsslNnZzIN485zUgsxPma3p7EDoHez80HcYo_imKIIeSyiHJcJBCqFWwWij6exune8DFOOdRYeQ0sJupoxz0dM4IIYH7AO8wf5bAZLviYyBnIVOBcQLlAbbabX37HsBgNLFkAn7h3GSlZqZDbaafVwzHCdElpumBkSWLgKPi5jPeLIUqpQdh5eNhWCyh3jwxeOxl5cs_2qFN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