[MLIR] [Python] Add `owner` to `mlir.ir.Block`
authorJohn Demme <john.demme@microsoft.com>
Thu, 19 Aug 2021 07:02:09 +0000 (00:02 -0700)
committerJohn Demme <john.demme@microsoft.com>
Thu, 19 Aug 2021 07:02:09 +0000 (00:02 -0700)
Provides a way for python users to access the owning Operation from a Block.

mlir/lib/Bindings/Python/IRCore.cpp

index 3e927ce..d6305e7 100644 (file)
@@ -2201,6 +2201,12 @@ void mlir::python::populateIRCore(py::module &m) {
   //----------------------------------------------------------------------------
   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) {
             return PyBlockArgumentList(self.getParentOperation(), self.get());