Native mutation with exact dispatch and structural fallback.
More...
#include <object_functor.h>
|
| | ObjectMutator () |
| | Construct a mutator using structural fallback for every object.
|
| |
| | ObjectMutator (const ObjectMutator &other)=delete |
| |
| ObjectMutator & | operator= (const ObjectMutator &other)=delete |
| |
| virtual UnchangedOr< ffi::Any > | Mutate (ffi::AnyView value, InplaceMode inplace_mode=InplaceMode::kDisallow) |
| | Mutate a borrowed value, throwing on failure.
|
| |
| Expected< UnchangedOr< ffi::Any > > | MutateExpected (ffi::AnyView value, InplaceMode inplace_mode=InplaceMode::kDisallow) noexcept |
| | Adapt the virtual throwing entrypoint to the structural ABI.
|
| |
| ffi::Any | VarRemapGet (ffi::AnyView var) |
| | Look up a variable replacement, throwing on failure.
|
| |
| void | VarRemapSet (ffi::AnyView var, ffi::AnyView value) |
| | Record a variable replacement, throwing on failure.
|
| |
| TVM_FFI_INLINE Expected< ffi::Any > | VarRemapGetExpected (ffi::AnyView var) noexcept |
| | Look up a replacement in the variable-remap environment.
|
| |
| TVM_FFI_INLINE Expected< void > | VarRemapSetExpected (ffi::AnyView var, ffi::AnyView mapped_value) noexcept |
| | Record a replacement in the variable-remap environment.
|
| |
|
| using | VTable = ObjectFunctor< UnchangedOr< ffi::Any >(const ffi::Object *, ObjectMutator *, InplaceMode)> |
| | Exact native dispatch table with owning replacement results.
|
| |
|
| | ObjectMutator (const VTable *vtable) |
| | Construct a mutator with a finalized native dispatch table.
|
| |
|
| static void | InitVTable (VTable *vtable) |
| | Initialize the base registrations in a fresh mutable table.
|
| |
| template<typename Self , typename Node > |
| static void | SetDispatch (VTable *vtable) |
| | Register an exact node type in a fresh table initialized by its parent. Derived node types require separate registrations.
|
| |
Native mutation with exact dispatch and structural fallback.
Allocate mutators with ffi::make_object<Derived>(). Inputs are borrowed; replacements and errors own their values. Overrides forward inplace_mode to child calls, following the structural mutation ownership contract.
◆ VTable
Exact native dispatch table with owning replacement results.
◆ ObjectMutator() [1/3]
| tvm::ObjectMutator::ObjectMutator |
( |
| ) |
|
|
inline |
Construct a mutator using structural fallback for every object.
◆ ObjectMutator() [2/3]
◆ ObjectMutator() [3/3]
| tvm::ObjectMutator::ObjectMutator |
( |
const VTable * |
vtable | ) |
|
|
inlineexplicitprotected |
Construct a mutator with a finalized native dispatch table.
- Parameters
-
| vtable | The immutable table, which must outlive this mutator. |
◆ InitVTable()
| static void tvm::ObjectMutator::InitVTable |
( |
VTable * |
vtable | ) |
|
|
inlinestaticprotected |
Initialize the base registrations in a fresh mutable table.
- Parameters
-
| vtable | The table to initialize before adding derived registrations. |
◆ Mutate()
| virtual UnchangedOr< ffi::Any > tvm::ObjectMutator::Mutate |
( |
ffi::AnyView |
value, |
|
|
InplaceMode |
inplace_mode = InplaceMode::kDisallow |
|
) |
| |
|
inlinevirtual |
Mutate a borrowed value, throwing on failure.
- Parameters
-
| value | The borrowed object or inline value to mutate. |
| inplace_mode | Inherited permission along the path to this value. |
- Returns
- An owning replacement or Unchanged. Non-object inputs return their inline value.
- Note
- Establishes uniqueness before invoking typed hooks. Entry overrides must preserve inherited denial and check uniqueness before writing or forwarding permission. Qualified Parent::Mutate bypasses the current override while descendants remain virtual. Completed in-place changes are not rolled back on error.
In-place mutation requires every node and owning container on the root-to-current path to be unique. Inherited inplace_mode records ancestor permission; Mutate checks the current target. Never promote inherited denial to permission. Within a Mutate_ hook, forward mode to a parent hook or an immediate child:
Parent_::Mutate_(node, mode);
virtual UnchangedOr< ffi::Any > Mutate(ffi::AnyView value, InplaceMode inplace_mode=InplaceMode::kDisallow)
Mutate a borrowed value, throwing on failure.
Definition object_functor.h:380
Direct descent that skips an owning ancestor must check that ancestor too:
auto child_mode = node->elem.unique() ? mode : InplaceMode::kDisallow;
Mutate(node->elem->a, child_mode);
When in doubt, omit inplace_mode. The default kDisallow is always safe; pass permission explicitly only when the full ancestor path is accounted for.
Reimplemented in tvm::ExprMutator.
◆ MutateExpected()
| Expected< UnchangedOr< ffi::Any > > tvm::ObjectMutator::MutateExpected |
( |
ffi::AnyView |
value, |
|
|
InplaceMode |
inplace_mode = InplaceMode::kDisallow |
|
) |
| |
|
inlinenoexcept |
Adapt the virtual throwing entrypoint to the structural ABI.
- Parameters
-
| value | The borrowed value to mutate. |
| inplace_mode | Inherited mutation permission. |
- Returns
- The replacement, Unchanged, or the caught error.
- Note
- Matches the FFI safe-call exception contract. Error identity is preserved; other standard exceptions become InternalError.
◆ operator=()
◆ SetDispatch()
template<typename Self , typename Node >
| static void tvm::ObjectMutator::SetDispatch |
( |
VTable * |
vtable | ) |
|
|
inlinestaticprotected |
Register an exact node type in a fresh table initialized by its parent. Derived node types require separate registrations.
- Template Parameters
-
| Self | The mutator implementing the hook. |
| Node | The exact node type handled by the hook. |
- Parameters
-
| vtable | The mutable table to receive the registration. |
◆ VarRemapGet()
| ffi::Any tvm::ObjectMutator::VarRemapGet |
( |
ffi::AnyView |
var | ) |
|
|
inline |
Look up a variable replacement, throwing on failure.
◆ VarRemapGetExpected()
| TVM_FFI_INLINE Expected< ffi::Any > tvm::ObjectMutator::VarRemapGetExpected |
( |
ffi::AnyView |
var | ) |
|
|
inlinenoexcept |
Look up a replacement in the variable-remap environment.
- Parameters
-
| var | The borrowed variable identity to look up. |
- Returns
- The owning replacement, None on a miss, or an Error.
◆ VarRemapSet()
| void tvm::ObjectMutator::VarRemapSet |
( |
ffi::AnyView |
var, |
|
|
ffi::AnyView |
value |
|
) |
| |
|
inline |
Record a variable replacement, throwing on failure.
◆ VarRemapSetExpected()
| TVM_FFI_INLINE Expected< void > tvm::ObjectMutator::VarRemapSetExpected |
( |
ffi::AnyView |
var, |
|
|
ffi::AnyView |
mapped_value |
|
) |
| |
|
inlinenoexcept |
Record a replacement in the variable-remap environment.
- Parameters
-
| var | The borrowed variable identity to bind. |
| mapped_value | The borrowed replacement value. |
- Returns
- Successful completion or an Error.
The documentation for this class was generated from the following file: