[Mlir-commits] [mlir] [mlir][python] Add `walk` method to PyOperationBase (PR #87962)
Maksim Levental
llvmlistbot at llvm.org
Thu Apr 11 06:25:03 PDT 2024
================
@@ -1249,6 +1250,21 @@ void PyOperationBase::writeBytecode(const py::object &fileObject,
.str());
}
+void PyOperationBase::walk(
+ std::function<MlirWalkResult(MlirOperation)> callback,
+ MlirWalkOrder walkOrder) {
+ PyOperation &operation = getOperation();
+ operation.checkValid();
+ MlirOperationWalkCallback walkCallback = [](MlirOperation op,
+ void *userData) {
+ auto *fn =
+ static_cast<std::function<MlirWalkResult(MlirOperation)> *>(userData);
+ return (*fn)(op);
----------------
makslevental wrote:
thought: can you actually check the result here to see if it's `py::none()` (i.e., the callback doesn't have a `return` statement) and then default to `MlirWalkResult::MlirWalkResultAdvance`. I think that's reasonable semantics? @ftynse
https://github.com/llvm/llvm-project/pull/87962
More information about the Mlir-commits
mailing list