vyre 0.4.0

GPU compute intermediate representation with a standard operation library
Documentation
// Byte histogram operation module.

// Backend-specific lowering for byte histogram.



// CPU reference kernel for `stats.byte_histogram`.

/// Count each byte value in `input`.
///
/// The returned array index is the byte value and the value is the wrapping
/// `u32` occurrence count.
#[must_use]
pub fn byte_histogram(input: &[u8]) -> [u32; 256] {
    let mut counts = [0_u32; 256];
    for &byte in input {
        let bucket = usize::from(byte);
        counts[bucket] = counts[bucket].wrapping_add(1);
    }
    counts
}