Skip to main content

ffn_cpu

Function ffn_cpu 

pub fn ffn_cpu(
    input: &[f32],
    w1: &[f32],
    w2: &[f32],
    input_size: usize,
    hidden_size: usize,
    output_size: usize,
) -> Vec<f32>
Expand description

CPU reference for the fused FFN, matching the emitted kernel’s op order exactly (hidden outer, input inner) so GPU/CPU agree within tolerance: out[o] = sum_h w2[o,h] * gelu(sum_i w1[h,i] * input[i]).