Skip to main content

gemm_f32

Function gemm_f32 

Source
pub fn gemm_f32(
    m: usize,
    k: usize,
    n: usize,
    a: &[f32],
    b: &[f32],
) -> Result<Vec<f32>, ForgeError>
Expand description

Best-path single-precision dense GEMM: row-major C[M×N] = A[M×K] · B[K×N].

Path selection:

  1. WGSL GPU — when caps().wgpu is set and the problem is at least GEMM_GPU_THRESHOLD FMAs, run the certified GEMM via the shared ForgeRuntime. If the runtime cannot be built or the dispatch errors at runtime, the error is not propagated — the call falls through to the CPU floor so it is never broken.
  2. CPU floor — otherwise (no GPU, sub-threshold, or GPU fell through) compute on the CPU via gemm_cpu.

a must have m * k elements, b must have k * n; both row-major. Returns m * n row-major elements. Dimension/length mismatches are the only hard errors.