[Mlir-commits] [mlir] [MLIR][Python] Add walk_of_type() binding and get_ops_of_type() utility (PR #186131)
Jakub Kuderski
llvmlistbot at llvm.org
Thu Mar 12 08:06:54 PDT 2026
================
@@ -35,18 +35,41 @@ def get_parent_of_type(op: OpView | Operation, op_class: type[OpView]) -> OpView
if not (isinstance(op_class, type) and issubclass(op_class, OpView)):
raise TypeError(f"op_class must be an OpView subclass, got {op_class!r}")
try:
- parent = op.parent
+ op = op.parent
except ValueError:
return None # No parent chain.
- while parent is not None:
- if isinstance(parent.opview, op_class):
- return parent.opview
- parent = parent.parent
+ while op is not None:
+ if isinstance(op.opview, op_class):
+ return op.opview
+ op = op.parent
return None
+def get_ops_of_type(
----------------
kuhar wrote:
This helper seems useful!
https://github.com/llvm/llvm-project/pull/186131
More information about the Mlir-commits
mailing list