Expand description
Pure dense/sparse math helpers (testable without ORT).
StructsΒ§
- SeqLen
Distribution π - Per-batch token-length distribution statistics.
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. - seq_
len_ πdistribution - Computes min, max, mean, and p95 token-length statistics for an embed batch.
- 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.