Skip to main content

max_f32

Function max_f32 

Source
pub fn max_f32(xs: &[f32]) -> f32
Expand description

Maximum of a slice — vectorised.

The other half of the softmax row. for &v in row { max = max.max(v) } is a loop-carried reduction on a function with NaN semantics, so LLVM will not lane it any more than it lanes the sum. It is a full pass over the same 50 MB-per-layer score tensor that exp_sub_sum_inplace then walks again.

Returns f32::NEG_INFINITY for an empty slice, matching a fold from that identity. Lane-splitting a MAX is exact — max is associative and commutative on non-NaN floats — so unlike the sum this twin is gated by assert_eq!, not by tolerance.