[Mlir-commits] [mlir] [MLIR][TOSA] Update IfOp print/parse to support ranked condition tens… (PR #149791)
Luke Hutton
llvmlistbot at llvm.org
Tue Jul 22 01:27:19 PDT 2025
================
@@ -500,9 +500,37 @@ func.func @test_cond_if_input_list_mismatch_else_block_2(%arg0: tensor<f32>, %ar
// -----
+func.func @test_cond_if_input_list_mismatch_else_block_simple(%arg0: tensor<f32>, %arg1: tensor<f32>, %arg2: tensor<i1>) -> tensor<f32> {
+ // expected-error at +1 {{'tosa.cond_if' op require same number of values in 'else_graph' arguments (1) and 'input_list' (2)}}
+ %0 = tosa.cond_if %arg2 (%arg3 = %arg0, %arg4 = %arg1) : tensor<i1> (tensor<f32>, tensor<f32>) -> tensor<f32> {
+ %1 = tosa.add %arg3, %arg4 : (tensor<f32>, tensor<f32>) -> tensor<f32>
----------------
lhutton1 wrote:
The current format seems to allow block arguments to not be specified in the `then` region, but requires block arguments in the `else` region. Is it possible to ensure the same approach is taken for both? i.e. allow one of the two following cases:
```
# no block arguments
func.func @test_cond_if(%arg0: tensor<f32>, %arg1: tensor<f32>, %arg2: tensor<i1>) -> tensor<f32> {
%0 = tosa.cond_if %arg2 (%arg3 = %arg1, %arg4 = %arg0) : tensor<i1> (tensor<f32>, tensor<f32>) -> tensor<f32> {
tosa.yield %arg3 : tensor<f32>
} else {
tosa.yield %arg4 : tensor<f32>
}
return %0 : tensor<f32>
}
$ mlir-opt test.mlir --tosa-validate="profile=pro_fp extension=controlflow strict-op-spec-alignment"
test.mlir:5:16: error: use of undeclared SSA value name
tosa.yield %arg4 : tensor<f32>
# then region block arguments
func.func @test_cond_if(%arg0: tensor<f32>, %arg1: tensor<f32>, %arg2: tensor<i1>) -> tensor<f32> {
%0 = tosa.cond_if %arg2 (%arg3 = %arg1) : tensor<i1> (tensor<f32>) -> tensor<f32> {
^bb0(%arg3: tensor<f32>):
tosa.yield %arg3 : tensor<f32>
} else {
^bb0(%arg3: tensor<f32>):
tosa.yield %arg3 : tensor<f32>
}
return %0 : tensor<f32>
}
$ mlir-opt test.mlir --tosa-validate="profile=pro_fp extension=controlflow strict-op-spec-alignment"
test.mlir:3:3: error: invalid block name in region with named arguments
^bb0(%arg3: tensor<f32>):
```
https://github.com/llvm/llvm-project/pull/149791
More information about the Mlir-commits
mailing list