For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo trait
StorageIO
Extends TensorEngine with element loads and stores that bypass unsafe_ptr.
Element-granular access normally goes through the raw pointer
unsafe_ptr returns. An engine whose storage has no such pointer, such
as a TPU memref, conforms to this trait instead, and TileTensor routes
every offset-based load and store through it: coordinate loads and
stores, element indexing, raw_load and raw_store, and fills. The
engine decides which widths it supports. TileIO is the whole-tile
counterpart, keyed by call shape rather than by trait: load() with no
coordinate is TileIO, t[i] is StorageIO.
Implemented traits
Required methods
load
static def load[mut: Bool, dtype: DType, origin: Origin[mut=mut], address_space: AddressSpace, //, width: SIMDLength, alignment: Int, invariant: Bool = False, non_temporal: Bool = False](storage: Self.StorageType[dtype, origin, address_space], offset: Int) -> SIMD[dtype, width]
Loads width elements starting at linear index offset.
Parameters:
- mut (
Bool): The mutability of the storage, inferred fromorigin. - dtype (
DType): The element data type of the storage. - origin (
Origin[mut=mut]): The origin tracking the lifetime of the storage. - address_space (
AddressSpace): The address space the storage resides in. - width (
SIMDLength): The number of elements to load. - alignment (
Int): The alignment of the access, in bytes. - invariant (
Bool): Whether the storage is unchanged for the kernel's lifetime, so the load may be hoisted or cached. - non_temporal (
Bool): Whether the data is not reused soon, so the access may bypass caches.
Args:
- storage (
Self.StorageType[dtype, origin, address_space]): The storage handle. - offset (
Int): The linear element index, as the layout computes it.
Returns:
SIMD[dtype, width]: The width elements at offset.
store
static def store[dtype: DType, origin: MutOrigin, address_space: AddressSpace, width: SIMDLength, //, alignment: Int, non_temporal: Bool = False](storage: Self.StorageType[dtype, origin, address_space], offset: Int, value: SIMD[dtype, width])
Stores value starting at linear index offset.
Parameters:
- dtype (
DType): The element data type of the storage. - origin (
MutOrigin): The origin tracking the lifetime of the storage. - address_space (
AddressSpace): The address space the storage resides in. - width (
SIMDLength): The number of elements to store, inferred fromvalue. - alignment (
Int): The alignment of the access, in bytes. - non_temporal (
Bool): Whether the data is not reused soon, so the access may bypass caches.
Args:
- storage (
Self.StorageType[dtype, origin, address_space]): The storage handle, modified in place. - offset (
Int): The linear element index, as the layout computes it. - value (
SIMD[dtype, width]): The elements to store.