tvm_ffi.structural_visit

tvm_ffi.structural_visit#

tvm_ffi.structural_visit(root, callbacks=())[source]#

Visit a value structurally with callbacks that own child traversal.

Each callback receives (value, visitor). It may call StructuralVisitor.visit() for selected children or StructuralVisitor.default_visit() for the value’s registered/default descent. Returning without either call prunes that value’s subtree.

Parameters:
  • root (Any) – Root value to traverse.

  • callbacks (tuple | Sequence | Callable, default: ()) – A callback, (type, callback) entry, grouped type entry, or sequence of entries. Entries are tried in order and the first match owns descent.

Return type:

VisitInterrupt | None

Returns:

resultNone if traversal completed, otherwise a VisitInterrupt.