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

apple_matmul

def apple_matmul[EpilogueFnType: ElementwiseEpilogueFn, ComputeFnType: ElementwiseComputeFn, //, *, transpose_b: Bool = False, has_epilogue_fn: Bool, has_compute_fn: Bool](cblas_gemm_fn: def(_CBLASOrder, _CBLASTranspose, _CBLASTranspose, Int32, Int32, Int32, Float32, ImmPointer[Float32, ImmutAnyOrigin], Int32, ImmPointer[Float32, ImmutAnyOrigin], Int32, Float32, MutPointer[Float32, MutAnyOrigin], Int32) thin -> None, c: TileTensor[Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type], a: TileTensor[Engine=a.Engine, address_space=a.address_space, linear_idx_type=a.linear_idx_type], b: TileTensor[Engine=b.Engine, address_space=b.address_space, linear_idx_type=b.linear_idx_type], epilogue_fn: EpilogueFnType, compute_fn: ComputeFnType)

Performs a single-precision matmul via a pre-loaded cblas_sgemm function pointer.

Delegates to the Apple Accelerate cblas_sgemm routine using the supplied function handle, then applies the optional epilogue to the output tile. Requires all operands to be DType.float32.

Parameters:

  • ​EpilogueFnType (ElementwiseEpilogueFn): Type of epilogue_fn (inferred).
  • ​ComputeFnType (ElementwiseComputeFn): Type of compute_fn (inferred).
  • ​transpose_b (Bool): Whether to treat B as transposed.
  • ​has_epilogue_fn (Bool): Whether to apply epilogue_fn to the output after the matmul writes it.
  • ​has_compute_fn (Bool): Whether to store compute_fn of the output back into c after the matmul writes it.

Args:

def apple_matmul[*, transpose_b: Bool = False](c: TileTensor[Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type], a: TileTensor[Engine=a.Engine, address_space=a.address_space, linear_idx_type=a.linear_idx_type], b: TileTensor[Engine=b.Engine, address_space=b.address_space, linear_idx_type=b.linear_idx_type])

Performs a single-precision matmul via the Apple Accelerate library.

Loads cblas_sgemm from the Accelerate framework and delegates to apple_matmul with the function handle. Requires all operands to be DType.float32.

Parameters:

  • ​transpose_b (Bool): Whether to treat B as transposed.

Args:

def apple_matmul[EpilogueFnType: ElementwiseEpilogueFn, ComputeFnType: ElementwiseComputeFn, //, *, transpose_b: Bool = False, has_epilogue_fn: Bool, has_compute_fn: Bool](c: TileTensor[Engine=c.Engine, address_space=c.address_space, linear_idx_type=c.linear_idx_type], a: TileTensor[Engine=a.Engine, address_space=a.address_space, linear_idx_type=a.linear_idx_type], b: TileTensor[Engine=b.Engine, address_space=b.address_space, linear_idx_type=b.linear_idx_type], epilogue_fn: EpilogueFnType, compute_fn: ComputeFnType)

Performs a single-precision matmul via the Apple Accelerate library.

Loads cblas_sgemm from the Accelerate framework and delegates to apple_matmul with the function handle. Requires all operands to be DType.float32.

Parameters:

  • ​EpilogueFnType (ElementwiseEpilogueFn): Type of epilogue_fn (inferred).
  • ​ComputeFnType (ElementwiseComputeFn): Type of compute_fn (inferred).
  • ​transpose_b (Bool): Whether to treat B as transposed.
  • ​has_epilogue_fn (Bool): Whether to apply epilogue_fn to the output after the matmul writes it.
  • ​has_compute_fn (Bool): Whether to store compute_fn of the output back into c after the matmul writes it.

Args:

Was this page helpful?