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
BTileGenerator
struct BTileGenerator[config: KernelConfig, a_type: DType, b_type: DType, c_type: DType, b_layout: TensorLayout, transpose_b: Bool, b_packed: Bool, origin: ImmOrigin]
Struct to encapsulate a tile of B that supports prepacking.
If b_packed is true, calls to get_tile will return a buffer view from B. Otherwise, calls to get_tile will copy a tile from B into a stack allocated scratch buffer and return a view of that.
Parametersβ
- βconfig (
KernelConfig): Kernel configuration supplyingsimd_sizeandkernel_colsused by the packing routines. - βa_type (
DType): Element type of the A operand of the matmul. - βb_type (
DType): Element type of the B operand being packed. - βc_type (
DType): Element type of the C output of the matmul. - βb_layout (
TensorLayout): Layout of the BTileTensor. - βtranspose_b (
Bool): True if the B operand is transposed, stored as [N, K]. - βb_packed (
Bool): True if B is already pre-packed into the mlas layout. - βorigin (
ImmOrigin): Origin of the BTileTensor.
Fieldsβ
- βb (
TileTensor[b_type, b_layout, origin]): - βb_tile_stack_ptr (
Pointer[Scalar[b_type], MutUntrackedOrigin, _safe=False]): - βtile_n_k (
IndexList[Int(2)]):
Implemented traitsβ
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDeletable,
Movable
comptime membersβ
PackedTileLayoutβ
comptime PackedTileLayout = Layout[*?, *?]
Methodsβ
getβ
static def get(b: TileTensor[b_type, b_layout, origin], tile_n_k: IndexList[Int(2)]) -> Self
get_tileβ
def get_tile[inner_size: Int](self, global_offset: GemmShape, tile_dim_nk: IndexList[Int(2)], valid_data_dim_nk: IndexList[Int(2)]) -> TileTensor[b_type, Layout[*?, *?], ImmutAnyOrigin]
Get a packed matrix (B) tile.
valid_data_tile_nk is ignored for pre-packing, where the tile is padded to have shape of tile_dim_nk.
Parameters:
- βinner_size (
Int): Size of the inner dimension along N in the packed tile; must be a multiple ofsimd_size.
Args:
- βglobal_offset (
GemmShape): Offset in the global M, N, K dimensions. - βtile_dim_nk (
IndexList[Int(2)]): Tile shape based on cache size and matrix dimensions. - βvalid_data_dim_nk (
IndexList[Int(2)]): The upper bounds for N and K dimensions.
Returns:
TileTensor[b_type, Layout[*?, *?], ImmutAnyOrigin]: A view of the packed tile.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!