[Mlir-commits] [mlir] [mlir][python] Add `walk` method to PyOperationBase (PR #87962)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Tue Apr 16 02:20:19 PDT 2024
================
@@ -717,17 +717,34 @@ void mlirOperationMoveBefore(MlirOperation op, MlirOperation other) {
return unwrap(op)->moveBefore(unwrap(other));
}
+static mlir::WalkResult translateWalkResult(MlirWalkResult result) {
+ switch (result) {
+ case MlirWalkResultAdvance:
+ return mlir::WalkResult::advance();
+
+ case MlirWalkResultInterrupt:
+ return mlir::WalkResult::interrupt();
+
+ case MlirWalkResultSkip:
+ return mlir::WalkResult::skip();
+ }
+}
+
void mlirOperationWalk(MlirOperation op, MlirOperationWalkCallback callback,
void *userData, MlirWalkOrder walkOrder) {
switch (walkOrder) {
case MlirWalkPreOrder:
unwrap(op)->walk<mlir::WalkOrder::PreOrder>(
- [callback, userData](Operation *op) { callback(wrap(op), userData); });
+ [callback, userData](Operation *op) {
+ return translateWalkResult(callback(wrap(op), userData));
----------------
ftynse wrote:
```suggestion
return unwrap(callback(wrap(op), userData));
```
https://github.com/llvm/llvm-project/pull/87962
More information about the Mlir-commits
mailing list