Skip to main content

BixverseSimd

Trait BixverseSimd 

Source
pub trait BixverseSimd:
    Copy
    + Default
    + AddAssign
    + Mul<Output = Self> {
    // Required methods
    fn bxv_dot_simd(a: &[Self], b: &[Self]) -> Self;
    fn bxv_sum(x: &[Self]) -> Self;
    fn bxv_sum_squared_deviation(x: &[Self], mean: Self) -> Self;
    fn bxv_exp_shift_sum(src: &[Self], shift: Self, dst: &mut [Self]) -> Self;

    // Provided method
    fn bxv_axpy_simd(y: &mut [Self], a: Self, x: &[Self]) { ... }
}
Expand description

Trait for SIMD-accelerated dot product, replacing the ann-search-rs SimdDistance dependency.

Required Methods§

Source

fn bxv_dot_simd(a: &[Self], b: &[Self]) -> Self

Compute the dot product of two slices using SIMD where available.

§Params
  • a - First slice
  • b - Second slice (must be the same length as a)
§Returns

The dot product of a and b

Source

fn bxv_sum(x: &[Self]) -> Self

Compute the sum over a slice with SIMD

§Params
  • a - Slice for which to calculate the sum
§Returns

The sum of the vector

Source

fn bxv_sum_squared_deviation(x: &[Self], mean: Self) -> Self

Sum of squared deviations from the mean

§Params
  • x - Vector for which to calculate the squared deviations from the mean.
  • mean - The mean.
§Returns

The sum of the squared deviations.

Source

fn bxv_exp_shift_sum(src: &[Self], shift: Self, dst: &mut [Self]) -> Self

Shifted exponential, dst = exp(src - shift), returning sum(dst).

The inner step of a stable softmax, with shift the row maximum.

§Params
  • src - Input slice
  • shift - Subtracted from every element before the exponential
  • dst - Output, same length as src
§Returns

The sum of dst

Provided Methods§

Source

fn bxv_axpy_simd(y: &mut [Self], a: Self, x: &[Self])

Scaled vector addition, y += a * x, in place.

The inner step of any sparse-operator-times-dense-block kernel, where y is one contiguous output row and x one contiguous input row.

Defaulted to a scalar loop so that adding it did not break the trait for out-of-crate implementors. Both in-crate impls override it.

§Params
  • y - Accumulator, updated in place.
  • a - Scalar multiplier.
  • x - Slice added into y (must be the same length as y).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl BixverseSimd for f32

Source§

fn bxv_dot_simd(a: &[f32], b: &[f32]) -> f32

Source§

fn bxv_sum(x: &[f32]) -> f32

Source§

fn bxv_sum_squared_deviation(x: &[f32], mean: f32) -> f32

Source§

fn bxv_axpy_simd(y: &mut [f32], a: f32, x: &[f32])

Source§

fn bxv_exp_shift_sum(src: &[f32], shift: f32, dst: &mut [f32]) -> f32

Source§

impl BixverseSimd for f64

Source§

fn bxv_dot_simd(a: &[f64], b: &[f64]) -> f64

Source§

fn bxv_sum(x: &[f64]) -> f64

Source§

fn bxv_sum_squared_deviation(x: &[f64], mean: f64) -> f64

Source§

fn bxv_axpy_simd(y: &mut [f64], a: f64, x: &[f64])

Source§

fn bxv_exp_shift_sum(src: &[f64], shift: f64, dst: &mut [f64]) -> f64

Implementors§