[Mlir-commits] [mlir] [mlir][tosa] Harden folds/canonicalizations for unranked and dynamic shapes (PR #188188)
Luke Hutton
llvmlistbot at llvm.org
Thu Mar 26 06:40:31 PDT 2026
================
@@ -28,6 +28,41 @@ func.func @try_fold_equal_with_unranked_tensor(%arg0: tensor<4xi32>, %arg1: tens
// -----
+// CHECK-LABEL: func @try_fold_unranked_constant_results
+func.func @try_fold_unranked_constant_results() {
+ // CHECK: tosa.equal
+ // CHECK: tosa.greater
+ // CHECK: tosa.greater_equal
+ // CHECK: tosa.cast
+ // CHECK: tosa.reciprocal
+ // CHECK-NEXT: return
+ %lhs = arith.constant dense<1> : tensor<1xi32>
+ %rhs = arith.constant dense<2> : tensor<1xi32>
+ %f = arith.constant dense<2.0> : tensor<1xf32>
+ %0 = tosa.equal %lhs, %rhs : (tensor<1xi32>, tensor<1xi32>) -> tensor<*xi1>
+ %1 = tosa.greater %lhs, %rhs : (tensor<1xi32>, tensor<1xi32>) -> tensor<*xi1>
+ %2 = tosa.greater_equal %lhs, %rhs : (tensor<1xi32>, tensor<1xi32>) -> tensor<*xi1>
+ %3 = tosa.cast %lhs : (tensor<1xi32>) -> tensor<*xf32>
+ %4 = tosa.reciprocal %f : (tensor<1xf32>) -> tensor<*xf32>
----------------
lhutton1 wrote:
Apologies, could we test a different op that goes through `unaryFolder`, the abs fold implementation doesn't use this
https://github.com/llvm/llvm-project/pull/188188
More information about the Mlir-commits
mailing list