tvm_tirx.tirx.structural.structural_walk_with_constraint_context

tvm_tirx.tirx.structural.structural_walk_with_constraint_context#

tvm_tirx.tirx.structural.structural_walk_with_constraint_context(root, callback, *, order='post')#

Walk a value structurally with its active symbolic facts.

The walk visits each occurrence as a tree. Sequence statements and lazy if_then_else arguments are visited directly, without callbacks on their intermediate arrays. Deduplication can use a pre-order callback that returns tvm_ffi.WalkResult.SKIP on repeats.

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

  • callback (callable) – Called as callback(value, constraints) for each visited value. The second argument is the active tvm_tirx.sym.ConstraintContext; callbacks must not append to it. Return None or tvm_ffi.WalkResult.ADVANCE to continue, tvm_ffi.WalkResult.SKIP to prune a pre-order subtree, or tvm_ffi.VisitInterrupt(payload) to stop traversal.

  • order ({"post", "pre"}, optional) – Visit children before their parent (the default), or the parent before its children. A scoped node’s post-order callback sees the outer facts after its body scope has ended.

Returns:

result (tvm_ffi.VisitInterrupt or None) – The interrupt returned by a callback, or None if traversal completes.

Raises:

ValueError – If order is neither "pre" nor "post".