[mlir][python] ExecutionEngine can dump to object file

Differential Revision: https://reviews.llvm.org/D100786
This commit is contained in:
Nicolas Vasilache 2021-04-19 19:30:29 +00:00
parent cc68799056
commit 1dc533cea4
3 changed files with 19 additions and 1 deletions

View File

@ -67,6 +67,11 @@ MLIR_CAPI_EXPORTED void
mlirExecutionEngineRegisterSymbol(MlirExecutionEngine jit, MlirStringRef name,
void *sym);
/// Dump as an object in `fileName`.
MLIR_CAPI_EXPORTED void
mlirExecutionEngineDumpToObjectFile(MlirExecutionEngine jit,
MlirStringRef fileName);
#ifdef __cplusplus
}
#endif

View File

@ -93,5 +93,13 @@ void mlir::python::populateExecutionEngineSubmodule(py::module &m) {
mlirStringRefCreate(name.c_str(), name.size()),
reinterpret_cast<void *>(sym));
},
"Lookup function `func` in the ExecutionEngine.");
"Lookup function `func` in the ExecutionEngine.")
.def(
"dump_to_object_file",
[](PyExecutionEngine &executionEngine, const std::string &fileName) {
mlirExecutionEngineDumpToObjectFile(
executionEngine.get(),
mlirStringRefCreate(fileName.c_str(), fileName.size()));
},
"Dump ExecutionEngine to an object file.");
}

View File

@ -66,3 +66,8 @@ extern "C" void mlirExecutionEngineRegisterSymbol(MlirExecutionEngine jit,
return symbolMap;
});
}
extern "C" void mlirExecutionEngineDumpToObjectFile(MlirExecutionEngine jit,
MlirStringRef name) {
unwrap(jit)->dumpToObjectFile(unwrap(name));
}