Skip to main content

hdm_linear

Function hdm_linear 

Source
pub fn hdm_linear(
    x: &[f32],
    w_rot: &[f32],
    out_f: usize,
    in_f: usize,
    hadamard_seed: Option<i64>,
) -> Result<Vec<f32>, EngineError>
Expand description

y = W_rot @ x followed by blocked unrotate on each out_f row (HDM fused path).

Equivalent to linear(x, unrotate(W_rot)) for dense GEMM. Not valid for embedding row gather: axis-0 Hadamard mixes vocab rows, so W_rot[token] is not the token vector. Session reconstructs the full matrix at load instead.