[Mlir-commits] [mlir] [mlir][tosa] Print generic `cond_if` when block arguments are present (PR #144859)
Luke Hutton
llvmlistbot at llvm.org
Mon Jun 23 01:38:18 PDT 2025
================
@@ -3690,12 +3706,11 @@ void IfOp::print(OpAsmPrinter &p) {
printBlockTerminators = true;
}
p << ' ';
- p.printRegion(getThenGraph(),
+ p.printRegion(thenRegion,
/*printEntryBlockArgs=*/false,
----------------
lhutton1 wrote:
Thanks, I had considered this, but ran into some issues. Using the example above I get:
```
func.func @test_cond_if_generic_form(%arg0: tensor<f32>, %arg1: tensor<f32>, %arg2: tensor<i1>) -> tensor<f32> {
%0 = tosa.cond_if %arg2 -> (tensor<f32>) {
^bb0(%arg3: tensor<f32>, %arg4: tensor<f32>):
%1 = tosa.add %arg3, %arg4 : (tensor<f32>, tensor<f32>) -> tensor<f32>
tosa.yield %1 : tensor<f32>
} else {
^bb0(%arg3: tensor<f32>, %arg4: tensor<f32>):
%1 = tosa.sub %arg3, %arg4 : (tensor<f32>, tensor<f32>) -> tensor<f32>
tosa.yield %1 : tensor<f32>
}
return %0 : tensor<f32>
}
```
But the cond_if verifier currently requires the same number of block arguments as the input list which is currently empty:
```
error: 'tosa.cond_if' op require same number of values in 'then_graph' arguments (2) and 'input_list' (0)
```
I had hoped to revisit changing the simplified format, but since it might require some further discussion, I wanted to fix the immediate issue first.
https://github.com/llvm/llvm-project/pull/144859
More information about the Mlir-commits
mailing list