Skip to main content

Crate rlx_tensor

Crate rlx_tensor 

Source
Expand description

Small host-side tensor kernels used by the native SAM3 bring-up.

Compute-heavy ops go through rlx_cpu::blas::sgemm_auto so we get Accelerate/OpenBLAS instead of naive Rust loops. The pure-Rust path falls back to a scalar gemm with the same signature (see rlx-cpu/src/blas.rs).

Functionsยง

gelu_tanh
layer_norm
linear
out = x @ w_t + b where w_t is [in_dim, out_dim] (already transposed at load time by WeightMap::take_transposed).
matmul
out = a @ b with default row-major no-transpose strides.
matmul_bt
out = alpha * a @ b^T (no bias). b is [n, k].
multihead_attention
Multi-head attention forward for an upstream nn.MultiheadAttention with the standard in_proj_weight [3*E, E] / out_proj.weight [E, E] parameterisation. Inputs are batch-first [B, L_q, E] / [B, L_k, E]. key_padding_mask (when present) is [B, L_k] with true meaning the position must be ignored.
sigmoid
softmax_rows
In-place row-wise softmax: each cols-long row is normalised independently. Numerically stable.