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
use crate::{dual_impls::common, workgroup::Memory};
use vyre_primitives::Gather;

impl common::ReferenceEvaluator for Gather {
    fn evaluate(&self, inputs: &[Memory]) -> Result<Memory, common::EvalError> {
        let (values, indices) = common::two_inputs(inputs, "gather")?;
        let values = common::u32_words(values, "gather")?;
        let indices = common::u32_words(indices, "gather")?;
        let mut output = Vec::with_capacity(indices.len());
        for index in indices {
            output.push(values[common::checked_index(index, values.len(), "gather")?]);
        }
        Ok(common::write_u32s(output))
    }
}