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
apple_matmul
def apple_matmul[*, transpose_b: Bool = False, elementwise_lambda_fn: Optional[def[dtype: DType, width: SIMDLength, *, alignment: Int = Int(1)](IndexList[Int(2)], SIMD[dtype, width]) capturing thin -> None] = None](cblas_gemm_fn: def(_CBLASOrder, _CBLASTranspose, _CBLASTranspose, Int32, Int32, Int32, Float32, Pointer[Float32, ImmutAnyOrigin, _safe=False], Int32, Pointer[Float32, ImmutAnyOrigin, _safe=False], Int32, Float32, Pointer[Float32, MutAnyOrigin, _safe=False], Int32) thin -> None, c: TileTensor[Storage=c.Storage, address_space=c.address_space, linear_idx_type=c.linear_idx_type], a: TileTensor[Storage=a.Storage, address_space=a.address_space, linear_idx_type=a.linear_idx_type], b: TileTensor[Storage=b.Storage, address_space=b.address_space, linear_idx_type=b.linear_idx_type])
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:
- βtranspose_b (
Bool): Whether to treat B as transposed. - βelementwise_lambda_fn (
Optional[def[dtype: DType, width: SIMDLength, *, alignment: Int = Int(1)](IndexList[Int(2)], SIMD[dtype, width]) capturing thin -> None]): Optional epilogue applied element-wise to output.
Args:
- βcblas_gemm_fn (
def(_CBLASOrder, _CBLASTranspose, _CBLASTranspose, Int32, Int32, Int32, Float32, Pointer[Float32, ImmutAnyOrigin, _safe=False], Int32, Pointer[Float32, ImmutAnyOrigin, _safe=False], Int32, Float32, Pointer[Float32, MutAnyOrigin, _safe=False], Int32) thin -> None): Pre-loadedcblas_sgemmfunction handle from the Accelerate library. - βc (
TileTensor[Storage=c.Storage, address_space=c.address_space, linear_idx_type=c.linear_idx_type]): Output matrix tile. - βa (
TileTensor[Storage=a.Storage, address_space=a.address_space, linear_idx_type=a.linear_idx_type]): Input A matrix tile. - βb (
TileTensor[Storage=b.Storage, address_space=b.address_space, linear_idx_type=b.linear_idx_type]): Input B matrix tile.
def apple_matmul[*, transpose_b: Bool = False, 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[Storage=c.Storage, address_space=c.address_space, linear_idx_type=c.linear_idx_type], a: TileTensor[Storage=a.Storage, address_space=a.address_space, linear_idx_type=a.linear_idx_type], b: TileTensor[Storage=b.Storage, 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. - βelementwise_lambda_fn (
Optional[def[dtype: DType, width: SIMDLength, *, alignment: Int = Int(1)](IndexList[Int(2)], SIMD[dtype, width]) capturing thin -> None]): Optional epilogue applied element-wise to output.
Args:
- βc (
TileTensor[Storage=c.Storage, address_space=c.address_space, linear_idx_type=c.linear_idx_type]): Output matrix tile. - βa (
TileTensor[Storage=a.Storage, address_space=a.address_space, linear_idx_type=a.linear_idx_type]): Input A matrix tile. - βb (
TileTensor[Storage=b.Storage, address_space=b.address_space, linear_idx_type=b.linear_idx_type]): Input B matrix tile.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!