Expand description
Pure dense/sparse math helpers (testable without ORT).
ConstantsΒ§
- SPECIAL_
TOKENS π - CLS, PAD, SEP/EOS, UNK β excluded from sparse output.
FunctionsΒ§
- median_
usize π - Computes the median of a
Vec<usize>in-place (sorts the slice). - normalize_
l2 π - L2-normalizes
vecin place. If the norm is zero, leaves the vector unchanged. - sparse_
maxpool π - Max-pools sparse scores by vocabulary token ID, excluding special tokens and tokens masked by the attention mask.
- sparse_
project π - Projects a single tokenβs hidden state through the sparse-linear layer.