[Mlir-commits] [mlir] [mlir] Make C/Python ExecutionEngine constructible with an Operation. (PR #86329)
Jacques Pienaar
llvmlistbot at llvm.org
Tue Apr 9 02:09:30 PDT 2024
================
@@ -71,15 +71,34 @@ PYBIND11_MODULE(_mlirExecutionEngine, m) {
// Mapping of the top-level PassManager
//----------------------------------------------------------------------------
py::class_<PyExecutionEngine>(m, "ExecutionEngine", py::module_local())
- .def(py::init<>([](MlirModule module, int optLevel,
+ .def(py::init<>([](py::object operation_or_module, int optLevel,
const std::vector<std::string> &sharedLibPaths,
bool enableObjectDump) {
+ // Manually type cast from either a Module or Operation. The
+ // automatic type casters do not handle such cascades well,
+ // so be explicit.
+ py::object capsule = mlirApiObjectToCapsule(operation_or_module);
+ MlirOperation module_op =
+ mlirPythonCapsuleToOperation(capsule.ptr());
+ if (mlirOperationIsNull(module_op)) {
----------------
jpienaar wrote:
This is confusing ... I'd have expected this to be a check if not-null.
https://github.com/llvm/llvm-project/pull/86329
More information about the Mlir-commits
mailing list