For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo struct
SMemTileArray
struct SMemTileArray[dtype: DType, shape_types: TypeList[shape_types.values], stride_types: TypeList[stride_types.values], num_tiles: Int, alignment: Int = 128]
Array of TileTensor tiles with variadic shape/stride type parameters.
This is the TileTensor equivalent of the LayoutTensor-based SMemTileArray in structuring.mojo. By taking shape_types and stride_types directly as variadic type parameters, this preserves full compile-time type information including swizzle patterns.
Example: comptime a_layout = internal_k_major[dtype, BM, BK, 128] comptime ATileArray = SMemTileArray[ dtype, a_layout.shape_types, a_layout.stride_types, num_pipeline_stages, ]
var array = ATileArray.stack_allocation() var tile = array[0] # Returns TileTensor with correct swizzled layout
Parametersβ
- βdtype (
DType): Tile element data type. - βshape_types (
TypeList[shape_types.values]): List of shape types from Layout (preserves compile-time info). - βstride_types (
TypeList[stride_types.values]): List of stride types from Layout (preserves compile-time info). - βnum_tiles (
Int): Number of tiles in the array. - βalignment (
Int): Memory alignment (default 128 for shared memory).
Fieldsβ
- βptr (
UnsafePointer[Scalar[dtype], MutAnyOrigin, address_space=AddressSpace.SHARED]):
Implemented traitsβ
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDestructible,
Movable,
RegisterPassable,
TrivialRegisterPassable
comptime membersβ
num_elementsβ
comptime num_elements = (SMemTileArray[dtype, shape_types, stride_types, num_tiles, alignment].tile_size * num_tiles)
Storageβ
comptime Storage = InlineArray[Scalar[dtype], SMemTileArray[dtype, shape_types, stride_types, num_tiles, alignment].num_elements]
storage_sizeβ
comptime storage_size = (SMemTileArray[dtype, shape_types, stride_types, num_tiles, alignment].num_elements * size_of[dtype]())
Tileβ
comptime Tile = TileTensor[dtype, Layout[shape_types, stride_types], MutAnyOrigin, address_space=AddressSpace.SHARED]
tile_sizeβ
comptime tile_size = Coord[*#kgen.param_list.concat(#kgen.param_list.tabulate(TypeList[#kgen.param_list.concat(#kgen.param_list.tabulate(TypeList[#kgen.param_list.concat(#kgen.param_list.tabulate(TypeList[#kgen.param_list.concat(#kgen.param_list.tabulate(TypeList[values], [idx: __mlir_type.index] values[idx]._ParamListType))], [idx: __mlir_type.index] #kgen.param_list.concat(#kgen.param_list.tabulate(TypeList[values], [idx: __mlir_type.index] values[idx]._ParamListType))[idx]._ParamListType))], [idx: __mlir_type.index] #kgen.param_list.concat(#kgen.param_list.tabulate(TypeList[#kgen.param_list.concat(#kgen.param_list.tabulate(TypeList[values], [idx: __mlir_type.index] values[idx]._ParamListType))], [idx: __mlir_type.index] #kgen.param_list.concat(#kgen.param_list.tabulate(TypeList[values], [idx: __mlir_type.index] values[idx]._ParamListType))[idx]._ParamListType))[idx]._ParamListType))], [idx: __mlir_type.index] #kgen.param_list.concat(#kgen.param_list.tabulate(TypeList[#kgen.param_list.concat(#kgen.param_list.tabulate(TypeList[#kgen.param_list.concat(#kgen.param_list.tabulate(TypeList[values], [idx: __mlir_type.index] values[idx]._ParamListType))], [idx: __mlir_type.index] #kgen.param_list.concat(#kgen.param_list.tabulate(TypeList[values], [idx: __mlir_type.index] values[idx]._ParamListType))[idx]._ParamListType))], [idx: __mlir_type.index] #kgen.param_list.concat(#kgen.param_list.tabulate(TypeList[#kgen.param_list.concat(#kgen.param_list.tabulate(TypeList[values], [idx: __mlir_type.index] values[idx]._ParamListType))], [idx: __mlir_type.index] #kgen.param_list.concat(#kgen.param_list.tabulate(TypeList[values], [idx: __mlir_type.index] values[idx]._ParamListType))[idx]._ParamListType))[idx]._ParamListType))[idx]._ParamListType))].static_product
TileLayoutβ
comptime TileLayout = Layout[shape_types, stride_types]
Methodsβ
__init__β
__init__(ref[AddressSpace._value] storage: InlineArray[Scalar[dtype], SMemTileArray[dtype, shape_types, stride_types, num_tiles, alignment].num_elements]) -> Self
Initialize from inline storage.
Args:
- βstorage (
InlineArray[Scalar[dtype], SMemTileArray[dtype, shape_types, stride_types, num_tiles, alignment].num_elements]): The inline storage array.
Returns:
Self: A new SMemTileArray pointing to the storage.
__init__(unsafe_ptr: UnsafePointer[Scalar[dtype], address_space=AddressSpace.SHARED]) -> Self
Initialize with a shared memory pointer.
Args:
- βunsafe_ptr (
UnsafePointer[Scalar[dtype], address_space=AddressSpace.SHARED]): Pointer to shared memory storage.
__getitem__β
__getitem__[T: Intable](self, index: T) -> SMemTileArray[dtype, shape_types, stride_types, num_tiles, alignment].Tile
Get tile at the given index.
Args:
- βindex (
T): The tile index.
Returns:
SMemTileArray[dtype, shape_types, stride_types, num_tiles, alignment].Tile: A TileTensor with correct swizzled layout at the given index.
sliceβ
slice[length: Int](self, start: Int) -> SMemTileArray[dtype, shape_types, stride_types, length, alignment]
Get a slice of the array.
Parameters:
- βlength (
Int): The length of the slice.
Args:
- βstart (
Int): The starting index.
Returns:
SMemTileArray[dtype, shape_types, stride_types, length, alignment]: A new SMemTileArray representing the slice.
stack_allocationβ
static stack_allocation() -> Self
Allocate the array on the stack (in shared memory).
Returns:
Self: A new SMemTileArray backed by stack-allocated shared memory.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!