tvm_ffi.StructuralMutator#
- class tvm_ffi.StructuralMutator(*args, **kwargs)#
Bases:
ObjectLow-level structural mutator.
This class exposes the mutator object used by structural-map and custom mutation hooks.
- Parameters:
args (Any)
kwargs (Any)
- mutate(value)#
Mutate
valuewithout modifying it in place.The original value is returned when none of its structural fields change; otherwise, the result is a mutated copy.
- Parameters:
value (Any) – Value to mutate.
- Returns:
result – The mutated owning value.
- Return type:
Any
- default_mutate(value)#
Mutate
valueusing its registered or reflected default behavior.This bypasses the active engine callback for
valueitself while recursive children re-enter the same mutator. Astructural_mutatecallback may use it on its matched value to request default descent.- Parameters:
value (Any) – Value whose default mutation should run.
- Returns:
result – The mutated owning value.
- Return type:
Any
- var_remap_get(var)#
Return the replacement recorded for a variable identity.
- Parameters:
var (Object) – Variable identity to look up. It must be an object-backed value with free-variable or DAG-node structural metadata.
- Returns:
result – The recorded replacement, or
Noneifvarhas no replacement.- Return type:
Any | None
- var_remap_set(var, mapped_value)#
Record or replace the substitution for a variable identity.
- Parameters:
var (Object) – Variable identity to bind. It must be an object-backed value with free-variable or DAG-node structural metadata.
mapped_value (Any) – Replacement returned for subsequent lookups of
var.
- Return type:
None
- def_region_kind()#
Return the currently active structural def-region kind.
- Returns:
kind – The active
DefRegionKind.- Return type:
- with_def_region_kind(kind, callback)#
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