Skip to content

[MLIR] tosa.powf + tosa.ceil returns incorrect result with -test-expand-math #151786

@sweead

Description

@sweead

test commit: 8934a6e

Description:

I am experiencing an inconsistent result when executing the same MLIR program with and without the -test-expand-math.

Steps to Reproduce:

Minimal MLIR program (test.mlir):

module {
  func.func private @printMemrefF32(tensor<*xf32>)
  func.func @main() -> () {
    %arg0 = "tosa.const"() {values = dense<137.27> : tensor<10x1xf32>} : () -> tensor<10x1xf32>
    %0 = tosa.pow %arg0, %arg0 : (tensor<10x1xf32>, tensor<10x1xf32>) -> tensor<10x1xf32>
    %5 = tosa.ceil %0 : (tensor<10x1xf32>) -> tensor<10x1xf32>
    %rtn1 = tensor.cast %5 : tensor<10x1xf32> to tensor<*xf32>
    call @printMemrefF32(%rtn1) : (tensor<*xf32>) -> ()
    return
  }
}

1. Without -test-expand-math:

Command:

/home/workdir/llvm-project/build/bin/mlir-opt test.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg-named,tosa-to-linalg))" | \
/home/workdir/llvm-project/build/bin/mlir-opt -tosa-to-arith  -sparsifier | \
/home/workdir/llvm-project/build/bin/mlir-runner -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project/build/lib/libmlir_runner_utils.so

Output:

[[inf],[inf],[inf],[inf],[inf],[inf],[inf],[inf],[inf],[inf]]

2. With -test-expand-math:

/home/workdir/llvm-project/build/bin/mlir-opt test.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg-named,tosa-to-lina
lg))" | \
/home/workdir/llvm-project/build/bin/mlir-opt -tosa-to-arith  -test-expand-math  -sparsifier | \
/home/workdir/llvm-project/build/bin/mlir-runner -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project/build/lib/libmlir_runner_utils.so

Output:

[[1],[1],[1],[1],[1],[1],[1],[1],[1],[1]]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions