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

/// Concrete SHA3-512 WGSL kernel.
pub const WGSL: &str = include_str!("wgsl/sha3_512.wgsl");

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

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

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

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

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

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