Skip to main content

sparse_maxpool

Function sparse_maxpool 

Source
pub(super) fn sparse_maxpool(
    ids: &[u32],
    mask: &[u32],
    scores: &[f32],
) -> (Vec<usize>, Vec<f32>)
Expand description

Max-pools sparse scores by vocabulary token ID, excluding special tokens and tokens masked by the attention mask.

Returns sorted (indices, values) vectors suitable for SparseEmbedding.