Skip to main content

Gemm

Trait Gemm 

Source
pub trait Gemm:
    Copy
    + Default
    + Sealed
    + 'static {
    // Required methods
    fn mul_add(acc: Self, a: Self, b: Self) -> Self;
    unsafe fn gemm(
        m: usize,
        n: usize,
        k: usize,
        dst: &mut [Self],
        a: MatView<'_, Self>,
        b: MatView<'_, Self>,
    );
}
Expand description

An element type with a GEMM kernel: f32, f64, f16, and [f32; 2] (complex64 as (re, im)).

Required Methods§

Source

fn mul_add(acc: Self, a: Self, b: Self) -> Self

acc + a·b, used by the reference loop (and under Miri).

Source

unsafe fn gemm( m: usize, n: usize, k: usize, dst: &mut [Self], a: MatView<'_, Self>, b: MatView<'_, Self>, )

Calls gemm::gemm for dst (row-major m×n) = lhs · rhs.

§Safety

Every element reachable through the views must lie inside their data, and dst must hold m·n elements.

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 Gemm for [f32; 2]

Source§

fn mul_add(acc: Self, a: Self, b: Self) -> Self

Source§

unsafe fn gemm( m: usize, n: usize, k: usize, dst: &mut [Self], a: MatView<'_, Self>, b: MatView<'_, Self>, )

Source§

impl Gemm for f16

Source§

unsafe fn gemm( m: usize, n: usize, k: usize, dst: &mut [Self], a: MatView<'_, Self>, b: MatView<'_, Self>, )

As MLX: widened to f32, multiplied with f32 accumulation, rounded once (the gemm crate’s f16 kernel accumulates in f16, losing bits over a long k).

Source§

fn mul_add(acc: Self, a: Self, b: Self) -> Self

Source§

impl Gemm for f32

Source§

fn mul_add(acc: Self, a: Self, b: Self) -> Self

Source§

unsafe fn gemm( m: usize, n: usize, k: usize, dst: &mut [Self], a: MatView<'_, Self>, b: MatView<'_, Self>, )

Source§

impl Gemm for f64

Source§

fn mul_add(acc: Self, a: Self, b: Self) -> Self

Source§

unsafe fn gemm( m: usize, n: usize, k: usize, dst: &mut [Self], a: MatView<'_, Self>, b: MatView<'_, Self>, )

Implementors§