coeus-ops 0.14.0

Numerical tensor operators for Coeus.
Documentation
use super::super::matmul;
use super::super::CpuBackend;
use crate::backend_ops::traits::MatmulOps;
use coeus_core::{CpuAddressableStorageMut, Layout, Scalar};

// SAFETY: Overwrite methods initialize every logical output on success; accumulation methods require initialized outputs.
unsafe impl<T: Scalar + leto_ops::Scalar, B: CpuBackend> MatmulOps<T> for B
where
    B::DeviceBuffer<T>: CpuAddressableStorageMut<T>,
{
    #[inline]
    fn matmul(
        &self,
        a: &Self::DeviceBuffer<T>,
        a_layout: &Layout,
        b: &Self::DeviceBuffer<T>,
        b_layout: &Layout,
        c: &mut Self::DeviceBuffer<T>,
        c_layout: &Layout,
    ) -> Result<(), Self::Error> {
        matmul::matmul(self, a, a_layout, b, b_layout, c, c_layout)
    }

    #[inline]
    fn batched_matmul(
        &self,
        a: &Self::DeviceBuffer<T>,
        a_layout: &Layout,
        b: &Self::DeviceBuffer<T>,
        b_layout: &Layout,
        c: &mut Self::DeviceBuffer<T>,
        c_layout: &Layout,
    ) -> Result<(), Self::Error> {
        matmul::batched_matmul(self, a, a_layout, b, b_layout, c, c_layout)
    }

    #[inline]
    fn matmul_accumulate(
        &self,
        a: &Self::DeviceBuffer<T>,
        a_layout: &Layout,
        b: &Self::DeviceBuffer<T>,
        b_layout: &Layout,
        c: &mut Self::DeviceBuffer<T>,
        c_layout: &Layout,
    ) -> Result<(), Self::Error> {
        matmul::matmul_accumulate(self, a, a_layout, b, b_layout, c, c_layout)
    }

    #[inline]
    fn batched_matmul_accumulate(
        &self,
        a: &Self::DeviceBuffer<T>,
        a_layout: &Layout,
        b: &Self::DeviceBuffer<T>,
        b_layout: &Layout,
        c: &mut Self::DeviceBuffer<T>,
        c_layout: &Layout,
    ) -> Result<(), Self::Error> {
        matmul::batched_matmul_accumulate(self, a, a_layout, b, b_layout, c, c_layout)
    }
}