vyre-reference 0.4.1

Pure-Rust CPU reference interpreter for vyre IR — byte-identical oracle for backend conformance and small-data fallback
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::{dual_impls::common, workgroup::Memory};
use vyre_primitives::Reduce;

impl common::ReferenceEvaluator for Reduce {
    fn evaluate(&self, inputs: &[Memory]) -> Result<Memory, common::EvalError> {
        let words = common::u32_words(common::one_input(inputs, "reduce")?, "reduce")?;
        let Some((&first, tail)) = words.split_first() else {
            return Ok(common::scalar(0));
        };
        let mut value = first;
        for next in tail.iter().copied() {
            value = common::combine(self.combine, value, next)?;
        }
        Ok(common::scalar(value))
    }
}