Issue 148354
Summary [MLIR] Inconsistent output when executing MLIR program with and without `-convert-math-to-spirv`
Labels mlir
Assignees
Reporter sweead
    test commit: [f2e244f](https://github.com/llvm/llvm-project/commit/f2e244f443c99f814216bef37a82f1b8d3e5975d)

## Description:

I am experiencing an inconsistent result when executing the same MLIR program with and without the -convert-math-to-spirv.


## Steps to Reproduce:

### Minimal MLIR program (test.mlir):

```
module {
 func.func private @printMemrefF32(tensor<*xf32>)
  func.func @main() {
 %0 = "tosa.const"() <{values = dense<7.077000e+01> : tensor<2x3x4x2x3xf32>}> : () -> tensor<2x3x4x2x3xf32>
    %1 = tosa.tanh %0 : (tensor<2x3x4x2x3xf32>) -> tensor<2x3x4x2x3xf32>
    %cast = tensor.cast %1 : tensor<2x3x4x2x3xf32> to tensor<*xf32>
    call @printMemrefF32(%cast) : (tensor<*xf32>) -> ()
    return
  }
}
```
### 1. Without -convert-math-to-spirv:

#### Command:
```
/home/workdir/llvm-project/build/bin/mlir-opt test.mlir --pass-pipeline="builtin.module(func.func(tosa-to-linalg))"| \
/home/workdir/llvm-project/build/bin/mlir-opt    -convert-spirv-to-llvm -sparsifier="vl=8" | \
/home/workdir/llvm-project/build/bin/mlir-runner -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project/build/lib/libmlir_runner_utils.so
```
#### Output:
```
[[[[[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]]], [[[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]]], [[[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]]]], [[[[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]]], [[[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]]], [[[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]], [[1, 1, 1], [1, 1, 1]]]]]
```

```
/home/workdir/llvm-project/build/bin/mlir-opt test.mlir --pass-pipeline="builtin.module(func.func(tosa-to-linalg))"| \
/home/workdir/llvm-project/build/bin/mlir-opt  -convert-math-to-spirv -convert-spirv-to-llvm  -sparsifier="vl=8" | \
/home/workdir/llvm-project/build/bin/mlir-runner -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project/build/lib/libmlir_runner_utils.so
```
#### Output:
```
[[[[[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]]], [[[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]]], [[[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]]]], [[[[ -nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]]], [[[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]]], [[[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]], [[-nan, -nan, -nan], [-nan, -nan, -nan]]]]]
```
I'm not sure if there is any bug in my program or if the wrong usage of the above passes caused this result.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to