vyre 0.4.0

GPU compute intermediate representation with a standard operation library
Documentation
use crate::ir::DataType;
use crate::ir::Program;
use crate::ops::AlgebraicLaw;
use crate::ops::OpSpec;

// WGSL lowering marker for `reductions.reduce_all`.
//
// No special handling is needed. The generic Category A lowerer emits the
// sequential reduction composition.

impl ReduceAll {
    /// Declarative operation specification.
    pub const SPEC: OpSpec = OpSpec::composition(
        "reductions.reduce_all",
        INPUTS,
        OUTPUTS,
        LAWS,
        Self::program,
    );

    /// Build the canonical sequential reduction program.
    #[must_use]
    pub fn program() -> Program {
        crate::ops::reductions::programs::reduce_bool_program(true, crate::ir::Expr::and)
    }
}

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

pub const LAWS: &[AlgebraicLaw] = &[
    AlgebraicLaw::Associative,
    AlgebraicLaw::Identity { element: 1 },
];

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

/// Boolean all reduction.
#[derive(Debug, Clone, Copy, Default)]
pub struct ReduceAll;