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

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

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

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

pub const OUTPUTS: &[DataType] = &[DataType::U64];

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

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

/// Compute XXH64 with seed 0.
#[must_use]
pub fn xxhash64(input: &[u8]) -> u64 {
    crate::ops::hash::reference::xxhash::xxhash64(input)
}