pub struct CpuBackend;Expand description
CPU backend using strided-kernel and GEMM.
Dispatched automatically when tensors reside on
LogicalMemorySpace::MainMemory.
Implements TensorPrims<Standard> for standard arithmetic.
§Examples
ⓘ
use tenferro_prims::{CpuBackend, TensorPrims, PrimDescriptor};
use strided_view::StridedArray;
// Transpose a matrix
let desc = PrimDescriptor::Permute {
modes_a: vec![0, 1],
modes_b: vec![1, 0],
};
let plan = CpuBackend::plan::<f64>(&desc, &[&[3, 4], &[4, 3]]).unwrap();
let a = StridedArray::<f64>::col_major(&[3, 4]);
let mut b = StridedArray::<f64>::col_major(&[4, 3]);
CpuBackend::execute(&plan, 1.0, &[&a.view()], 0.0, &mut b.view_mut()).unwrap();Trait Implementations§
Source§impl TensorPrims<Standard> for CpuBackend
impl TensorPrims<Standard> for CpuBackend
Source§fn plan<T: ScalarBase>(
_desc: &PrimDescriptor,
_shapes: &[&[usize]],
) -> Result<CpuPlan<T>>
fn plan<T: ScalarBase>( _desc: &PrimDescriptor, _shapes: &[&[usize]], ) -> Result<CpuPlan<T>>
Create an execution plan from an operation descriptor. Read more
Auto Trait Implementations§
impl Freeze for CpuBackend
impl RefUnwindSafe for CpuBackend
impl Send for CpuBackend
impl Sync for CpuBackend
impl Unpin for CpuBackend
impl UnwindSafe for CpuBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more