[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 11:33:30 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Matt Hofmann (matth2k)

<details>
<summary>Changes</summary>

Without this fix, `scf.if` operations would be created without a parent. Since `scf.if` operations often have results, this caused silent bugs where the generated code was straight-up missing the operation.

---
Full diff: https://github.com/llvm/llvm-project/pull/107286.diff


1 Files Affected:

- (modified) mlir/python/mlir/dialects/scf.py (+1-1) 


``````````diff
diff --git a/mlir/python/mlir/dialects/scf.py b/mlir/python/mlir/dialects/scf.py
index 7025f6e0f1a166..2d0047b76c7022 100644
--- a/mlir/python/mlir/dialects/scf.py
+++ b/mlir/python/mlir/dialects/scf.py
@@ -87,7 +87,7 @@ def __init__(self, cond, results_=None, *, hasElse=False, loc=None, ip=None):
         operands.append(cond)
         results = []
         results.extend(results_)
-        super().__init__(results, cond)
+        super().__init__(results, cond, loc=loc, ip=ip)
         self.regions[0].blocks.append(*[])
         if hasElse:
             self.regions[1].blocks.append(*[])

``````````

</details>


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


More information about the Mlir-commits mailing list