Skip to main content

topk_cpu

Function topk_cpu 

pub fn topk_cpu(
    input: &[f32],
    length: usize,
    k: usize,
    block_size: usize,
) -> Vec<f32>
Expand description

CPU reference for the per-block top-k: the k largest values of each block_size-element block, in descending order. Blocks shorter than block_size (the tail) are padded with the sentinel, mirroring the GPU kernel’s out-of-range loads.