tvm_ffi.access_path.AccessPath#
- class tvm_ffi.access_path.AccessPath[source]#
Bases:
ObjectAccess path container.
It describes how to reach a nested attribute or item inside a complex FFI object by recording a sequence of steps (attribute, array index, or map key). It is primarily used by diagnostics to pinpoint structural mismatches.
Examples
from tvm_ffi.access_path import AccessPath root = AccessPath.root() # Build a path equivalent to obj.layer.weight[2] p = root.attr("layer").attr("weight").array_item(2) assert isinstance(p, AccessPath)
Methods
__ffi_init__(*args)Defined in
Objectas method__ffi_init__().__init__()Disallow direct construction; use AccessPath.root() instead.
array_item(index)Create an access path to the item of the current array.
array_item_missing(index)Create an access path that indicate an array item is missing.
attr(attr_key)Create an access path to the attribute of the current object.
attr_missing(attr_key)Create an access path that indicate an attribute is missing.
is_prefix_of(other)Check if this access path is a prefix of another access path.
map_item(key)Create an access path to the item of the current map.
map_item_missing(key)Create an access path that indicate a map item is missing.
root()Create a root access path.
same_as(other)to_steps()Convert the access path to a list of access steps.
Attributes
- property parent#
- property step#
- property depth#
- static root()[source]#
Create a root access path.
- Return type:
- Returns:
AccessPath – A path representing the root of an object graph.
- is_prefix_of(other)[source]#
Check if this access path is a prefix of another access path.
- Parameters:
other (
AccessPath) – The access path to check if it is a prefix of this access path- Return type:
- Returns:
bool – True if this access path is a prefix of the other access path, False otherwise
- attr(attr_key)[source]#
Create an access path to the attribute of the current object.
- Parameters:
attr_key (
str) – The key of the attribute to access- Return type:
- Returns:
AccessPath – The extended access path
- attr_missing(attr_key)[source]#
Create an access path that indicate an attribute is missing.
- Parameters:
attr_key (
str) – The key of the attribute to access- Return type:
- Returns:
AccessPath – The extended access path
- array_item(index)[source]#
Create an access path to the item of the current array.
- Parameters:
index (
int) – The index of the item to access- Return type:
- Returns:
AccessPath – The extended access path
- array_item_missing(index)[source]#
Create an access path that indicate an array item is missing.
- Parameters:
index (
int) – The index of the item to access- Return type:
- Returns:
AccessPath – The extended access path
- map_item(key)[source]#
Create an access path to the item of the current map.
- Parameters:
key (
Any) – The key of the item to access- Return type:
- Returns:
AccessPath – The extended access path
- map_item_missing(key)[source]#
Create an access path that indicate a map item is missing.
- Parameters:
key (
Any) – The key of the item to access- Return type:
- Returns:
AccessPath – The extended access path