Open
Description
git version: 0a44b24
system: Ubuntu 18.04.6 LTS
Description:
I am experiencing an inconsistent result when executing the same MLIR program with and without the --scf-for-to-while
and --test-scf-while-op-builder
optimizations. When these optimizations are applied, the program enters a dead loop.
Steps to Reproduce:
1. MLIR Program (a.mlir):
module {
func.func private @printMemrefI32(tensor<*xi32>)
func.func private @printMemrefF32(tensor<*xf32>)
func.func @main() {
%2 = "tosa.const"() <{value = dense<42> : tensor<1x3x7xi32>}> : () -> tensor<1x3x7xi32>
%4 = "tosa.const"() <{value = dense<35> : tensor<1x3x7xi32>}> : () -> tensor<1x3x7xi32>
%12 = tosa.minimum %2, %4 : (tensor<1x3x7xi32>, tensor<1x3x7xi32>) -> tensor<1x3x7xi32>
%cast = tensor.cast %12 : tensor<1x3x7xi32> to tensor<*xi32>
call @printMemrefI32(%cast) : (tensor<*xi32>) -> ()
return
}
}
2. Command to Run Without Optimizations::
/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt a.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg))" \
| /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -tosa-to-arith -convert-linalg-to-parallel-loops \
-one-shot-bufferize="bufferize-function-boundaries" -convert-linalg-to-loops -finalize-memref-to-llvm \
-convert-arith-to-llvm -convert-scf-to-cf -convert-func-to-llvm -reconcile-unrealized-casts \
| timeout 10 /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-cpu-runner -e main -entry-point-result=void \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_c_runner_utils.so \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_runner_utils.so
3. Output WithOut Optimizations::
Unranked Memref base@ = 0x561bcc0853c0 rank = 3 offset = 0 sizes = [1, 3, 7] strides = [21, 7, 1] data =
[[[35, 35, 35, 35, 35, 35, 35],
[35, 35, 35, 35, 35, 35, 35],
[35, 35, 35, 35, 35, 35, 35]]]
4. Command to Run With --scf-for-to-while and --test-scf-while-op-builder Optimizations::
/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt a.mlir \
-pass-pipeline="builtin.module(func.func(tosa-to-linalg))" | /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt \
-tosa-to-arith -convert-linalg-to-parallel-loops -one-shot-bufferize="bufferize-function-boundaries" \
-convert-linalg-to-loops --scf-for-to-while --test-scf-while-op-builder -finalize-memref-to-llvm \
-convert-arith-to-llvm -convert-scf-to-cf -convert-func-to-llvm -reconcile-unrealized-casts \
| timeout 10 /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-cpu-runner -e main -entry-point-result=void \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_c_runner_utils.so \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_runner_utils.so
5. Behavior with Optimizations::
When I apply the --scf-for-to-while and --test-scf-while-op-builder optimizations, the program enters a dead loop and doesn't produce any output.