This document is relevant for: Trn2, Trn3
nki.language.grid_element_offset#
- nki.language.grid_element_offset(offset: int | NkiTensor | NkiScalar | VirtualRegister) GridElementOffset[source]#
Interpret one grid key as a source-axis element offset.
Ordinary integer keys are coordinates at the current grid level and are scaled by
NkiGrid.index_step_elements. This marker identifies a value that is already in source-element units, so it is not scaled again. The bracket position chooses the dimension, and the value remains relative to the current grid view.Static offsets must be nonnegative, aligned to the current grid step, and within the selected extent. Runtime offsets may be
int32oruint32SBUF scalar tensors, scalar register values, or virtual registers; their alignment and bounds remain kernel obligations.NkiScalaroffsets may beint32orint64for HBM grids, but must beint32for SBUF grids.- Parameters:
offset β Static source-element offset or supported runtime scalar.
- Returns:
Marker consumed by
NkiGrid.__getitem__().- Raises:
TypeError β if the value is a boolean or unsupported runtime value.
ValueError β if a static value is negative or a runtime tensor is not scalar-shaped.
Example:
src_tiles = nl.tiles(src, tile_shape=(128, 256)) src_tile = src_tiles[ nl.grid_element_offset(offset_sbuf), 0, ]
This document is relevant for: Trn2, Trn3