CpuBackend

Struct CpuBackend 

Source
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

Source§

type Plan<T: ScalarBase> = CpuPlan<T>

Backend-specific plan type (no type erasure).
Source§

fn plan<T: ScalarBase>( _desc: &PrimDescriptor, _shapes: &[&[usize]], ) -> Result<CpuPlan<T>>

Create an execution plan from an operation descriptor. Read more
Source§

fn execute<T: ScalarBase>( _plan: &CpuPlan<T>, _alpha: T, _inputs: &[&StridedView<'_, T>], _beta: T, _output: &mut StridedViewMut<'_, T>, ) -> Result<()>

Execute a plan with the given scaling factors and tensor views. Read more
Source§

fn has_extension_for<T: ScalarBase>(_ext: Extension) -> bool

Query whether an extended operation is available for scalar type T. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.