vyre-conform 0.1.0

Conformance suite for vyre backends — proves byte-identical output to CPU reference
Documentation
//! Backend certification subcommand.

use clap::Parser;

use crate::pipeline::certify::{certify, to_json, CertificateStrength};

/// Arguments for backend certification.
#[derive(Debug, Parser)]
pub struct Args {
    /// Backend identifier to certify. Currently supported: wgpu.
    pub backend: String,
}

/// Certify a backend and emit the certificate JSON.
pub fn run(args: Args) -> Result<(), Box<dyn std::error::Error>> {
    match args.backend.as_str() {
        "wgpu" | "gpu" => certify_wgpu(),
        other => Err(format!(
            "Fix: unsupported backend `{other}`. Use `wgpu` or register a supported backend."
        )
        .into()),
    }
}

fn certify_wgpu() -> Result<(), Box<dyn std::error::Error>> {
    let backend = crate::pipeline::backend::require_gpu()?;
    let specs = crate::op_registry::all_specs();
    let certificate = certify(&backend, &specs, CertificateStrength::Standard)?;
    let json = to_json(&certificate)?;
    println!("{json}");
    Ok(())
}