Skip to content

[MLIR] Unexpected inf output from tosa.rsqrt on zero input #151322

@sweead

Description

@sweead

test commit: 9164d20

Description:

When applying tosa.rsqrt to a tensor containing the value 0.0, the resulting value becomes inf.

Steps to Reproduce:

Minimal MLIR program (test.mlir):

module {
  func.func private @printMemrefF32(tensor<*xf32>)
  func.func @main() -> () {
    %arg0 = "tosa.const"() {values = dense<0.0> : tensor<1xf32>} : () -> tensor<1xf32>
    %3 = tosa.rsqrt %arg0 : (tensor<1xf32>) -> tensor<1xf32>
    %rtn1 = tensor.cast %3 : tensor<1xf32> to tensor<*xf32>
    call @printMemrefF32(%rtn1) : (tensor<*xf32>) -> ()
    return
  }
}

Command:

mlir-opt test.mlir  --tosa-to-linalg-pipeline  --sparsifier |  \
mlir-runner -e main -entry-point-result=void -shared-libs=/home/workdir/llvm-project/build/lib/libmlir_runner_utils.so

Output:

[inf]

Metadata

Metadata

Assignees

No one assigned

    Labels

    mlir:tosaquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions