Skip to main content

gemm_packed_b_fused

Function gemm_packed_b_fused 

Source
pub fn gemm_packed_b_fused<T: FusedScalar>(
    alpha: T,
    a: MatRef<'_, T>,
    packed: &PackedRhs<T>,
    beta: T,
    c: MatMut<'_, T>,
    bias: Option<Bias<'_, T>>,
    act: Option<Activation<T>>,
    par: Parallelism,
)
Available on crate feature epilogue only.
Expand description

C <- act(alpha*A*(prepacked B) + beta*C + bias) in one pass. This is a fused epilogue over a reused PackedRhs, using the thread-local workspace pool. It is the fused twin of gemm_packed_b. The bias is folded in with 1 IEEE add right after the final beta-scaled store. The activation applies next, fused into the same store the packed kernel already runs. bias == None && act == None reproduces gemm_packed_b bit-for-bit

The same PackedRhs handle serves both gemm_packed_b and this fused entry. The epilogue is store-side only, so the pack and its recorded geometry stay untouched. For f32 and f64 the result is bit-identical to gemm_packed_b followed by the same scalar map, for every valid shape and stride. For f16 and bf16 the epilogue applies in f32 before the single narrowing, which is more precise than, and so not bitwise equal to, packed-gemm-then-map

Unlike plain gemm_fused, this path never reroutes to gemv or a small-shape special path. It always drives the general prepacked kernel. Because it never swaps orientation, the user-frame per-row or per-col bias passes straight through

ยงPanics

Same conditions as gemm_packed_b, plus the fused conditions of gemm_fused. A PerRow bias whose length is not A.rows, or a PerCol bias whose length is not B.cols, causes a panic. A bias slice that overlaps C, or a non-finite LeakyRelu slope, also causes a panic