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

/// Concrete SHA-384 WGSL kernel.
pub const WGSL: &str = include_str!("wgsl/sha384.wgsl");

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

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

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

/// Compute SHA-384 and return six big-endian digest words.
#[must_use]
pub fn sha384(input: &[u8]) -> [u64; 6] {
    crate::ops::hash::reference::sha512::sha384_words(input)
}

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

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