vyre 0.4.0

GPU compute intermediate representation with a standard operation library
Documentation
use crate::ir::DataType;
use crate::ops::Backend;
use crate::ops::{IntrinsicDescriptor, OpSpec};

// WGSL lowering source for `hash.md5`.

/// Concrete MD5 WGSL kernel.
pub const WGSL: &str = include_str!("wgsl/md5.wgsl");

pub const INPUTS: &[DataType] = &[DataType::Bytes];

pub const LAWS: &[crate::ops::AlgebraicLaw] = &[];

/// Compute MD5 and return four canonical big-endian digest words.
#[must_use]
pub fn md5(input: &[u8]) -> [u32; 4] {
    crate::ops::hash::reference::md5::md5_words(input)
}

pub const OUTPUTS: &[DataType] = &[const { DataType::U32 }; 4];

/// Declarative operation specification for `hash.md5`.
pub const SPEC: OpSpec = OpSpec::intrinsic(
    "hash.md5",
    INPUTS,
    OUTPUTS,
    LAWS,
    wgsl_only,
    IntrinsicDescriptor::new(
        "hash.md5.wgsl",
        "wgsl-md5-compress",
        crate::ops::hash::cpu_refs::md5,
    ),
);

pub fn wgsl_only(backend: &Backend) -> bool {
    matches!(backend, Backend::Wgsl)
}