Issue 177845
Summary mlir-opt crash in --convert-index-to-llvm on dynamic-shaped tensor.expand_shape
Labels new issue
Assignees
Reporter Subway2023
    # Description

mlir-opt version: 22.1.0-rc1

Running mlir-opt with the --convert-index-to-llvm pass on an MLIR module containing tensor.expand_shape that produces a dynamic-shaped tensor triggers an assertion failure in mlir::ShapedType::getNumElements(). The crash occurs because the pass attempts to get the number of elements of a dynamically shaped tensor, which is not allowed

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

```
module {
  func.func @main() {
    %0 = arm_sme.streaming_vl<half>
    %1 = "tosa.const"() <{value = dense<1> : tensor<i32>}> {values = dense<1> : tensor<i32>} : () -> tensor<i32>
    %2 = tensor.expand_shape %1 [] output_shape [%0] : tensor<i32> into tensor<?xi32>
    return
  }
}
```
```
mlir-opt --convert-index-to-llvm test.mlir
```
```
mlir-opt: /mnt/sdd1/mlir/tool/llvm-project-llvmorg-22.1.0-rc1/build/tools/mlir/include/mlir/IR/BuiltinTypeInterfaces.h.inc:494: int64_t mlir::ShapedType::getNumElements() const: Assertion `hasStaticShape() && "cannot get element count of dynamic shaped type"' 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/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt --convert-index-to-llvm /mnt/sdd1/sbw/mlir/data/genProgram_1229/290256_7761/mlir_steps/290256_7761_4.mlir
 #0 0x00005e7dc6730e32 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x252fe32)
 #1 0x00005e7dc672d5af llvm::sys::RunSignalHandlers() (/mnt/sdd1/sbw/mlir/tool/llvmorg-22.1.0-install/bin/mlir-opt+0x252c5af)
 #2 0x00005e7dc672d6fc SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007bd187045330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #4 0x00007bd18709eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007bd18709eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007bd18709eb2c pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007bd18704527e raise ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007bd1870288ff abort ./stdlib/abort.c:81:7
 #9 0x00007bd18702881b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007bd18703b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to