aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Bindings/Python/IRModule.h
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/lib/Bindings/Python/IRModule.h')
-rw-r--r--mlir/lib/Bindings/Python/IRModule.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/mlir/lib/Bindings/Python/IRModule.h b/mlir/lib/Bindings/Python/IRModule.h
index cfa3737..013bb7b 100644
--- a/mlir/lib/Bindings/Python/IRModule.h
+++ b/mlir/lib/Bindings/Python/IRModule.h
@@ -13,6 +13,7 @@
#include <utility>
#include <vector>
+#include "Globals.h"
#include "PybindUtils.h"
#include "mlir-c/AffineExpr.h"
@@ -868,9 +869,7 @@ public:
PyConcreteType() = default;
PyConcreteType(PyMlirContextRef contextRef, MlirType t)
- : BaseTy(std::move(contextRef), t) {
- pybind11::implicitly_convertible<PyType, DerivedTy>();
- }
+ : BaseTy(std::move(contextRef), t) {}
PyConcreteType(PyType &orig)
: PyConcreteType(orig.getContext(), castFrom(orig)) {}
@@ -914,6 +913,13 @@ public:
return printAccum.join();
});
+ if (DerivedTy::getTypeIdFunction) {
+ PyGlobals::get().registerTypeCaster(
+ DerivedTy::getTypeIdFunction(),
+ pybind11::cpp_function(
+ [](PyType pyType) -> DerivedTy { return pyType; }));
+ }
+
DerivedTy::bindDerived(cls);
}
@@ -1009,9 +1015,8 @@ public:
return DerivedTy::isaFunction(otherAttr);
},
pybind11::arg("other"));
- cls.def_property_readonly("type", [](PyAttribute &attr) {
- return PyType(attr.getContext(), mlirAttributeGetType(attr));
- });
+ cls.def_property_readonly(
+ "type", [](PyAttribute &attr) { return mlirAttributeGetType(attr); });
DerivedTy::bindDerived(cls);
}