[Mlir-commits] [mlir] 96fbd5c - [MLIR] [Python] Add `owner` to `mlir.ir.Block`

John Demme llvmlistbot at llvm.org
Thu Aug 19 00:13:29 PDT 2021


Author: John Demme
Date: 2021-08-19T00:02:09-07:00
New Revision: 96fbd5cd5e442bd01172d0d4491a2ef19876621f

URL: https://github.com/llvm/llvm-project/commit/96fbd5cd5e442bd01172d0d4491a2ef19876621f
DIFF: https://github.com/llvm/llvm-project/commit/96fbd5cd5e442bd01172d0d4491a2ef19876621f.diff

LOG: [MLIR] [Python] Add `owner` to `mlir.ir.Block`

Provides a way for python users to access the owning Operation from a Block.

Added: 
    

Modified: 
    mlir/lib/Bindings/Python/IRCore.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index 3e927ceec190f..d6305e7f49ec5 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -2200,6 +2200,12 @@ void mlir::python::populateIRCore(py::module &m) {
   // Mapping of PyBlock.
   //----------------------------------------------------------------------------
   py::class_<PyBlock>(m, "Block")
+      .def_property_readonly(
+          "owner",
+          [](PyBlock &self) {
+            return self.getParentOperation()->createOpView();
+          },
+          "Returns the owning operation of this block.")
       .def_property_readonly(
           "arguments",
           [](PyBlock &self) {


        


More information about the Mlir-commits mailing list