tvm_ffi.VisitInterrupt

tvm_ffi.VisitInterrupt#

class tvm_ffi.VisitInterrupt(value=None)#

Bases: Object

Payload-carrying signal that stops a structural visit.

This object can be returned from structural walk callbacks and structural visit hooks to halt traversal early. The optional payload is preserved in value and returned to the caller.

Examples

Use VisitInterrupt to stop a structural walk when a target node is found:

import tvm_ffi

def on_node(node):
    if is_target(node):
        return tvm_ffi.VisitInterrupt(node)
    return None


result = tvm_ffi.structural_walk(root, (object, on_node), order="pre")
if result is not None:
    found = result.value

See also

tvm_ffi.structural_walk()

Structural walk API whose callbacks may return VisitInterrupt.

Parameters:

value (Any)

property value#