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

/// Concrete RIPEMD-160 WGSL kernel.
pub const WGSL: &str = include_str!("wgsl/ripemd160.wgsl");

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

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

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

/// Compute RIPEMD-160 and return five big-endian digest words.
#[must_use]
pub fn ripemd160(input: &[u8]) -> [u32; 5] {
    crate::ops::hash::reference::ripemd160::ripemd160_words(input)
}

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

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