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_types
Native TileTensor types for SM100 structured kernels.
This module provides TileTensor-based tile types for SM100 structured kernels. All SMEM storage uses TileTensor natively. TileTensors are passed directly to TMA and MMA via TileTensor overloads.
Usage:
# Create tile with a layout
comptime my_layout = row_major[64, 32]()
comptime MyTile = SMemTile[DType.float16, my_layout]
# TileTensors are passed directly to TMA/MMA
tma_op.async_copy(tile, barrier, coords)comptime values
GMEMLayout1D
comptime GMEMLayout1D = Layout[*(), *()]
1D layout for flat global memory arrays.
Shape is dynamic (Scalar), stride is 1 (ComptimeInt[1]). Rank is provably 1 at compile time.
GMEMTile
comptime GMEMTile[dtype: DType, tt_layout: TensorLayout] = TileTensor[dtype, tt_layout, MutAnyOrigin]
Global memory TileTensor for global memory kernel parameters.
Used for kernel parameter types, replacing LayoutTensor parameters.
Parameters
- dtype (
DType): - tt_layout (
TensorLayout):
internal_k_major
comptime internal_k_major[dtype: DType, BM: Int, BK: Int, swizzle_bytes: Int] = Layout(Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())), Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())))
Parameters
internal_k_major_128B
comptime internal_k_major_128B[dtype: DType, BM: Int, BK: Int] = Layout(Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())), Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())))
Parameters
internal_k_major_32B
comptime internal_k_major_32B[dtype: DType, BM: Int, BK: Int] = Layout(Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())), Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())))
Parameters
internal_k_major_64B
comptime internal_k_major_64B[dtype: DType, BM: Int, BK: Int] = Layout(Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())), Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())))
Parameters
internal_k_major_none
comptime internal_k_major_none[dtype: DType, BM: Int, BK: Int] = row_major[BM, BK]()
Parameters
internal_sf_k_major
comptime internal_sf_k_major[dim0: Int, dim1: Int] = Layout(Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(Coord(ComptimeInt(), ComptimeInt()), ComptimeInt())), Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(Coord(ComptimeInt(), ComptimeInt()), ComptimeInt())))
Parameters
sf_tile_dim0
sf_tile_dim1
comptime sf_tile_dim1[sf_bk: Int, vec_sf_size: Int] = ((sf_bk // (Int(4) * vec_sf_size)) * Int(16))
Parameters
SMemTile
comptime SMemTile[dtype: DType, layout: Layout[shape_types, stride_types], *, alignment: Int = Int(128)] = TileTensor[dtype, Layout[shape_types, stride_types], MutAnyOrigin, address_space=AddressSpace.SHARED]
Shared memory tile using TileTensor with a Layout.
The Layout parameter preserves swizzle information, enabling .to_layout_tensor() to produce correctly swizzled LayoutTensors.
Parameters
- dtype (
DType): The data type of tile elements. - layout (
Layout[shape_types, stride_types]): The full layout including swizzle information. - alignment (
Int): Memory alignment (default 128 for shared memory).
SMemTile2D
comptime SMemTile2D[dtype: DType, dim0: Int, dim1: Int, *, alignment: Int = Int(128)] = TileTensor[dtype, Layout[*(), *()], MutAnyOrigin, address_space=AddressSpace.SHARED]
Backward-compatible alias for SMemTile with explicit 2D dimensions.
Parameters
SMemTileShape
comptime SMemTileShape[idx: Int, Tile: TileTensor[dtype, LayoutType, origin, Storage=Storage, address_space=address_space, linear_idx_type=linear_idx_type]] = LayoutType.static_shape[idx]
Get compile-time shape value at index from a TileTensor type.
Returns: The static shape value, or -1 if runtime-determined.
Parameters
- idx (
Int): The dimension index. - Tile (
TileTensor[dtype, LayoutType, origin, Storage=Storage, address_space=address_space, linear_idx_type=linear_idx_type]): The TileTensor type (use type_of(tile)).
SMemTileStride
comptime SMemTileStride[idx: Int, Tile: TileTensor[dtype, LayoutType, origin, Storage=Storage, address_space=address_space, linear_idx_type=linear_idx_type]] = LayoutType.static_stride[idx]
Get compile-time stride value at index from a TileTensor type.
Returns: The static stride value, or -1 if runtime-determined.
Parameters
- idx (
Int): The dimension index. - Tile (
TileTensor[dtype, LayoutType, origin, Storage=Storage, address_space=address_space, linear_idx_type=linear_idx_type]): The TileTensor type (use type_of(tile)).
static_row_major
comptime static_row_major[dim0: Int, dim1: Int] = Layout[*(), *()]
2D row-major layout with fully static dimensions.
Equivalent to LegacyLayout.row_major(dim0, dim1) but using new Layout
types with rank=2 provable at compile time.
Parameters
swizzle_mode_to_bytes
comptime swizzle_mode_to_bytes[swizzle_mode: TensorMapSwizzle] = Int(128) if (swizzle_mode == TensorMapSwizzle.SWIZZLE_128B) else Int(64) if (swizzle_mode == TensorMapSwizzle.SWIZZLE_64B) else Int(32) if (swizzle_mode == TensorMapSwizzle.SWIZZLE_32B) else Int(16)
Convert TensorMapSwizzle enum to swizzle size in bytes.
SWIZZLE_NONE returns 16, matching TensorMapSwizzle.bytes()
(formula: (2**value) * 16, value=0 gives 16).
Returns: The swizzle size in bytes (16, 32, 64, or 128).
Parameters
- swizzle_mode (
TensorMapSwizzle): The TensorMapSwizzle enum value.
tma_desc_layout_2d
comptime tma_desc_layout_2d[dtype: DType, tile_dim0: Int, swizzle: TensorMapSwizzle] = Layout[*(), *()]
2D TMA descriptor layout: [dim0, swizzle_elems], strides [1, 1].
Parameters
- dtype (
DType): - tile_dim0 (
Int): - swizzle (
TensorMapSwizzle):
tma_desc_layout_3d
comptime tma_desc_layout_3d[dtype: DType, tile_dim0: Int, tile_dim1: Int, swizzle: TensorMapSwizzle] = Layout[*(), *()]
3D TMA descriptor layout: [dim0, dim1, swizzle_elems], strides [1,1,1].
Parameters
- dtype (
DType): - tile_dim0 (
Int): - tile_dim1 (
Int): - swizzle (
TensorMapSwizzle):
tma_desc_layout_3d_explicit_inner
comptime tma_desc_layout_3d_explicit_inner[tile_dim0: Int, tile_dim1: Int, inner_elems: Int] = Layout[*(), *()]
3D TMA descriptor layout with explicit innermost dim (in elements).
Parameters
tma_desc_layout_4d
comptime tma_desc_layout_4d[dtype: DType, tile_dim0: Int, tile_dim1: Int, tile_dim2: Int, swizzle: TensorMapSwizzle] = Layout[*(), *()]
4D TMA descriptor layout: [d0,d1,d2,swizzle_elems], strides all 1.
Parameters
- dtype (
DType): - tile_dim0 (
Int): - tile_dim1 (
Int): - tile_dim2 (
Int): - swizzle (
TensorMapSwizzle):
tma_desc_layout_5d
comptime tma_desc_layout_5d[dtype: DType, tile_dim0: Int, tile_dim1: Int, tile_dim2: Int, tile_dim3: Int, swizzle: TensorMapSwizzle] = Layout[*(), *()]
5D TMA descriptor layout: [d0,d1,d2,d3,swizzle_elems], strides all 1.
Parameters
TmaOpType
comptime TmaOpType[dtype: DType, tile_layout: TensorLayout, desc_layout: TensorLayout] = TMATensorTile[dtype, tile_layout.rank, _to_index_list[tile_layout](), _to_index_list[tile_layout.rank, desc_layout]()]
TMATensorTile type derived from new Layout types.
Single source of truth: new Layout types determine the TMATensorTile type parameters via _to_index_list.
Parameters
- dtype (
DType): - tile_layout (
TensorLayout): - desc_layout (
TensorLayout):
TmaOpTypeIm2col
comptime TmaOpTypeIm2col[dtype: DType, tile_layout: TensorLayout, desc_layout: TensorLayout] = TMATensorTileIm2col[dtype, tile_layout.rank, _to_index_list[tile_layout](), _to_index_list[tile_layout.rank, desc_layout]()]
TMATensorTileIm2col type derived from new Layout types.
Same as TmaOpType but for im2col TMA (used by conv2d activation loads).
Parameters
- dtype (
DType): - tile_layout (
TensorLayout): - desc_layout (
TensorLayout):
Structs
-
SMemTileArray: Array of TileTensor tiles with variadic shape/stride type parameters. -
SMemTileArray2D: Array of TileTensor tiles in shared memory with swizzled K-major layout. -
SMemTileArray2DRowMajor: Array of TileTensor tiles in shared memory with row_major layout. -
SMemTileArrayWithLayout: Array of TileTensor tiles with explicit Layout (preserves swizzle info).
Traits
-
TilePayload: Trait for tile payload types. Must be extend TrivialRegisterPassable.
Functions
-
create_tma_tile: Create a TMATensorTile using new Layout types.