| Issue |
174580
|
| Summary |
[MLIR]Inconsistent Results When Using the `-affine-loop-fusion` Pass
|
| Labels |
|
| Assignees |
|
| Reporter |
BealZephyr
|
**test commit**: [5cfd02](https://github.com/llvm/llvm-project/commit/5cfd02f44a43a2e2a085a633b022a62f64ba2b93)
## Description:
I observed an inconsistency in the results depending on whether the `-affine-loop-fusion` pass is used.
## test case
```
module {
func.func private @printMemrefF32(tensor<*xf32>)
func.func @main() {
%0 = "tosa.const"() <{values = dense<4.000000e+00> : tensor<3x7x5xf32>}> : () -> tensor<3x7x5xf32>
%1 = tosa.rsqrt %0 : (tensor<3x7x5xf32>) -> tensor<3x7x5xf32>
%2 = tosa.reduce_sum %1 {axis = 0 : i32} : (tensor<3x7x5xf32>) -> tensor<1x7x5xf32>
%3 = tosa.sigmoid %2 : (tensor<1x7x5xf32>) -> tensor<1x7x5xf32>
%cast = tensor.cast %3 : tensor<1x7x5xf32> to tensor<*xf32>
call @printMemrefF32(%cast) : (tensor<*xf32>) -> ()
return
}
}
```
## Command:
### 1. Without `-affine-loop-fusion`
#### cmd:
```
mlir-opt test.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg))" | mlir-opt -linalg-fuse-elementwise-ops \
-one-shot-bufferize="bufferize-function-boundaries=1" -expand-strided-metadata -convert-linalg-to-affine-loops \
-lower-affine -convert-scf-to-cf -convert-to-llvm | mlir-runner -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project-latest/build/lib/libmlir_runner_utils.so
```
#### output:
```
[[[0.817574, 0.817574, 0.817574, 0.817574, 0.817574], ...]]]
```
### 2. With `-affine-loop-fusion`:
#### cmd:
```
mlir-opt test.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg))" | mlir-opt -linalg-fuse-elementwise-ops \
-one-shot-bufferize="bufferize-function-boundaries=1" -expand-strided-metadata -convert-linalg-to-affine-loops \
-affine-loop-fusion -lower-affine -convert-scf-to-cf -convert-to-llvm | mlir-runner -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project-latest/build/lib/libmlir_runner_utils.so
```
#### output:
```
[[[0.952574, 0.952574, 0.952574, 0.952574, 0.952574], ...]]]
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs