Open
Description
git version: adf892d
system: Ubuntu 18.04.6 LTS
Description:
I am experiencing an inconsistent result when executing the same MLIR program with and without the --test-math-polynomial-approximation
. I am not sure whether the semantic of --test-math-polynomial-approximation
should affect the results.
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() {
%0 = "tosa.const"() <{value = dense<[0, 2, 1]> : tensor<3xi32>}> : () -> tensor<3xi32>
%1 = "tosa.const"() <{value = dense<4068> : tensor<1x4x3xi32>}> : () -> tensor<1x4x3xi32>
%2 = "tosa.const"() <{value = dense<-1976> : tensor<1x4x3xi32>}> : () -> tensor<1x4x3xi32>
%3 = tosa.maximum %2, %1 : (tensor<1x4x3xi32>, tensor<1x4x3xi32>) -> tensor<1x4x3xi32>
%4 = tosa.transpose %3, %0 : (tensor<1x4x3xi32>, tensor<3xi32>) -> tensor<1x3x4xi32>
%5 = tosa.matmul %2, %4 : (tensor<1x4x3xi32>, tensor<1x3x4xi32>) -> tensor<1x4x4xi32>
%6 = tosa.cast %5 : (tensor<1x4x4xi32>) -> tensor<1x4x4xf32>
%7 = tosa.floor %6 : (tensor<1x4x4xf32>) -> tensor<1x4x4xf32>
%8 = tosa.sin %7 : (tensor<1x4x4xf32>) -> tensor<1x4x4xf32>
%cast = tensor.cast %8 : tensor<1x4x4xf32> to tensor<*xf32>
call @printMemrefF32(%cast) : (tensor<*xf32>) -> ()
return
}
}
2. Command to Run Without --test-math-polynomial-approximation
:
/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt a.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg-named,tosa-to-linalg))" | /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -tosa-to-arith -one-shot-bufferize="bufferize-function-boundaries" \
-convert-linalg-to-affine-loops -finalize-memref-to-llvm -lower-affine -finalize-memref-to-llvm -convert-arith-to-llvm \
-convert-math-to-llvm -convert-scf-to-cf -convert-arith-to-llvm -convert-func-to-llvm -convert-func-to-llvm \
-reconcile-unrealized-casts | /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.so
3. Output without --test-math-polynomial-approximation
:
[[[-0.0299986, -0.0299986, -0.0299986, -0.0299986],
[-0.0299986, -0.0299986, -0.0299986, -0.0299986],
[-0.0299986, -0.0299986, -0.0299986, -0.0299986],
[-0.0299986, -0.0299986, -0.0299986, -0.0299986]]]
4. Command to Run With --test-math-polynomial-approximation
:
/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt a.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg-named,tosa-to-linalg))" | /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -tosa-to-arith \
--test-math-polynomial-approximation -one-shot-bufferize="bufferize-function-boundaries" \
-convert-linalg-to-affine-loops -finalize-memref-to-llvm -lower-affine -finalize-memref-to-llvm \
-convert-arith-to-llvm -convert-math-to-llvm -convert-scf-to-cf -convert-arith-to-llvm -convert-func-to-llvm \
-convert-func-to-llvm -reconcile-unrealized-casts | /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.so
5. Output with --test-math-polynomial-approximation
:
[[[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 1, 1, 1]]]