vyre-conform 0.1.0

Conformance suite for vyre backends — proves byte-identical output to CPU reference
Documentation
use vyre_conform::{
    certify, Category, CertificateStrength, DataType, DispatchConfig, OpOutcome, OpSignature,
    OpSpec, Strictness, VyreBackend,
};

fn cpu(_: &[u8]) -> Vec<u8> {
    0_u32.to_le_bytes().to_vec()
}

fn wgsl() -> String {
    "fn vyre_op(index: u32, input_len: u32) -> u32 { return 0u; }".to_string()
}

fn spec() -> OpSpec {
    OpSpec::builder("primitive.float.fadd")
        .signature(OpSignature {
            inputs: vec![DataType::F32, DataType::F32],
            output: DataType::F32,
        })
        .cpu_fn(cpu)
        .wgsl_fn(wgsl)
        .category(Category::A {
            composition_of: vec![],
        })
        .laws(vec![])
        .strictness(Strictness::Strict)
        .version(1)
        .build()
        .expect("registry invariant violated")
}

struct FtzBackend;

impl VyreBackend for FtzBackend {
    fn name(&self) -> &str {
        "float-b3-ftz"
    }

    fn dispatch(
        &self,
        _wgsl: &str,
        _input: &[u8],
        _output_size: usize,
        _config: DispatchConfig,
    ) -> Result<Vec<u8>, String> {
        Ok(0_u32.to_le_bytes().to_vec())
    }
}

#[test]
fn certify_trips_b3_subnormal_gate() {
    let cert = certify(&FtzBackend, &[spec()], CertificateStrength::FastCheck).unwrap();
    assert_eq!(cert.ops()[0].outcome(), OpOutcome::Failed);
    assert!(cert.ops()[0].parity_failures()[0]
        .message
        .contains("SPEC.md:321"));
}