[Mlir-commits] [mlir] [MLIR][Python] Fix detached operation coming from `IfOp` constructor (PR #107286)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Sep 4 13:07:10 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r 36c210bb340cfdc68d314dd188e18c0bf017b999...e6108a14c1651098d5406d1cc2cb1e88cc21ff53 mlir/python/mlir/dialects/scf.py mlir/test/python/dialects/scf.py
``````````
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- test/python/dialects/scf.py 2024-09-04 20:03:39.000000 +0000
+++ test/python/dialects/scf.py 2024-09-04 20:06:41.833677 +0000
@@ -275,26 +275,27 @@
# CHECK: scf.if %[[ARG0:.*]]
# CHECK: %[[ONE:.*]] = arith.constant 1
# CHECK: %[[ADD:.*]] = arith.addi %[[ONE]], %[[ONE]]
# CHECK: return
+
@constructAndPrintInModule
def testNestedIf():
- bool = IntegerType.get_signless(1)
- i32 = IntegerType.get_signless(32)
-
- @func.FuncOp.from_py_func(bool, bool)
- def nested_if(b, c):
- if_op = scf.IfOp(b)
- with InsertionPoint(if_op.then_block) as ip:
- if_op = scf.IfOp(c, ip=ip)
- with InsertionPoint(if_op.then_block):
- one = arith.ConstantOp(i32, 1)
- add = arith.AddIOp(one, one)
- scf.YieldOp([])
- scf.YieldOp([])
- return
+ bool = IntegerType.get_signless(1)
+ i32 = IntegerType.get_signless(32)
+
+ @func.FuncOp.from_py_func(bool, bool)
+ def nested_if(b, c):
+ if_op = scf.IfOp(b)
+ with InsertionPoint(if_op.then_block) as ip:
+ if_op = scf.IfOp(c, ip=ip)
+ with InsertionPoint(if_op.then_block):
+ one = arith.ConstantOp(i32, 1)
+ add = arith.AddIOp(one, one)
+ scf.YieldOp([])
+ scf.YieldOp([])
+ return
# CHECK: func @nested_if(%[[ARG0:.*]]: i1, %[[ARG1:.*]]: i1)
# CHECK: scf.if %[[ARG0:.*]]
# CHECK: scf.if %[[ARG1:.*]]
``````````
</details>
https://github.com/llvm/llvm-project/pull/107286
More information about the Mlir-commits
mailing list