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

matmul

def matmul[*, transpose_b: Bool = False, b_packed: Bool = False, saturated_vnni: Bool = False](c: TileTensor[Engine=c.Engine, linear_idx_type=c.linear_idx_type], a: TileTensor[Engine=a.Engine, linear_idx_type=a.linear_idx_type], b: TileTensor[Engine=b.Engine, linear_idx_type=b.linear_idx_type], kernel_type_m: Int, num_threads: Int = Int(-1), ctx: Optional[DeviceContext[CompilationTarget()]] = None)

TileTensor matmul dispatcher. Selects kernel type and delegates to _matmul_cpu_impl.

Parameters:

  • ​transpose_b (Bool): Whether the B operand is transposed (defaults to False).
  • ​b_packed (Bool): Whether B was pre-packed offline in the cache-friendly layout (defaults to False).
  • ​saturated_vnni (Bool): When True, uses the saturating x86 variant, which requires the a operand to lie in [0, 127]; it saves instructions only on the AVX2 emulation path used when the target lacks VNNI (defaults to False).

Args:

def matmul[EpilogueFnType: ElementwiseEpilogueFn, //, *, transpose_b: Bool = False, b_packed: Bool = False, saturated_vnni: Bool = False](c: TileTensor[Engine=c.Engine, linear_idx_type=c.linear_idx_type], a: TileTensor[Engine=a.Engine, linear_idx_type=a.linear_idx_type], b: TileTensor[Engine=b.Engine, linear_idx_type=b.linear_idx_type], epilogue_fn: EpilogueFnType, kernel_type_m: Int, num_threads: Int = Int(-1), ctx: Optional[DeviceContext[CompilationTarget()]] = None)

TileTensor matmul dispatcher with a fused elementwise epilogue.

The kernel accumulates into c, then calls epilogue_fn with the (m, n) coordinates and value of each finished output chunk.

Parameters:

  • ​EpilogueFnType (ElementwiseEpilogueFn): Type of epilogue_fn (inferred).
  • ​transpose_b (Bool): Whether the B operand is transposed (defaults to False).
  • ​b_packed (Bool): Whether B was pre-packed offline in the cache-friendly layout (defaults to False).
  • ​saturated_vnni (Bool): When True, uses the saturating x86 variant, which requires the a operand to lie in [0, 127]; it saves instructions only on the AVX2 emulation path used when the target lacks VNNI (defaults to False).

Args:

def matmul[ComputeFnType: ElementwiseComputeFn, //, *, transpose_b: Bool = False, b_packed: Bool = False, saturated_vnni: Bool = False](c: TileTensor[Engine=c.Engine, linear_idx_type=c.linear_idx_type], a: TileTensor[Engine=a.Engine, linear_idx_type=a.linear_idx_type], b: TileTensor[Engine=b.Engine, linear_idx_type=b.linear_idx_type], compute_fn: ComputeFnType, kernel_type_m: Int, num_threads: Int = Int(-1), ctx: Optional[DeviceContext[CompilationTarget()]] = None)

TileTensor matmul dispatcher with a fused elementwise compute epilogue.

The kernel accumulates into c, then stores compute_fn of each finished output chunk back into c, so compute_fn never needs to capture c.

Parameters:

  • ​ComputeFnType (ElementwiseComputeFn): Type of compute_fn (inferred).
  • ​transpose_b (Bool): Whether the B operand is transposed (defaults to False).
  • ​b_packed (Bool): Whether B was pre-packed offline in the cache-friendly layout (defaults to False).
  • ​saturated_vnni (Bool): When True, uses the saturating x86 variant, which requires the a operand to lie in [0, 127]; it saves instructions only on the AVX2 emulation path used when the target lacks VNNI (defaults to False).

Args:

Was this page helpful?