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 module
tile_tensor
TileTensor type for structured memory access with compile-time layout information.
comptime values
ImmTileTensor
comptime ImmTileTensor[dtype: DType, LayoutType: TensorLayout, origin: ImmOrigin, *, Engine: TensorEngine = DefaultEngine, address_space: AddressSpace = .GENERIC, linear_idx_type: DType = _get_index_type[LayoutType](address_space)] = TileTensor[dtype, LayoutType, origin, Engine=Engine, address_space=address_space, linear_idx_type=linear_idx_type]
Names a TileTensor over immutable storage.
TileTensor infers its mut parameter from origin, so a declaration that
must accept only read-only views has to bind and constrain mut itself. This
alias restricts origin to ImmOrigin instead, leaving the mutability spelled
in the type. See MutTileTensor for the mutable counterpart.
Parameters
- dtype (
DType): The data type of tensor elements (e.g.,DType.float32). - LayoutType (
TensorLayout): A type implementingTensorLayoutthat defines the tensor's shape and stride structure. - origin (
ImmOrigin): The immutable origin of the underlying pointer. - Engine (
TensorEngine): A type implementingTensorEnginethat supplies the storage handle and the load/store/offset operations acting on it. Defaults toDefaultEngine[element_width=1]. - address_space (
AddressSpace): Memory address space (GENERIC, SHARED, CONSTANT, etc.). Defaults to GENERIC. - linear_idx_type (
DType): Integer type for memory indexing. Defaults to int32 for shared/constant memory, int64 otherwise.
LTToTTLayout
comptime LTToTTLayout[lt_layout: Layout] = Layout[TypeList[#kgen.param_list.tabulate(len[IntTuple](product_each(lt_layout.shape)), [idx: __mlir_type.index] ComptimeInt[SIMD[IntTuple](product_each(lt_layout.shape)[Int(idx)])] if (xor identical(SIMD[IntTuple](product_each(lt_layout.shape)[Int(idx)]), -1), True) else Int64)](), TypeList[#kgen.param_list.tabulate(len[IntTuple](product_each(lt_layout.stride)), [idx: __mlir_type.index] ComptimeInt[SIMD[IntTuple](product_each(lt_layout.stride)[Int(idx)])] if (xor identical(SIMD[IntTuple](product_each(lt_layout.stride)[Int(idx)]), -1), True) else Int64)]()]
Derive a TileTensor Layout from a legacy Layout.
Known dimensions become ComptimeInt, UNKNOWN_VALUE dimensions become
Scalar. Hierarchical layouts (e.g. from tile_to_shape) are
collapsed via product_each so each mode becomes a single value.
Parameters
- lt_layout (
Layout): The legacy Layout to convert.
MutTileTensor
comptime MutTileTensor[dtype: DType, LayoutType: TensorLayout, origin: MutOrigin, *, Engine: TensorEngine = DefaultEngine, address_space: AddressSpace = .GENERIC, linear_idx_type: DType = _get_index_type[LayoutType](address_space)] = TileTensor[dtype, LayoutType, origin, Engine=Engine, address_space=address_space, linear_idx_type=linear_idx_type]
Names a TileTensor over mutable storage.
The mutable counterpart of ImmTileTensor: origin is restricted to
MutOrigin, so the view is writable without the declaration having to bind
TileTensor's inferred mut parameter.
Parameters
- dtype (
DType): The data type of tensor elements (e.g.,DType.float32). - LayoutType (
TensorLayout): A type implementingTensorLayoutthat defines the tensor's shape and stride structure. - origin (
MutOrigin): The mutable origin of the underlying pointer. - Engine (
TensorEngine): A type implementingTensorEnginethat supplies the storage handle and the load/store/offset operations acting on it. Defaults toDefaultEngine[element_width=1]. - address_space (
AddressSpace): Memory address space (GENERIC, SHARED, CONSTANT, etc.). Defaults to GENERIC. - linear_idx_type (
DType): Integer type for memory indexing. Defaults to int32 for shared/constant memory, int64 otherwise.
Structs
-
NullableTileTensor: A TileTensor variant whose pointer may be absent (null). -
TileTensor: A tensor type with trait-based layouts supporting nested and hierarchical indexing.
Functions
-
flatten_leading: Merge the first two dimensions of a rank-3 TileTensor: (A, B, C) -> (A*B, C). -
lt_to_tt: Convert a LayoutTensor to a TileTensor. -
lt_to_tt_idx: Likelt_to_ttbut with an explicitlinear_idx_typeoverride. -
stack_allocation: Allocate a TileTensor on the stack with the given layout.