-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Labels
Description
git version: 953838d
system: Ubuntu 18.04.6 LTS
Description:
I am experiencing an inconsistent result when executing the same MLIR program with and without --affine-data-copy-generate --affine-loop-fusion.
Steps to Reproduce:
1. MLIR Program (a.mlir):
a.mlir:
module {
func.func private @printMemrefI32(tensor<*xi32>)
func.func private @printMemrefF32(tensor<*xf32>)
func.func @main() {
%4 = "tosa.const"() <{value = dense<-7643> : tensor<1x2x2xi32>}> : () -> tensor<1x2x2xi32>
%6 = "tosa.const"() <{value = dense<-1782> : tensor<1x2x2xi32>}> : () -> tensor<1x2x2xi32>
%14 = tosa.cast %6 : (tensor<1x2x2xi32>) -> tensor<1x2x2xf32>
%40 = tosa.cast %4 : (tensor<1x2x2xi32>) -> tensor<1x2x2xf32>
%41 = tosa.clamp %14 {max_fp = 1.07374182E+9 : f32, max_int = 1073741823 : i64, min_fp = -1.07374182E+9 : f32, min_int = -1073741824 : i64} : (tensor<1x2x2xf32>) -> tensor<1x2x2xf32>
%42 = tosa.clamp %40 {max_fp = 1.07374182E+9 : f32, max_int = 1073741823 : i64, min_fp = -1.07374182E+9 : f32, min_int = -1073741824 : i64} : (tensor<1x2x2xf32>) -> tensor<1x2x2xf32>
%43 = tosa.sub %41, %42 : (tensor<1x2x2xf32>, tensor<1x2x2xf32>) -> tensor<1x2x2xf32>
%cast = tensor.cast %43 : tensor<1x2x2xf32> to tensor<*xf32>
call @printMemrefF32(%cast) : (tensor<*xf32>) -> ()
return
}
}2. Command to Run without --affine-data-copy-generate --affine-loop-fusion:
/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt a.mlir -tosa-to-arith --tosa-layerwise-constant-fold | /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -pass-pipeline="builtin.module(func.func(tosa-to-linalg))" | /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -convert-arith-to-llvm -one-shot-bufferize="bufferize-function-boundaries" -convert-linalg-to-affine-loops -lower-affine --expand-strided-metadata -finalize-memref-to-llvm -convert-math-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 --shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_async_runtime.so3. Output without --affine-data-copy-generate --affine-loop-fusion::
[[[5861, 5861],
[5861, 5861]]]4. Command to Run With --affine-data-copy-generate --affine-loop-fusion:
/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt a.mlir -tosa-to-arith --tosa-layerwise-constant-fold | /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -pass-pipeline="builtin.module(func.func(tosa-to-linalg))" | /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -convert-arith-to-llvm -one-shot-bufferize="bufferize-function-boundaries" -convert-linalg-to-affine-loops --affine-data-copy-generate="generate-dma=false fast-mem-space=0 skip-non-unit-stride-loops" --affine-loop-fusion -lower-affine --expand-strided-metadata -finalize-memref-to-llvm -convert-math-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 --shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_async_runtime.so5. Output with --affine-data-copy-generate --affine-loop-fusion:
[[[7643, 7643],
[7643, 7643]]]