Skip to main content

Mojo struct

RaggedMHAOperand

@register_passable(trivial) struct RaggedMHAOperand[dtype_: DType, shape: DimList, stride: DimList]

An implementation for ragged NDBuffer arguments to MHA kernels.

Fields

  • buffer (NDBuffer[dtype_, 3, MutableAnyOrigin, shape, stride]):
  • cache_row_offsets (NDBuffer[uint32, 1, MutableAnyOrigin]):

Implemented traits

AnyType, Copyable, ExplicitlyCopyable, MHAOperand, Movable, UnknownDestructibility

Aliases

dtype

alias dtype = dtype_

Methods

__init__

__init__(buffer: NDBuffer[dtype_, 3, MutableAnyOrigin, shape, stride], cache_row_offsets: NDBuffer[uint32, 1, MutableAnyOrigin, shape, strides]) -> Self

block_paged_ptr

block_paged_ptr[tile_size: Int](self, batch_idx: SIMD[uint32, 1], start_tok_idx: SIMD[uint32, 1], head_idx: SIMD[uint32, 1], head_dim_idx: SIMD[uint32, 1] = 0) -> UnsafePointer[SIMD[dtype_, 1]]

Returns:

UnsafePointer

cache_length

cache_length(self, batch_idx: Int) -> Int

Returns:

Int

max_context_length

max_context_length(self) -> SIMD[uint32, 1]

Returns:

SIMD

row_idx

row_idx(self, batch_idx: SIMD[uint32, 1], start_tok_idx: SIMD[uint32, 1]) -> SIMD[uint32, 1]

Returns the row idx when viewing the memory as a matrix.

Returns:

SIMD

col_idx

col_idx(self, head_idx: SIMD[uint32, 1]) -> SIMD[uint32, 1]

Returns the col idx when viewing the memory as a matrix.

Returns:

SIMD

create_tma_tile

create_tma_tile[tile_m: Int, tile_n: Int, swizzle_mode: TensorMapSwizzle, *, is_k_major: Bool](self, ctx: DeviceContext) -> TMATensorTile[dtype_, tile_layout_k_major[::DType,::Int,::Int,::TensorMapSwizzle]() if is_k_major else tile_layout_mn_major[::DType,::Int,::Int,::TensorMapSwizzle](), _tma_desc_tile_layout[::DType,::Int,::IndexList[$1, ::DType(), is_k_major]

Creates a TMA tile for efficient GPU memory transfers.

Returns:

TMATensorTile

Was this page helpful?