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
dispatch_rdna_conv2d
def dispatch_rdna_conv2d[input_type: DType, filter_type: DType, output_type: DType, filter_is_fcrs: Bool, maybe_epilogue_func: Optional[def[dtype: DType, rank: Int, width: SIMDLength, alignment: Int = Int(1)](IndexList[rank], SIMD[dtype, width]) capturing thin -> None] = None, has_residual: Bool = False](input: TileTensor[input_type, Storage=input.Storage, address_space=input.address_space, linear_idx_type=input.linear_idx_type], filter: TileTensor[filter_type, Storage=filter.Storage, address_space=filter.address_space, linear_idx_type=filter.linear_idx_type], output: TileTensor[output_type, Storage=output.Storage, address_space=output.address_space, linear_idx_type=output.linear_idx_type], stride: IndexList[Int(2)], dilation: IndexList[Int(2)], symmetric_padding: IndexList[Int(2)], num_groups: Int, ctx: DeviceContext, source_ptr: Pointer[Scalar[output_type], MutAnyOrigin, _safe=False] = Pointer.unsafe_dangling(), beta: Float32 = 0) -> Bool
Try to dispatch Conv2D on RDNA via implicit GEMM (im2col fused into WMMA).
Returns True if the convolution was handled, False if the caller should fall back to another implementation (e.g. MIOpen).
Uses the implicit GEMM kernel when C_in is aligned to BLOCK_K (covers all FLUX VAE shapes), falling back to explicit im2col + matmul otherwise.
When has_residual=True, folds output = conv + beta * source into the
conv epilogue (the RDNA implicit-GEMM/im2col kernels have no native
residual path). source_ptr is NHWC-contiguous, same shape as output:
e.g. ResNet skip connections that the graph compiler fuses into the conv.
Parameters:
- βinput_type (
DType):DTypeof the input tensor elements. - βfilter_type (
DType):DTypeof the filter tensor elements. - βoutput_type (
DType):DTypeof the output tensor elements. - βfilter_is_fcrs (
Bool): True iffilteris laid out as FCRS, False for RSCF. - βmaybe_epilogue_func (
Optional[def[dtype: DType, rank: Int, width: SIMDLength, alignment: Int = Int(1)](IndexList[rank], SIMD[dtype, width]) capturing thin -> None]): Optional elementwise epilogue applied to each output element (defaults toNone). - βhas_residual (
Bool): True to fold a scaled residualbeta * source_ptrinto the conv epilogue (defaults toFalse).
Args:
- βinput (
TileTensor[input_type, Storage=input.Storage, address_space=input.address_space, linear_idx_type=input.linear_idx_type]): Rank-4 NHWC input tensor. - βfilter (
TileTensor[filter_type, Storage=filter.Storage, address_space=filter.address_space, linear_idx_type=filter.linear_idx_type]): Rank-4 filter tensor in FCRS or RSCF layout perfilter_is_fcrs. - βoutput (
TileTensor[output_type, Storage=output.Storage, address_space=output.address_space, linear_idx_type=output.linear_idx_type]): Rank-4 NHWC output tensor written by the convolution. - βstride (
IndexList[Int(2)]): Spatial stride[stride_h, stride_w]; only[1, 1]is supported. - βdilation (
IndexList[Int(2)]): Spatial dilation[dilation_h, dilation_w]; only[1, 1]is supported. - βsymmetric_padding (
IndexList[Int(2)]): Symmetric spatial padding[pad_h, pad_w]applied to the input. - βnum_groups (
Int): Number of convolution groups; only1is supported. - βctx (
DeviceContext):DeviceContextused to enqueue kernels and synchronize. - βsource_ptr (
Pointer[Scalar[output_type], MutAnyOrigin, _safe=False]): NHWC-contiguous residual source with the same shape asoutput; read only whenhas_residual=True(defaults to a dangling pointer). - βbeta (
Float32): Scale factor applied to the residual source whenhas_residual=True(defaults to0.0).
Returns:
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!