Skip to main content

Module vector

Module vector 

Source
Expand description

Element-wise vector ops (add / Hadamard / scale / axpy) — residual stream + gated activations. Dynamic element-wise vector operations — the foundational rank-1 linear algebra the transformer is built from beyond GEMM: the residual connection (x + sublayer(x)) is vector addition, and the gated activation (SwiGLU) uses the Hadamard product (element-wise multiply). Plain arithmetic; caller-owned, zero allocation.

Functions§

add_assign
a[i] += b[i] — in-place residual add.
add_into
c[i] = a[i] + b[i] — vector addition (the residual connection x + sublayer(x)).
axpy
y[i] += α·x[i] — the BLAS axpy.
hadamard_assign
a[i] *= b[i] — in-place Hadamard product.
hadamard_into
c[i] = a[i] · b[i] — the Hadamard (element-wise) product, e.g. the SwiGLU gate silu(g) ⊙ u.
scale
a[i] *= s — scalar scaling.