Gemm

Trait Gemm 

Source
pub trait Gemm<T, LS: Shape = (), RS: Shape = (), OS: Shape = (), D: Device = Self>: Device {
    // Required method
    fn gemm(
        &self,
        lhs: &Matrix<'_, T, D, LS>,
        rhs: &Matrix<'_, T, D, RS>,
    ) -> Matrix<'_, T, Self, OS>;
}
Expand description

Matrix multiplication. Uses provided device.

§Example

use custos::{CPU, Read};
use custos_math::{Matrix, Gemm};

let device = CPU::new();

let a = Matrix::from((&device, (2, 3), [1., 2., 3., 4., 5., 6.,]));
let b = Matrix::from((&device, (3, 2), [6., 5., 4., 3., 2., 1.,]));

let c: Matrix = device.gemm(&a, &b);

assert_eq!(c.read(), vec![20., 14., 56., 41.,]);

Required Methods§

Source

fn gemm( &self, lhs: &Matrix<'_, T, D, LS>, rhs: &Matrix<'_, T, D, RS>, ) -> Matrix<'_, T, Self, OS>

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.

Implementors§

Source§

impl<T, D, LS, RS, OS> Gemm<T, LS, RS, OS, D> for CPU
where T: Default + Copy + Mul<Output = T> + AddAssign, D: MainMemory, LS: Shape, RS: Shape, OS: Shape,

Available on crate feature cpu only.
Source§

impl<T: CDatatype> Gemm<T> for OpenCL

Available on crate feature opencl only.