Skip to main content

SparseDot

Trait SparseDot 

Source
pub trait SparseDot: Sized {
    type Weight;
    type Output;

    // Required method
    fn sparse_dot(
        a_indices: &[Self],
        b_indices: &[Self],
        a_weights: &[Self::Weight],
        b_weights: &[Self::Weight],
    ) -> Self::Output;
}
Expand description

Computes sparse dot product between two sorted sparse vectors with weights.

Each vector consists of sorted indices and corresponding weights. The dot product is computed over the intersection of indices, summing the products of weights.

Required Associated Types§

Source

type Weight

Weight type for this sparse dot product.

Source

type Output

Output type for this sparse dot product.

Required Methods§

Source

fn sparse_dot( a_indices: &[Self], b_indices: &[Self], a_weights: &[Self::Weight], b_weights: &[Self::Weight], ) -> Self::Output

Computes sparse dot product.

Returns the sum of a_weights[i] × b_weights[j] for all pairs where a_indices[i] == b_indices[j].

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl SparseDot for u16

Source§

type Weight = bf16

Source§

type Output = f32

Source§

fn sparse_dot( a_indices: &[Self], b_indices: &[Self], a_weights: &[bf16], b_weights: &[bf16], ) -> Self::Output

Source§

impl SparseDot for u32

Source§

type Weight = f32

Source§

type Output = f64

Source§

fn sparse_dot( a_indices: &[Self], b_indices: &[Self], a_weights: &[f32], b_weights: &[f32], ) -> Self::Output

Implementors§