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

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

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

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

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

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

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

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