Issue 130008
Summary [MLIR] Assertion `parentPos.size() == 1 && "Dense level can not be non-unique."' failed.
Labels mlir
Assignees
Reporter RiRi114
    Test on commit: 0f9720a6

steps to reproduce:
`mlir-opt  temp.mlir       --lower-sparse-ops-to-foreach     --lower-sparse-foreach-to-scf `

test case:
```mlir
#COO = #sparse_tensor.encoding<{
map = (i, j) -> (
i : compressed(nonunique),
j : dense
)
}>
func.func @sparse_example(%input : tensor<10x10xf32, #COO>) -> tensor<10x10xf32> {
  %0 = sparse_tensor.convert %input : tensor<10x10xf32, #COO> to tensor<10x10xf32>
  
  %i = arith.constant 0 : index
  %c1 = arith.constant 1 : index
  %l = sparse_tensor.extract_iteration_space %input lvls = 0 : tensor<10x10xf32, #COO> -> !sparse_tensor.iter_space<#COO, lvls = 0>
  
  %r1 = sparse_tensor.iterate %it1 in %l iter_args(%outer = %i): !sparse_tensor.iter_space<#COO, lvls = 0 to 1> -> index {
    %l2 = sparse_tensor.extract_iteration_space %input at %it1 lvls = 1 : tensor<10x10xf32, #COO>, 
                                                 !sparse_tensor.iterator<#COO, lvls = 0 to 1> -> !sparse_tensor.iter_space<#COO, lvls = 1>
    %r2 = sparse_tensor.iterate %it2 in %l2 iter_args(%inner = %outer): !sparse_tensor.iter_space<#COO, lvls = 1 to 2> -> index {
      %k = arith.addi %inner, %c1 : index
      sparse_tensor.yield %k : index
    }
    sparse_tensor.yield %r2 : index
  }
  
  return %0 : tensor<10x10xf32>
}
```

crash trace:
```
mlir-opt: /home/fuzzing/llvm-project/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorIterator.cpp:99: virtual ValuePair (anonymous namespace)::DenseLevel::peekRangeAt(mlir::OpBuilder &, mlir::Location, mlir::ValueRange, mlir::ValueRange, mlir::Value) const: Assertion `parentPos.size() == 1 && "Dense level can not be non-unique."' 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/fuzzing/llvm-project/build/bin/mlir-opt temp.mlir --lower-sparse-ops-to-foreach --lower-sparse-foreach-to-scf
 #0 0x000000000113ce77 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x113ce77)
 #1 0x000000000113aa0e llvm::sys::RunSignalHandlers() (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x113aa0e)
 #2 0x000000000113d855 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007b113ad95520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007b113ade99fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007b113ad95476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007b113ad7b7f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007b113ad7b71b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007b113ad8ce96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00000000032beae5 (anonymous namespace)::DenseLevel::peekRangeAt(mlir::OpBuilder&, mlir::Location, mlir::ValueRange, mlir::ValueRange, mlir::Value) const SparseTensorIterator.cpp:0:0
#10 0x00000000032c05cf (anonymous namespace)::TrivialIterator::genInitImpl(mlir::OpBuilder&, mlir::Location, mlir::sparse_tensor::SparseIterator const*) SparseTensorIterator.cpp:0:0
#11 0x00000000032ad779 mlir::sparse_tensor::LoopEmitter::prepareLoopOverTensorAtLvl(mlir::OpBuilder&, mlir::Location, unsigned int, unsigned long) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x32ad779)
#12 0x00000000032ad4d7 mlir::sparse_tensor::LoopEmitter::enterNewLoopSeq(mlir::OpBuilder&, mlir::Location, llvm::ArrayRef<unsigned int>) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x32ad4d7)
#13 0x00000000032866d6 (anonymous namespace)::ForeachRewriter::matchAndRewrite(mlir::sparse_tensor::ForeachOp, mlir::PatternRewriter&) const SparseTensorRewriting.cpp:0:0
#14 0x0000000006a1e891 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) PatternApplicator.cpp:0:0
#15 0x0000000006a1b28f 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/fuzzing/llvm-project/build/bin/mlir-opt+0x6a1b28f)
#16 0x00000000042c2fc6 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#17 0x00000000042bf60b mlir::applyPatternsGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x42bf60b)
#18 0x00000000032680c5 (anonymous namespace)::LowerForeachToSCFPass::runOnOperation() SparseTensorPasses.cpp:0:0
#19 0x00000000042452f7 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x42452f7)
#20 0x0000000004245b61 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x4245b61)
#21 0x000000000424aede auto void mlir::parallelForEach<__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&&)::'lambda'(__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> > >&&)::operator()<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> > >&&) const Pass.cpp:0:0
#22 0x000000000424735b mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x424735b)
#23 0x0000000004245450 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x4245450)
#24 0x0000000004245b61 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x4245b61)
#25 0x000000000424825b mlir::PassManager::run(mlir::Operation*) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x424825b)
#26 0x00000000042408af performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#27 0x0000000004240503 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&) MlirOptMain.cpp:0:0
#28 0x00000000042ec4e8 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/fuzzing/llvm-project/build/bin/mlir-opt+0x42ec4e8)
#29 0x000000000423a151 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer> >, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x423a151)
#30 0x000000000423a403 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x423a403)
#31 0x000000000423a612 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x423a612)
#32 0x000000000111a8d7 main (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x111a8d7)
#33 0x00007b113ad7cd90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#34 0x00007b113ad7ce40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#35 0x000000000111a435 _start (/home/fuzzing/llvm-project/build/bin/mlir-opt+0x111a435)
Aborted (core dumped)
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to