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_batched_matmul

def apple_batched_matmul[rank: Int, *, 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], c_shape_idx: IndexList[rank])

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

Iterates over all batch dimensions (all axes except the last two), calling apple_matmul for each 2D slice. Requires at least rank-3 tensors and all operands to be DType.float32.

Parameters:

  • ​rank (Int): The rank of the output tensor (must be >= 3).
  • ​transpose_b (Bool): Whether to treat B as transposed.

Args:

def apple_batched_matmul[rank: Int, EpilogueFnType: ElementwiseEpilogueFn, //, *, 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], c_shape_idx: IndexList[rank], epilogue_fn: EpilogueFnType)

Performs a batched single-precision matmul via the Apple Accelerate library, then applies epilogue_fn to the output.

epilogue_fn receives rank-rank coordinates in the original (uncollapsed) output shape.

Parameters:

  • ​rank (Int): The rank of the output tensor (must be >= 3).
  • ​EpilogueFnType (ElementwiseEpilogueFn): Type of epilogue_fn (inferred).
  • ​transpose_b (Bool): Whether to treat B as transposed.

Args:

def apple_batched_matmul[rank: Int, ComputeFnType: ElementwiseComputeFn, //, *, 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], c_shape_idx: IndexList[rank], compute_fn: ComputeFnType)

Performs a batched single-precision matmul via the Apple Accelerate library, storing compute_fn(idx, value) into c.

compute_fn receives rank-rank coordinates in the original (uncollapsed) output shape.

Parameters:

  • ​rank (Int): The rank of the output tensor (must be >= 3).
  • ​ComputeFnType (ElementwiseComputeFn): Type of compute_fn (inferred).
  • ​transpose_b (Bool): Whether to treat B as transposed.

Args:

Was this page helpful?