Skip to main content

ternary_gemm_cpu

Function ternary_gemm_cpu 

Source
pub fn ternary_gemm_cpu(
    activations: &[f32],
    packed: &[u8],
    scale: f32,
    n_in: usize,
    n_out: usize,
    n_batch: usize,
    in_row_stride: usize,
    out_row_stride: usize,
    out: &mut [f32],
)
Expand description

CPU oracle for ternary_gemm.wgsl. Computes out[m][i] = scale · Σ_j trit(W[i][j])·act[m][j] where packed holds the row-major trits of an (n_out × n_in) weight matrix. The weight contributes by add/subtract only (the BitNet win); the per-tensor scale is applied once per output element. Zero-heap. Strides default to dense (n_in / n_out) when 0.