[MLIR] Inconsistent output when executing MLIR program with and without `-test-commutativity-utils`
My git version is 9d7ca6c.
Description:
I am experiencing an inconsistent result when executing the same MLIR program with and without the -test-commutativity-utils.
Steps to Reproduce:
1. MLIR Program (test.mlir):
test.mlir:
module {
func.func private @printMemrefI32(tensor<*xi32>)
func.func @main() {
%0 = "tosa.const"() <{values = dense<2> : tensor<1x3xi32>}> : () -> tensor<1x3xi32>
%1 = tosa.equal %0, %0 : (tensor<1x3xi32>, tensor<1x3xi32>) -> tensor<1x3xi1>
%2 = tosa.cast %1 : (tensor<1x3xi1>) -> tensor<1x3xi32>
%cast = tensor.cast %2 : tensor<1x3xi32> to tensor<*xi32>
call @printMemrefI32(%cast) : (tensor<*xi32>) -> ()
return
}
}
2. Command to Run Without -test-commutativity-utils:
/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 -expand-strided-metadata -lower-host-to-llvm -convert-cf-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-commutativity-utils:
[[1, 1, 1]]
4. Command to Run With -test-commutativity-utils:
/path/llvm-project/build/bin/mlir-opt test.mlir -test-commutativity-utils | \
/path/llvm-project/build/bin/mlir-opt -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 -expand-strided-metadata -lower-host-to-llvm -convert-cf-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-commutativity-utils:
[[-1, -1, -1]]
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/issue-subscribers-mlir
Author: None (Lambor24)
Description:
I am experiencing an inconsistent result when executing the same MLIR program with and without the -test-commutativity-utils.
Steps to Reproduce:
1. MLIR Program (test.mlir):
test.mlir:
module {
func.func private @<!-- -->printMemrefI32(tensor<*xi32>)
func.func @<!-- -->main() {
%0 = "tosa.const"() <{values = dense<2> : tensor<1x3xi32>}> : () -> tensor<1x3xi32>
%1 = tosa.equal %0, %0 : (tensor<1x3xi32>, tensor<1x3xi32>) -> tensor<1x3xi1>
%2 = tosa.cast %1 : (tensor<1x3xi1>) -> tensor<1x3xi32>
%cast = tensor.cast %2 : tensor<1x3xi32> to tensor<*xi32>
call @<!-- -->printMemrefI32(%cast) : (tensor<*xi32>) -> ()
return
}
}
2. Command to Run Without -test-commutativity-utils:
/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 -expand-strided-metadata -lower-host-to-llvm -convert-cf-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-commutativity-utils:
[[1, 1, 1]]
4. Command to Run With -test-commutativity-utils:
/path/llvm-project/build/bin/mlir-opt test.mlir -test-commutativity-utils | \
/path/llvm-project/build/bin/mlir-opt -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 -expand-strided-metadata -lower-host-to-llvm -convert-cf-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-commutativity-utils:
[[-1, -1, -1]]
I'm not sure if there is any bug in my program or if the wrong usage of the above passes caused this result.
This problem is similar to [[MLIR] Inconsistent output when executing MLIR program with and without -test-math-to-vcix #130697 ].
This issue has been fixed.