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_gemv

def apple_gemv[EpilogueFnType: ElementwiseEpilogueFn, ComputeFnType: ElementwiseComputeFn, //, *, b_packed: Bool, transpose_b: Bool = False, has_epilogue_fn: Bool, has_compute_fn: Bool](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, compute_fn: ComputeFnType, ctx: Optional[DeviceContext[CompilationTarget()]] = None)

Performs a parallelized and vectorized GEMV for the M=1 case on Apple CPUs.

Used as an alternative to apple_matmul when M=1 and the Apple Accelerate cblas_sgemm path exhibits suboptimal performance for single-row inputs. Iterates over columns of B using SIMD FMA and optional parallelism.

Parameters:

  • ​EpilogueFnType (ElementwiseEpilogueFn): Type of epilogue_fn (inferred).
  • ​ComputeFnType (ElementwiseComputeFn): Type of compute_fn (inferred).
  • ​b_packed (Bool): Whether B is already in packed (transposed) layout.
  • ​transpose_b (Bool): Whether to treat B as transposed.
  • ​has_epilogue_fn (Bool): Whether to hand each output element to epilogue_fn instead of storing it to c.
  • ​has_compute_fn (Bool): Whether to store compute_fn of each output element to c.

Args:

Was this page helpful?