pub struct CPU {
pub cache: RefCell<Cache<CPU>>,
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, Read, 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<CPU>>§graph: RefCell<Graph>Implementations§
Trait Implementations§
source§impl<T: Float, D: MainMemory, S: Shape> ActivationOps<T, S, D> for CPU
impl<T: Float, D: MainMemory, S: Shape> ActivationOps<T, S, D> for CPU
fn sigmoid(&self, x: &Matrix<'_, T, D, S>) -> Matrix<'_, T, Self, S>
fn sigmoid_grad(&self, activated: &Matrix<'_, T, D, S>) -> Matrix<'_, T, Self, S>
fn tanh(&self, x: &Matrix<'_, T, D, S>) -> Matrix<'_, T, Self, S>
fn tanh_grad(&self, x: &Matrix<'_, T, D, S>) -> Matrix<'_, T, Self, S>
fn relu(&self, x: &Matrix<'_, T, D, S>) -> Matrix<'_, T, Self, S>
fn relu_grad(&self, x: &Matrix<'_, T, D, S>) -> Matrix<'_, T, Self, S>
source§fn relu_grad_mut(&self, x: &mut Matrix<'_, T, D, S>)
fn relu_grad_mut(&self, x: &mut Matrix<'_, T, D, S>)
inplace
source§impl<T: Number, D: MainMemory, S: Shape> AdditionalOps<T, S, D> for CPU
impl<T: Number, D: MainMemory, S: Shape> AdditionalOps<T, S, D> for CPU
fn adds(&self, lhs: &Matrix<'_, T, D, S>, rhs: T) -> Matrix<'_, T, Self, S>
fn subs(&self, lhs: &Matrix<'_, T, D, S>, rhs: T) -> Matrix<'_, T, Self, S>
fn muls(&self, lhs: &Matrix<'_, T, D, S>, rhs: T) -> Matrix<'_, T, Self, S>
fn divs(&self, lhs: &Matrix<'_, T, D, S>, rhs: T) -> Matrix<'_, T, Self, S>
source§impl<T, S> Alloc<'_, T, S> for CPUwhere
S: Shape,
impl<T, S> Alloc<'_, T, S> for CPUwhere S: Shape,
source§impl<T, S, D> BaseOps<T, S, D> for CPUwhere
T: Number,
S: Shape,
D: MainMemory,
impl<T, S, D> BaseOps<T, S, D> for CPUwhere T: Number, S: Shape, D: MainMemory,
source§fn add(
&self,
lhs: &Matrix<'_, T, D, S>,
rhs: &Matrix<'_, T, D, S>
) -> Matrix<'_, T, Self, S>
fn add( &self, lhs: &Matrix<'_, T, D, S>, rhs: &Matrix<'_, T, D, S> ) -> Matrix<'_, T, Self, S>
Element-wise addition Read more
source§fn sub(
&self,
lhs: &Matrix<'_, T, D, S>,
rhs: &Matrix<'_, T, D, S>
) -> Matrix<'_, T, Self, S>
fn sub( &self, lhs: &Matrix<'_, T, D, S>, rhs: &Matrix<'_, T, D, S> ) -> Matrix<'_, T, Self, S>
Element-wise subtraction Read more