Issue 177856
Summary mlir-opt crash on sparse_tensor.foreach over rank-0 tensor during --sparsification-and-bufferization pass
Labels new issue
Assignees
Reporter Subway2023
    # Description

mlir-opt version: 22.1.0-rc1

The crash is an assertion failure in mlir::sparse_tensor::LoopEmitter::getValPosits (std::vector::back() on an empty container), triggered during ForeachRewriter lowering. This indicates that the current sparse_tensor.foreach lowering assumes at least one iteration dimension and does not handle scalar tensors.

# Reproduce
location: If the **sparse_tensor.foreach** is commented out, the crash no longer occurs.

```
module {
  func.func @main() {
    %0 = gpu.dynamic_shared_memory : memref<?xi8, #gpu.address_space<workgroup>>
 %1 = "tosa.const"() <{values = dense<0> : tensor<i32>}> : () -> tensor<i32>
    sparse_tensor.foreach in %1 : tensor<i32> do {
 ^bb0(%arg0: i32):
      "tosa.const"() <{values = dense<0> : tensor<i32>}> : () -> tensor<i32>
    }
    return
  }
}
```
```
mlir-opt --sparsification-and-bufferization test.mlir
```
```
/usr/include/c++/13/bits/stl_vector.h:1247: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::back() const [with _Tp = std::vector<std::unique_ptr<mlir::sparse_tensor::SparseIterator> >; _Alloc = std::allocator<std::vector<std::unique_ptr<mlir::sparse_tensor::SparseIterator> > >; const_reference = const std::vector<std::unique_ptr<mlir::sparse_tensor::SparseIterator> >&]: Assertion '!this->empty()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.      Program arguments: /mnt/sdd1/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt --sparsification-and-bufferization /mnt/sdd1/mlir/data/genProgram_1229/290244_8149/mlir_steps/290244_8149_3.mlir
 #0 0x000060d07c94ae32 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x252fe32)
 #1 0x000060d07c9475af llvm::sys::RunSignalHandlers() (/mnt/sdd1/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x252c5af)
 #2 0x000060d07c9476fc SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007fd2fea45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #4 0x00007fd2fea9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007fd2fea9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007fd2fea9eb2c pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007fd2fea4527e raise ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007fd2fea288ff abort ./stdlib/abort.c:81:7
 #9 0x00007fd2feedf90d (/lib/x86_64-linux-gnu/libstdc++.so.6+0xdf90d)
#10 0x000060d07d5a7a7f mlir::sparse_tensor::LoopEmitter::getValPosits(unsigned int) const (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x318ca7f)
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to