[Mlir-commits] [mlir] [MLIR][Python] Fix detached operation coming from `IfOp` constructor (PR #107286)

Matt Hofmann llvmlistbot at llvm.org
Wed Sep 4 11:32:40 PDT 2024


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

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.

>From 4b45423e7c23ff4fd72945aa00031597b4c0cbe6 Mon Sep 17 00:00:00 2001
From: Matt Hofmann <47065711+matth2k at users.noreply.github.com>
Date: Wed, 4 Sep 2024 14:29:21 -0400
Subject: [PATCH] Fix detached operation from IfOp constructor

---
 mlir/python/mlir/dialects/scf.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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(*[])



More information about the Mlir-commits mailing list