Template Function tvm::ffi::StructuralWalkExpected#
Defined in File structural_visit.h
Function Documentation#
-
template<WalkOrder order, typename ...Callbacks>
Expected<Optional<VisitInterrupt>> tvm::ffi::StructuralWalkExpected(AnyView root, Callbacks&&... callbacks) noexcept# Structural walk visits every occurrence as a tree.
The walk keeps no state. A var’s type is walked under its region at every occurrence, a shared DAG node is visited once per parent, and callbacks fire once per occurrence. Pre may return Skip to prune a subtree or Stop to end the walk; post sees a node after its children. Dedup can be composed if descend once on pattern var is desirable, or in graph case: a pre callback with its own visited set returns Skip on a repeat.
Callbacks are selected the same way as in StructuralMap and return
Expected<WalkResult>.- Template Parameters:
order – Whether to invoke the callback before or after visiting children.
Callbacks – Callback types.
- Parameters:
root – The root value to visit.
callbacks – Callbacks invoked for matching nodes.
- Returns:
std::nulloptif traversal completed, or the interrupt a callback returned.