TensorId
PythonTensorId = strTensorId = strAIR tensor representation.
AirTensor()AIR tensor representation.
id: TensorId = Field(..., description='Unique tensor identifier')kind: AirTensorKind = Field(AirTensorKind.SCRATCH, description='The kind of tensor')quantization: AirQuantizationParameters | None = Field(default_factory=AirQuantizationParameters, description='Quantization parameters for the tensor')sparsity: AirSparsityParameters | None = Field(default_factory=AirSparsityParameters, description='Sparsity parameters for the tensor')buffer_index: int | None = Field(None, description='Index of the buffer this tensor is mapped to')local_name: str | None = Field(None, description='Local name for the tensor')shape_signature: tuple[int, ...] | None = Field(None, description='Shape signature of the tensor')has_rank: bool = Field(False, description='Indicates if the tensor has a rank')alias_of: TensorId | None = Field(None, description='Optional alias for this tensor')inferred_value: Array | None = Field(default=None, repr=False, description='Compile-time value that shape propagation computed for a shape-expression tensor: the output of a SHAPE, or of a STRIDED_SLICE or PACK over one. An operator still produces the tensor at run time, so this is not constant data; code that needs a constant reads `data`. FoldStaticShapeExpressions moves the value into `data` and removes the producing operator.')alignment_hint: int | None = Field(None, description='Alignment hint for the tensor in bytes')fixed_offset: int | None = Field(None, description="Mandatory arena-relative byte offset imposed by an external compiler (e.g. Vela's OfflineMemoryAllocation for an Ethos-U subgraph). When set, the memory planner must place this tensor at exactly this offset within its writable arena instead of choosing one, because the offset is baked into a command stream. Such tensors may intentionally overlap one another.")packed_from: TensorId | None = Field(None, description='Id of the tensor whose data a conversion-time repacking produced this one from. memory.tensors rules resolve against that id (see placement_id).')layout: str | None = Field(None, description='Weight layout of repacked data, e.g. NT_N_PACKED')shape: tuple[int, ...]dtype: np.dtypeReturn the data of the tensor.
data: npt.NDArray | NoneReturn the data of the tensor.
Quantization parameters, which must be present.
quant: AirQuantizationParametersQuantization parameters, which must be present.
quantization is Optional so a tensor can carry none; kernels that
require quantized inputs read through this view and get a clear error
naming the tensor instead of an attribute access on None.
Return the size of the tensor.
size: intReturn the size of the tensor.
Return the number of bytes in the tensor.
nbytes: intReturn the number of bytes in the tensor.
Return the number of dimensions of the tensor.
ndim: intReturn the number of dimensions of the tensor.
Check if the tensor is a constant.
is_constant: boolCheck if the tensor is a constant.
Check if the tensor is a persistent variable.
is_persistent: boolCheck if the tensor is a persistent variable.
Check if the tensor is a scratch tensor.
is_scratch: boolCheck if the tensor is a scratch tensor.
Id that memory.tensors rules match: the source id for a repacked copy.
placement_id: TensorIdId that memory.tensors rules match: the source id for a repacked copy.
name: strReturn the C type of the tensor.
ctype: strReturn the C type of the tensor.
This is used for generating C code that operates on the tensor. For example, if the tensor is of type int16, the C type will be int16_t.
Return the alignment floor based on the tensor's dtype.
dtype_alignment_floor: intReturn the alignment floor based on the tensor’s dtype.
Return a NHWC padded shape tuple, padding missing axes with 1.
get_shape_nhwc(pre: bool = True) -> tuple[int, int, int, int]Return a NHWC padded shape tuple, padding missing axes with 1.
get_shape_with_axis_expanded(axis: int) -> tuple[int, ...]