pub struct CPU {
pub cache: RefCell<Cache<RawCpuBuf>>,
pub graph: RefCell<Graph>,
}
Expand description
A CPU is used to perform calculations on the host CPU. To make new operations invocable, a trait providing new functions should be implemented for CPU.
§Example
use custos::{CPU, VecRead, Buffer};
let device = CPU::new();
let a = Buffer::from((&device, [1, 2, 3]));
let out = device.read(&a);
assert_eq!(out, vec![1, 2, 3]);
Fields§
§cache: RefCell<Cache<RawCpuBuf>>
§graph: RefCell<Graph>
Implementations§
Trait Implementations§
Source§impl<T> ActivationOps<T> for CPUwhere
T: Float,
impl<T> ActivationOps<T> for CPUwhere
T: Float,
Source§impl<T> AdditionalOps<T> for CPUwhere
T: Number,
impl<T> AdditionalOps<T> for CPUwhere
T: Number,
Source§impl<T> Alloc<T> for CPU
impl<T> Alloc<T> for CPU
Source§fn alloc(&self, len: usize) -> (*mut T, *mut c_void, u64)
fn alloc(&self, len: usize) -> (*mut T, *mut c_void, u64)
Allocate memory on the implemented device. Read more
Source§fn with_data(&self, data: &[T]) -> (*mut T, *mut c_void, u64)where
T: Clone,
fn with_data(&self, data: &[T]) -> (*mut T, *mut c_void, u64)where
T: Clone,
Allocate new memory with data Read more
Source§impl<T> BaseOps<T> for CPUwhere
T: Number,
impl<T> BaseOps<T> for CPUwhere
T: Number,
Source§fn add(&self, lhs: &Matrix<'_, T>, rhs: &Matrix<'_, T>) -> Matrix<'_, T>
fn add(&self, lhs: &Matrix<'_, T>, rhs: &Matrix<'_, T>) -> Matrix<'_, T>
Element-wise addition Read more
Source§fn sub(&self, lhs: &Matrix<'_, T>, rhs: &Matrix<'_, T>) -> Matrix<'_, T>
fn sub(&self, lhs: &Matrix<'_, T>, rhs: &Matrix<'_, T>) -> Matrix<'_, T>
Element-wise subtraction Read more
Source§impl CacheReturn<RawCpuBuf> for CPU
impl CacheReturn<RawCpuBuf> for CPU
Source§impl<T> DiagflatOp<T> for CPU
impl<T> DiagflatOp<T> for CPU
Source§impl<T> ScalarAssign<T> for CPU
impl<T> ScalarAssign<T> for CPU
fn adds_assign(&self, lhs: &mut Matrix<'_, T>, rhs: T)
fn muls_assign(&self, lhs: &mut Matrix<'_, T>, rhs: T)
fn divs_assign(&self, lhs: &mut Matrix<'_, T>, rhs: T)
fn subs_assign(&self, lhs: &mut Matrix<'_, T>, rhs: T)
Source§impl<T> SoftmaxOps<T> for CPUwhere
T: Float + GenericBlas,
impl<T> SoftmaxOps<T> for CPUwhere
T: Float + GenericBlas,
Source§impl<T> TransposeOp<T> for CPU
impl<T> TransposeOp<T> for CPU
impl<T> CCEOp<T> for CPU
Auto Trait Implementations§
impl !Freeze for CPU
impl !RefUnwindSafe for CPU
impl !Send for CPU
impl !Sync for CPU
impl Unpin for CPU
impl UnwindSafe for CPU
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