pub trait ComputeReduce: ComputeView{
// Required method
fn compute_reduce<Op: ReductionOp<Self::Element>>(
&self,
op: Op,
) -> Self::Element;
}Expand description
Extension trait that provides reduce() over any SimdView-backed ComputeView.
§Design
ComputeReduce is a blanket extension: it is automatically satisfied by any type
that implements ComputeView with a SimdView backend. It does not add a vtable
entry — the sole method reduce is #[inline(always)] and monomorphizes to the
same code as calling view.reduce(op) directly.
§Examples
use hermes_simd_core::compute::{ComputeView, ComputeReduce};
use hermes_simd_core::view::SimdView;
use hermes_simd_core::ops::Sum;
use hermes_simd_intrinsics::Scalar;
use hermes_simd_core::align::Unaligned;
use hermes_simd_core::execution::Unmasked;
let data = [1.0_f32; 8];
let view: SimdView<'_, f32, Scalar, Unaligned, Unmasked, &[f32]> =
SimdView::new(&data).unwrap();
let total: f32 = view.compute_reduce(Sum);
assert!((total - 8.0_f32).abs() < 1e-6);Required Methods§
Sourcefn compute_reduce<Op: ReductionOp<Self::Element>>(
&self,
op: Op,
) -> Self::Element
fn compute_reduce<Op: ReductionOp<Self::Element>>( &self, op: Op, ) -> Self::Element
Reduce all elements to a scalar using the given strategy.
Delegates to the SimdView::reduce implementation, which uses
multi-accumulator unrolled SIMD + scalar tail handling.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".