[Mlir-commits] [mlir] Draft: [mlir][tosa] Fix unranked tosa canonicalizations crashes (PR #188188)

Hocky Yudhiono llvmlistbot at llvm.org
Tue Mar 24 20:46:32 PDT 2026


================

----------------
hockyy wrote:

For this specific one, i added 3 testcases
```


// ReverseOp::fold: unranked operand has hasRank() == false;
// CHECK-LABEL: @reverse_nofold_unranked_operand
func.func @reverse_nofold_unranked_operand(%arg0: tensor<*xf32>) -> tensor<*xf32> {
  // CHECK: tosa.reverse
  %0 = tosa.reverse %arg0 {axis = 0 : i32} : (tensor<*xf32>) -> tensor<*xf32>
  return %0 : tensor<*xf32>
}

// -----

// Unit-dim no-op, but mismatch type
// CHECK-LABEL: @reverse_nofold_unit_dim_unranked_result
func.func @reverse_nofold_unit_dim_unranked_result(%arg0: tensor<1x4xf32>) -> tensor<*xf32> {
  // CHECK: tosa.reverse
  %0 = tosa.reverse %arg0 {axis = 0 : i32} : (tensor<1x4xf32>) -> tensor<*xf32>
  return %0 : tensor<*xf32>
}

// -----

// Splat fold returns the operand ElementsAttr; But result type doesn't match.
// CHECK-LABEL: @reverse_nofold_splat_type_unmatch
func.func @reverse_nofold_splat_type_unmatch() -> tensor<*xf32> {
  // CHECK: tosa.reverse
  %0 = "tosa.const"() <{values = dense<1.0> : tensor<4xf32>}> : () -> tensor<4xf32>
  %1 = tosa.reverse %0 {axis = 0 : i32} : (tensor<4xf32>) -> tensor<*xf32>
  return %1 : tensor<*xf32>
}
```

https://github.com/llvm/llvm-project/pull/188188


More information about the Mlir-commits mailing list