tvm_ffi.StructuralVisitor#
- class tvm_ffi.StructuralVisitor(*args, **kwargs)#
Bases:
ObjectLow-level structural traversal visitor.
This class exposes the low-level visitor object used by structural traversal hooks. Instances are supplied by an active traversal and cannot be constructed directly.
- Parameters:
args (Any)
kwargs (Any)
- visit(value)#
Low-level API to visit
valueusing this visitor’s dispatch behavior.- Parameters:
value (Any) – Value to visit.
- Returns:
result –
Noneif traversal should continue, otherwise aVisitInterruptcarrying the early-exit payload.- Return type:
VisitInterrupt | None
- default_visit(value)#
Visit
valueusing its registered or reflected child traversal.Warning
Never call
default_visiton the value whose__s_visit__hook is currently running. Doing so re-enters the same hook recursively and can exhaust the C stack, crashing the process.This bypasses the active engine callback dispatch for
valueitself, but still invokes the value type’s registered__s_visit__hook when one exists. Use it for a child whose default traversal is wanted. Recursive children still use this visitor.- Parameters:
value (Any) – Value whose default children should be traversed.
- Returns:
result –
Noneif traversal should continue, otherwise aVisitInterruptcarrying the early-exit payload.- Return type:
VisitInterrupt | None
- def_region_kind()#
Low-level API to return the currently active structural def-region kind.
- Returns:
kind – The active
DefRegionKind.- Return type:
- with_def_region_kind(kind, callback)#
Low-level API to run
callbackwith a temporarily active def-region kind.- Parameters:
kind (int) – Def region kind to use while running
callback.callback (Callable[[], Any]) – Nullary callable to execute inside the scoped region.
- Returns:
result – The value returned by
callback.- Return type:
Any