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 function
conv2d_kernel_rdna
def conv2d_kernel_rdna[out_type: DType, in_type: DType, filter_type: DType, out_layout: TensorLayout, filter_nk_layout: TensorLayout, elementwise_lambda_fn: Optional[def[dtype: DType, width: SIMDLength, *, alignment: Int = Int(1)](IndexList[Int(2)], SIMD[dtype, width]) capturing thin -> None] = None, s_type: DType = get_accum_type[out_type](), BLOCK_K: Int = Int(32), BLOCK_M: Int = Int(128), BLOCK_N: Int = Int(128), WARPS_M: Int = Int(8), WARPS_N: Int = Int(2), WARP_TILE_M: Int = Int(1), WARP_TILE_N: Int = Int(4)](output: TileTensor[out_type, out_layout, MutAnyOrigin], input_ptr: Pointer[Scalar[in_type], ImmutAnyOrigin, _safe=False], filter_nk: TileTensor[filter_type, filter_nk_layout, MutAnyOrigin], M: Int, N: Int, K: Int, HW_out: Int, W_out: Int, H_in: Int, W_in: Int, C_in: Int, R: Int, S: Int, pad_h: Int, pad_w: Int)
Conv2D implicit GEMM kernel for RDNA 3+ GPUs.
Identical to the RDNA WMMA matmul kernel except the A-tile is loaded directly from the NHWC input with on-the-fly im2col coordinate computation, eliminating the intermediate im2col buffer.
The B-tile (filter) must be pre-transposed to [N, K] = [C_out, RSC_in] layout for vectorized loading with transpose_b=True semantics.
Output [M, N] in row-major maps directly to NHWC output.
Constraints (enforced by the dispatch layer):
- stride = (1, 1) and dilation = (1, 1)
- K % BLOCK_K == 0 and C_in % BLOCK_K == 0
Parameters:
- βout_type (
DType):DTypeof the output tensor. - βin_type (
DType):DTypeof the input activation tensor. - βfilter_type (
DType):DTypeof the filter tensor. - βout_layout (
TensorLayout):TensorLayoutof the outputTileTensor. - βfilter_nk_layout (
TensorLayout):TensorLayoutof the pre-transposed [N, K] filterTileTensor. - βelementwise_lambda_fn (
Optional[def[dtype: DType, width: SIMDLength, *, alignment: Int = Int(1)](IndexList[Int(2)], SIMD[dtype, width]) capturing thin -> None]): Optional fused epilogue lambda applied per output element (defaults toNone). - βs_type (
DType):DTypeused for the accumulator (defaults to the accumulator type forout_type). - βBLOCK_K (
Int): Tile size along the K reduction dimension (defaults to 32). - βBLOCK_M (
Int): Tile size along the M output-row dimension (defaults to 128). - βBLOCK_N (
Int): Tile size along the N output-column dimension (defaults to 128). - βWARPS_M (
Int): Number of warps tiling the M dimension (defaults to 8). - βWARPS_N (
Int): Number of warps tiling the N dimension (defaults to 2). - βWARP_TILE_M (
Int): MMA tiles per warp along M (defaults to 1). - βWARP_TILE_N (
Int): MMA tiles per warp along N (defaults to 4).
Args:
- βoutput (
TileTensor[out_type, out_layout, MutAnyOrigin]): OutputTileTensorof shape [M, N] in row-major, mapping to NHWC output. - βinput_ptr (
Pointer[Scalar[in_type], ImmutAnyOrigin, _safe=False]): Pointer to the NHWC input activation tensor ofin_type. - βfilter_nk (
TileTensor[filter_type, filter_nk_layout, MutAnyOrigin]): FilterTileTensorpre-transposed to [N, K] = [C_out, RSC_in] layout. - βM (
Int): Number of output rows; equals batch * H_out * W_out. - βN (
Int): Number of output columns; equals C_out. - βK (
Int): Reduction dimension length; equals R * S * C_in. - βHW_out (
Int): Product of output spatial dimensions H_out * W_out. - βW_out (
Int): Output spatial width. - βH_in (
Int): Input spatial height. - βW_in (
Int): Input spatial width. - βC_in (
Int): Number of input channels. - βR (
Int): Filter height. - βS (
Int): Filter width. - βpad_h (
Int): Zero padding applied to the input height. - βpad_w (
Int): Zero padding applied to the input width.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!