Skip to main content

argmax

Function argmax 

Source
pub fn argmax(values: &[f32]) -> u32
Expand description

Greedy: index of the maximum value.

Four running maxima instead of one: the scalar max_by carried a loop dependency through the comparison, which at a 129k vocab is a tenth of a millisecond of pure serial work per token.

Ties resolve to the HIGHEST index — not an arbitrary choice, it is what Iterator::max_by does (it keeps the last of several equal maxima) and therefore what this has always returned. explain’s preview compares its own argmax against what greedy emits, and that test is what catches the flip.