| Issue |
174553
|
| Summary |
[MLIR] Inconsistent Results with `tosa.exp + tosa.ceil` when using `-test-expand-math`
|
| Labels |
mlir
|
| Assignees |
|
| Reporter |
BealZephyr
|
**test commit**: [5cfd02](https://github.com/llvm/llvm-project/commit/5cfd02f44a43a2e2a085a633b022a62f64ba2b93)
## Description:
I encountered an inconsistency in the results when performing two different pipelines on the same input program. Due to the `-test-expand-math` pass, seems to cause overflow or precision loss.
## test case
```
module {
func.func private @printMemrefI32(tensor<*xi32>)
func.func private @printMemrefF32(tensor<*xf32>)
func.func @main() {
%1 = "tosa.const"() <{values = dense<5.000000e+01> : tensor<10xf32>}> : () -> tensor<10xf32>
%3 = tosa.exp %1 : (tensor<10xf32>) -> tensor<10xf32>
%5 = tosa.ceil %3 : (tensor<10xf32>) -> tensor<10xf32>
%cast_1 = tensor.cast %5 : tensor<10xf32> to tensor<*xf32>
call @printMemrefF32(%cast_1) : (tensor<*xf32>) -> ()
return
}
}
```
## Command:
### 1. Without `-test-expand-math`
#### cmd:
```
mlir-opt test.mlir -tosa-to-tensor -tosa-to-linalg-pipeline -tosa-to-arith -one-shot-bufferize="bufferize-function-boundaries=1" \
-convert-linalg-to-affine-loops -lower-affine -convert-scf-to-cf -convert-to-llvm | mlir-runner -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project-latest/build/lib/libmlir_runner_utils.so
```
#### output:
```
[5.18471e+21, 5.18471e+21, 5.18471e+21, 5.18471e+21, 5.18471e+21, 5.18471e+21, 5.18471e+21, 5.18471e+21, 5.18471e+21, 5.18471e+21]
```
### 2. Without `-test-expand-math`:
#### cmd:
```
mlir-opt test.mlir -tosa-to-tensor -tosa-to-linalg-pipeline -tosa-to-arith -one-shot-bufferize="bufferize-function-boundaries=1" \
-convert-linalg-to-affine-loops -lower-affine -convert-scf-to-cf -test-expand-math -convert-to-llvm | mlir-runner -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project-latest/build/lib/libmlir_runner_utils.so
```
#### output:
```
[9.22337e+18, 9.22337e+18, 9.22337e+18, 9.22337e+18, 9.22337e+18, 9.22337e+18, 9.22337e+18, 9.22337e+18, 9.22337e+18, 9.22337e+18]
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs