IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo function

multistage_gemm

def multistage_gemm[c_type: DType, a_type: DType, b_type: DType, //, *, transpose_b: Bool, config: MatmulConfig[a_type, b_type, c_type, transpose_b], elementwise_lambda_fn: Optional[def[dtype: DType, width: SIMDLength, *, alignment: Int = Int(1)](IndexList[Int(2)], SIMD[dtype, width]) capturing thin -> None] = None](c: TileTensor[c_type, Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type], a: TileTensor[a_type, Engine=a.Engine, address_space=a.address_space, linear_idx_type=a.linear_idx_type], b: TileTensor[b_type, Engine=b.Engine, address_space=b.address_space, linear_idx_type=b.linear_idx_type], ctx: DeviceContext)

TileTensor overload of multistage_gemm. Converts to LayoutTensor and dispatches to a GEMM kernel.

Parameters:

Args:

def multistage_gemm[c_type: DType, a_type: DType, b_type: DType, EpilogueFnType: ElementwiseEpilogueFn, //, *, transpose_b: Bool, config: MatmulConfig[a_type, b_type, c_type, transpose_b]](c: TileTensor[c_type, Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type], a: TileTensor[a_type, Engine=a.Engine, address_space=a.address_space, linear_idx_type=a.linear_idx_type], b: TileTensor[b_type, Engine=b.Engine, address_space=b.address_space, linear_idx_type=b.linear_idx_type], epilogue_fn: EpilogueFnType, ctx: DeviceContext)

Runs multistage_gemm, storing the output through an epilogue closure value.

Only the AMD CDNA transpose_b kernels support this overload.

Parameters:

  • ​c_type (DType): DType of the output tile c elements (inferred).
  • ​a_type (DType): DType of the input tile a elements (inferred).
  • ​b_type (DType): DType of the input tile b elements (inferred).
  • ​EpilogueFnType (ElementwiseEpilogueFn): Type of epilogue_fn (inferred).
  • ​transpose_b (Bool): Whether b is stored as (N, K). Must be True.
  • ​config (MatmulConfig[a_type, b_type, c_type, transpose_b]): Compile-time MatmulConfig selecting the block tile, warp tile, MMA shape, and pipeline stages for the kernel.

Args:

def multistage_gemm[c_type: DType, a_type: DType, b_type: DType, //, *, transpose_b: Bool, config: MatmulConfig[a_type, b_type, c_type, transpose_b], elementwise_lambda_fn: Optional[def[dtype: DType, width: SIMDLength, *, alignment: Int = Int(1)](IndexList[Int(2)], SIMD[dtype, width]) capturing thin -> None] = None](c: TileTensor[c_type, Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type], a: TileTensor[a_type, Engine=a.Engine, address_space=a.address_space, linear_idx_type=a.linear_idx_type], b: TileTensor[b_type, Engine=b.Engine, address_space=b.address_space, linear_idx_type=b.linear_idx_type], runtime_config: MatmulConfig[a_type, b_type, c_type, transpose_b], ctx: DeviceContext)

TileTensor overload of multistage_gemm with runtime config. Constrains c to mut=True because split_k_reduce requires a mutable output tensor.

Parameters:

Args:

def multistage_gemm[c_type: DType, a_type: DType, b_type: DType, EpilogueFnType: ElementwiseEpilogueFn, //, *, transpose_b: Bool, config: MatmulConfig[a_type, b_type, c_type, transpose_b]](c: TileTensor[c_type, Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type], a: TileTensor[a_type, Engine=a.Engine, address_space=a.address_space, linear_idx_type=a.linear_idx_type], b: TileTensor[b_type, Engine=b.Engine, address_space=b.address_space, linear_idx_type=b.linear_idx_type], runtime_config: MatmulConfig[a_type, b_type, c_type, transpose_b], epilogue_fn: EpilogueFnType, ctx: DeviceContext)

Runs multistage_gemm with runtime config, storing the output through an epilogue closure value.

Only the AMD CDNA transpose_b kernels support this overload.

Parameters:

  • ​c_type (DType): DType of the output tile c elements (inferred).
  • ​a_type (DType): DType of the input tile a elements (inferred).
  • ​b_type (DType): DType of the input tile b elements (inferred).
  • ​EpilogueFnType (ElementwiseEpilogueFn): Type of epilogue_fn (inferred).
  • ​transpose_b (Bool): Whether b is stored as (N, K). Must be True.
  • ​config (MatmulConfig[a_type, b_type, c_type, transpose_b]): Compile-time MatmulConfig selecting the block tile, warp tile, MMA shape, and pipeline stages for the kernel.

Args:

Was this page helpful?