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.blake3`.

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

/// Compute BLAKE3-256 and return eight big-endian digest words.
#[must_use]
pub fn blake3(input: &[u8]) -> [u32; 8] {
    crate::ops::hash::reference::blake3::blake3_words(input)
}

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

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

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

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

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