IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/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. /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:

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.