Trait custos_math::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.,]);