tvm_ffi.VisitInterrupt#

class tvm_ffi.VisitInterrupt(value=None)[source]#

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))
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, default: None)

__init__(value=None)[source]#

Create an interrupt with an optional payload.

Parameters:

value (Any, default: None) – Payload returned to the caller when traversal stops.

Return type:

None

Methods

__ffi_init__(*args, **kwargs)

__init__([value])

Create an interrupt with an optional payload.

__init_handle_by_constructor__(fconstructor, ...)

Defined in Object as method __init_handle_by_constructor__().

__move_handle_from__(other)

Defined in Object as method __move_handle_from__().

_move()

Defined in Object as method _move().

is_(other)

Defined in Object as method is_().

same_as(other)

Defined in Object as method same_as().

Attributes

id_

Defined in Object as attribute id_.

value

property value#
__ffi_init__(*args, **kwargs)[source]#
Parameters:
Return type:

None