[Mlir-commits] [mlir] [mlir][python] Add `walk` method to PyOperationBase (PR #87962)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Mon Apr 8 04:36:09 PDT 2024


================
@@ -1249,6 +1249,19 @@ void PyOperationBase::writeBytecode(const py::object &fileObject,
                               .str());
 }
 
+void PyOperationBase::walk(py::object callback, bool usePreOrder) {
----------------
ftynse wrote:

I think it is possible to spell out the callback type as `std::function<void (MlirOperation)>` here, not sure if this will have any performance implications.

Consider exposing `MlirWalkResult` in C and Python API to allow functions to stop the walk early. 

I'm also not a fan of using a boolean kwarg for order, but can live with it.

https://github.com/llvm/llvm-project/pull/87962


More information about the Mlir-commits mailing list