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

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

/// Compute BLAKE2b-512 and return eight big-endian digest words.
#[must_use]
pub fn blake2b(input: &[u8]) -> [u64; 8] {
    crate::ops::hash::reference::blake2::blake2b_words(input)
}

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

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

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

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

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