[Mlir-commits] [mlir] 1fb2e84 - [mlir][python] Forward _OperationBase _CAPIPtr to the Operation.

Stella Laurenzo llvmlistbot at llvm.org
Mon Sep 20 18:52:42 PDT 2021


Author: Stella Laurenzo
Date: 2021-09-20T18:52:05-07:00
New Revision: 1fb2e842a93ac862849f5081eb6fdf6f1447ef2a

URL: https://github.com/llvm/llvm-project/commit/1fb2e842a93ac862849f5081eb6fdf6f1447ef2a
DIFF: https://github.com/llvm/llvm-project/commit/1fb2e842a93ac862849f5081eb6fdf6f1447ef2a.diff

LOG: [mlir][python] Forward _OperationBase _CAPIPtr to the Operation.

* ODS generated operations extend _OperationBase and without this, cannot be marshalled to CAPI functions.
* No test case updates: this kind of interop is quite hard to verify with in-tree tests.

Differential Revision: https://reviews.llvm.org/D110030

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 8672b772e54c9..7763f4671d58c 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -2026,6 +2026,10 @@ void mlir::python::populateIRCore(py::module &m) {
   // Mapping of Operation.
   //----------------------------------------------------------------------------
   py::class_<PyOperationBase>(m, "_OperationBase", py::module_local())
+      .def_property_readonly(MLIR_PYTHON_CAPI_PTR_ATTR,
+                             [](PyOperationBase &self) {
+                               return self.getOperation().getCapsule();
+                             })
       .def("__eq__",
            [](PyOperationBase &self, PyOperationBase &other) {
              return &self.getOperation() == &other.getOperation();


        


More information about the Mlir-commits mailing list