Issue |
139491
|
Summary |
[MLIR] Inconsistent output when executing MLIR program with and without `-convert-math-to-spirv`
|
Labels |
mlir
|
Assignees |
|
Reporter |
Lambor24
|
My git version is [5971b41](https://github.com/llvm/llvm-project/commit/5971b419199942fd8023070f81f37499d4d4738b).
## Description:
I am experiencing an inconsistent result when executing the same MLIR program with and without the `-convert-math-to-spirv`.
## Steps to Reproduce:
### 1. **MLIR Program (test.mlir)**:
test.mlir:
```
module {
func.func private @printMemrefF32(tensor<*xf32>)
func.func @main() {
%0 = "tosa.const"() <{values = dense<-8.227000e+01> : tensor<1x4x4x2xf32>}> : () -> tensor<1x4x4x2xf32>
%1 = "tosa.const"() <{values = dense<-1.486000e+02> : tensor<2x2x2x1xf32>}> : () -> tensor<2x2x2x1xf32>
%2 = "tosa.const"() <{values = dense<-1.022500e+02> : tensor<2xf32>}> : () -> tensor<2xf32>
%3 = "tosa.const"() <{values = dense<0.000000e+00> : tensor<1xf32>}> : () -> tensor<1xf32>
%4 = "tosa.const"() <{values = dense<0.000000e+00> : tensor<1xf32>}> : () -> tensor<1xf32>
%5 = tosa.depthwise_conv2d %0, %1, %2, %3, %4 {acc_type = f32, dilation = array<i64: 1, 1>, pad = array<i64: 0, 0, 0, 0>, stride = array<i64: 2, 2>} : (tensor<1x4x4x2xf32>, tensor<2x2x2x1xf32>, tensor<2xf32>, tensor<1xf32>, tensor<1xf32>) -> tensor<1x2x2x2xf32>
%6 = tosa.tanh %5 : (tensor<1x2x2x2xf32>) -> tensor<1x2x2x2xf32>
%cast = tensor.cast %6 : tensor<1x2x2x2xf32> to tensor<*xf32>
call @printMemrefF32(%cast) : (tensor<*xf32>) -> ()
return
}
}
```
### 2. **Command to Run Without `-convert-math-to-spirv`:**
```
/path/llvm-project/build/bin/mlir-opt test.mlir -pass-pipeline='builtin.module(func.func(tosa-to-linalg-named,tosa-to-linalg))' | \
/path/llvm-project/build/bin/mlir-opt -tosa-to-arith -one-shot-bufferize="bufferize-function-boundaries" -convert-linalg-to-affine-loops -lower-affine -convert-scf-to-cf -expand-strided-metadata -convert-math-to-libm -convert-cf-to-llvm -convert-arith-to-llvm -finalize-memref-to-llvm -convert-func-to-llvm -convert-spirv-to-llvm -reconcile-unrealized-casts | \
/path/llvm-project/build/bin/mlir-runner -e main -entry-point-result=void \
-shared-libs=/path/llvm-project/build/lib/libmlir_runner_utils.so \
-shared-libs=/path/llvm-project/build/lib/libmlir_c_runner_utils.so \
-shared-libs=/path/llvm-project/build/lib/libmlir_async_runtime.so
```
### 3. **Output Without `-convert-math-to-spirv`:**
```
[[[[1, 1],
[1, 1]],
[[1, 1],
[1, 1]]]]
```
### 4. **Command to Run With `-convert-math-to-spirv`:**
```
/path/llvm-project/build/bin/mlir-opt test.mlir -pass-pipeline='builtin.module(func.func(tosa-to-linalg-named,tosa-to-linalg))' | \
/path/llvm-project/build/bin/mlir-opt -tosa-to-arith -one-shot-bufferize="bufferize-function-boundaries" -convert-linalg-to-affine-loops -lower-affine -convert-scf-to-cf -expand-strided-metadata -convert-math-to-spirv -convert-math-to-libm -convert-cf-to-llvm -convert-arith-to-llvm -finalize-memref-to-llvm -convert-func-to-llvm -convert-spirv-to-llvm -reconcile-unrealized-casts | \
/path/llvm-project/build/bin/mlir-runner -e main -entry-point-result=void \
-shared-libs=/path/llvm-project/build/lib/libmlir_runner_utils.so \
-shared-libs=/path/llvm-project/build/lib/libmlir_c_runner_utils.so \
-shared-libs=/path/llvm-project/build/lib/libmlir_async_runtime.so
```
### 5. **Output With `-convert-math-to-spirv`:**
```
[[[[-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