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 ofepilogue_fn(inferred). - ComputeFnType (
ElementwiseComputeFn): Type ofcompute_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 toepilogue_fninstead of storing it toc. - has_compute_fn (
Bool): Whether to storecompute_fnof each output element toc.
Args:
- c (
TileTensor[Engine=c.Engine, linear_idx_type=c.linear_idx_type]): Output matrix tile (M=1). - a (
TileTensor[Engine=a.Engine, linear_idx_type=a.linear_idx_type]): Input A matrix tile (M=1). - b (
TileTensor[Engine=b.Engine, linear_idx_type=b.linear_idx_type]): Input B matrix tile. - epilogue_fn (
EpilogueFnType): Epilogue applied element-wise to the output. - compute_fn (
ComputeFnType): Compute epilogue applied element-wise to the output. - ctx (
Optional[DeviceContext[CompilationTarget()]]): Optional device context for parallelism control.