From 96fbd5cd5e442bd01172d0d4491a2ef19876621f Mon Sep 17 00:00:00 2001 From: John Demme Date: Thu, 19 Aug 2021 00:02:09 -0700 Subject: [PATCH] [MLIR] [Python] Add `owner` to `mlir.ir.Block` Provides a way for python users to access the owning Operation from a Block. --- mlir/lib/Bindings/Python/IRCore.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp index 3e927ce..d6305e7 100644 --- a/mlir/lib/Bindings/Python/IRCore.cpp +++ b/mlir/lib/Bindings/Python/IRCore.cpp @@ -2201,6 +2201,12 @@ void mlir::python::populateIRCore(py::module &m) { //---------------------------------------------------------------------------- py::class_(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()); -- 2.7.4