Skip to main content

sum_in_f32_accumulation

Function sum_in_f32_accumulation 

Source
pub fn sum_in_f32_accumulation(values: &[Bf16]) -> Bf16
Expand description

Sum a slice, accumulating in f32 and rounding once at the end.

ยงExamples

use tenferro_bf16_proof::{reduction::sum_in_f32_accumulation, Bf16};

let ones = vec![Bf16::from_f32(1.0); 300];
// Three hundred ones are exactly representable after rounding, because the accumulation kept
// the intermediate values in f32.
assert_eq!(sum_in_f32_accumulation(&ones).to_f32(), 300.0);