Issue |
132202
|
Summary |
[MLIR] Inconsistent output when executing MLIR program with and without `-test-expand-math`
|
Labels |
mlir
|
Assignees |
|
Reporter |
Lambor24
|
My git version is [6003c30](https://github.com/llvm/llvm-project/commit/6003c3055a4630be31cc3d459cdbb88248a007b9).
## Description:
I am experiencing an inconsistent result when executing the same MLIR program with and without the `-test-expand-math`.
## 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<-4.671000e+01> : tensor<2x3xf32>}> : () -> tensor<2x3xf32>
%1 = tosa.floor %0 : (tensor<2x3xf32>) -> tensor<2x3xf32>
%2 = tosa.transpose %1 {perms = array<i32: 0, 1>} : (tensor<2x3xf32>) -> tensor<2x3xf32>
%3 = tosa.add %2, %2 : (tensor<2x3xf32>, tensor<2x3xf32>) -> tensor<2x3xf32>
%4 = tosa.pow %3, %2 : (tensor<2x3xf32>, tensor<2x3xf32>) -> tensor<2x3xf32>
%cast = tensor.cast %4 : tensor<2x3xf32> to tensor<*xf32>
call @printMemrefF32(%cast) : (tensor<*xf32>) -> ()
return
}
}
```
### 2. **Command to Run Without `-test-expand-math`:**
```
/path/llvm-project/build/bin/mlir-opt test.mlir -pass-pipeline='builtin.module(func.func(tosa-to-linalg))' | \
/path/llvm-project/build/bin/mlir-opt -tosa-to-tensor -tosa-to-arith -one-shot-bufferize="bufferize-function-boundaries" -convert-linalg-to-affine-loops -lower-affine -convert-scf-to-cf -convert-cf-to-llvm -convert-arith-to-llvm -convert-math-to-llvm -finalize-memref-to-llvm -convert-func-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 `-test-expand-math`:**
```
[[-0, -0, -0],
[-0, -0, -0]]
```
### 4. **Command to Run With `-test-expand-math`:**
```
/path/llvm-project/build/bin/mlir-opt test.mlir -pass-pipeline='builtin.module(func.func(tosa-to-linalg))' | \
/path/llvm-project/build/bin/mlir-opt -tosa-to-tensor -tosa-to-arith -one-shot-bufferize="bufferize-function-boundaries" -convert-linalg-to-affine-loops -lower-affine -convert-scf-to-cf -convert-cf-to-llvm -test-expand-math -convert-arith-to-llvm -convert-math-to-llvm -finalize-memref-to-llvm -convert-func-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 `-test-expand-math`:**
```
[[-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