|
19 | 19 | #include "mlir/Bindings/Python/PybindAdaptors.h" |
20 | 20 | #include "pybind11/pybind11.h" |
21 | 21 | #include "llvm/Support/DynamicLibrary.h" |
| 22 | +#include <iostream> |
22 | 23 | #include <pybind11/attr.h> |
23 | 24 | #include <pybind11/functional.h> |
24 | 25 |
|
@@ -68,6 +69,7 @@ class PyStableHLOToExecutableOptions |
68 | 69 | mtrtPythonCapsuleToStableHLOToExecutableOptions, |
69 | 70 | mtrtPythonStableHLOToExecutableOptionsToCapsule}; |
70 | 71 |
|
| 72 | + // We need this member so we can keep the Python callback alive long enough. |
71 | 73 | std::function<std::string(MlirOperation)> callback; |
72 | 74 | }; |
73 | 75 | } // namespace |
@@ -226,25 +228,6 @@ static void bindTensorRTPluginAdaptorObjects(py::module m) { |
226 | 228 | #endif |
227 | 229 | #endif |
228 | 230 |
|
229 | | -void layerMetadataCallback(MlirOperation op, MlirStringCallback append, |
230 | | - void *appendCtx, void *userDataVoid) { |
231 | | - // auto pyCallback = |
232 | | - // *static_cast<std::function<std::string(MlirOperation)> |
233 | | - // *>(userDataVoid); |
234 | | - |
235 | | - // std::string result; |
236 | | - // try { |
237 | | - // result = pyCallback(op); |
238 | | - // } catch (const std::exception &e) { |
239 | | - // // TODO: What to do here? Change callback to return a status |
240 | | - // // instead of void? |
241 | | - // // return mtrtStatusCreate( |
242 | | - // // MTRT_StatusCode::MTRT_StatusCode_Unknown, e.what()); |
243 | | - // } |
244 | | - |
245 | | - // append(MlirStringRef{result.data(), result.size()}, appendCtx); |
246 | | -} |
247 | | - |
248 | 231 | PYBIND11_MODULE(_api, m) { |
249 | 232 |
|
250 | 233 | populateCommonBindingsInModule(m); |
@@ -312,10 +295,7 @@ PYBIND11_MODULE(_api, m) { |
312 | 295 | try { |
313 | 296 | result = pyCallback(op); |
314 | 297 | } catch (const std::exception &e) { |
315 | | - // TODO: What to do here? Change callback to return a status |
316 | | - // instead of void? |
317 | | - // return mtrtStatusCreate( |
318 | | - // MTRT_StatusCode::MTRT_StatusCode_Unknown, e.what()); |
| 298 | + std::cerr << e.what() << std::endl; |
319 | 299 | } |
320 | 300 |
|
321 | 301 | append(MlirStringRef{result.data(), result.size()}, appendCtx); |
|
0 commit comments