Issue |
148366
|
Summary |
[MLIR] Inconsistent Results with `scf-for-loop-peeling`
|
Labels |
mlir
|
Assignees |
|
Reporter |
sweead
|
test commit: [f2e244f](https://github.com/llvm/llvm-project/commit/f2e244f443c99f814216bef37a82f1b8d3e5975d)
## Description:
I am experiencing an inconsistent result when running the same MLIR input through two pipelines that differ only in the peel-front flag of the scf-for-loop-peeling pass
## Steps to Reproduce:
### Minimal MLIR program (test.mlir):
```
module {
func.func private @printMemrefI8(tensor<*xi8>) attributes {llvm.emit_c_interface}
func.func @main() {
%0 = "tosa.const"() <{values = dense<17> : tensor<2x3x4x2x1x3xi8>}> : () -> tensor<2x3x4x2x1x3xi8>
%1 = "tosa.const"() <{values = dense<-2> : tensor<2x1x1x1x1x3xi8>}> : () -> tensor<2x1x1x1x1x3xi8>
%3 = tosa.maximum %0, %1 : (tensor<2x3x4x2x1x3xi8>, tensor<2x1x1x1x1x3xi8>) -> tensor<2x3x4x2x1x3xi8>
%cast_0 = tensor.cast %3 : tensor<2x3x4x2x1x3xi8> to tensor<*xi8>
call @printMemrefI8(%cast_0) : (tensor<*xi8>) -> ()
return
}
}
```
### 1. Using -scf-for-loop-peeling=peel-front=`false`:
#### 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 -sparsification-and-bufferization -tosa-to-arith -convert-linalg-to-loops \
-scf-for-loop-peeling=peel-front=false -test-lower-to-llvm | \
/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:
```
[[[[[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]]], [[[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]]], [[[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]]]], [[[[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]]], [[[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]]], [[[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]]]]]
```
### 2. Using -scf-for-loop-peeling=peel-front=`true `:
```
/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 -sparsification-and-bufferization -tosa-to-arith -convert-linalg-to-loops \
-scf-for-loop-peeling=peel-front=true -test-lower-to-llvm | \
/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:
```
[[[[[[, , &]], [[/, 0, V]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, �, �]]], [[[, L, 5]], [[V, , ]]]], [[[[, , ]], [[L, 5, V]]], [[[, , ]], [[�, l, L]]], [[[, , ]], [[, �, �]]], [[[, , ]], [[V, , ]]]], [[[[, , ]], [[L, 5, V]]], [[[, , ]], [[�, l, L]]], [[[, , ]], [[, �, �]]], [[[, , ]], [[V, , ]]]]], [[[[[, , ]], [[, , ]]], [[[, , P]], [[, l, L]]], [[[, V, ]], [[, �, �]]], [[[, L, 5]], [[, , ]]]], [[[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]]], [[[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]], [[[, , ]], [[, , ]]]]]]
```
It seems that the loop peeling process caused undefined values in memory.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs