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
gemv_kernel
def gemv_kernel[c_type: DType, a_type: DType, b_type: DType, *, 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, accum_type: DType = get_accum_type[c_type](), pdl_level: PDLLevel = PDLLevel()](c: Pointer[Scalar[c_type], MutUnsafeAnyOrigin, _safe=False], a: Pointer[Scalar[a_type], ImmUnsafeAnyOrigin, _safe=False], b: Pointer[Scalar[b_type], ImmUnsafeAnyOrigin, _safe=False], m: Int, n: Int, k: Int)
GPU kernel for matrix-vector multiplication using scalar warp-level reduction.
Each warp computes one output row by accumulating a dot product over the K dimension with one scalar element per thread, then reducing across the warp.
Parameters:
- βc_type (
DType): Output element type. - βa_type (
DType): A (matrix) element type. - βb_type (
DType): B (vector) element type. - βtranspose_b (
Bool): When True, writes the result to a transposed output index. - βelementwise_lambda_fn (
Optional[def[dtype: DType, width: SIMDLength, *, alignment: Int = Int(1)](IndexList[Int(2)], SIMD[dtype, width]) capturing thin -> None]): Optional epilogue function applied to each output element. - βaccum_type (
DType): Accumulation precision type. - βpdl_level (
PDLLevel): Programmatic dependent launch level for PDL barriers.
Args:
- βc (
Pointer[Scalar[c_type], MutUnsafeAnyOrigin, _safe=False]): Output pointer of length m. - βa (
Pointer[Scalar[a_type], ImmUnsafeAnyOrigin, _safe=False]): Input matrix pointer of shape (m, k). - βb (
Pointer[Scalar[b_type], ImmUnsafeAnyOrigin, _safe=False]): Input vector pointer of length k. - βm (
Int): Number of output rows. - βn (
Int): Unused; retained for interface consistency. - βk (
Int): Shared reduction dimension.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!