pub struct CPU(/* private fields */);
Expand description
CPU backend
Implementations§
source§impl CPU
impl CPU
sourcepub fn tensor<'a>(&'a self, data: impl IntoTensor<&'a Self>) -> Tensor<&'a Self>
pub fn tensor<'a>(&'a self, data: impl IntoTensor<&'a Self>) -> Tensor<&'a Self>
Create new tensor
sourcepub fn randn(&self, shape: impl Into<Shape>, dtype: DType) -> Tensor<&Self>
pub fn randn(&self, shape: impl Into<Shape>, dtype: DType) -> Tensor<&Self>
Create new tensor using values from standard normal distribution
sourcepub fn uniform(
&self,
shape: impl Into<Shape>,
range: Range<impl Scalar>
) -> Tensor<&Self>
pub fn uniform( &self, shape: impl Into<Shape>, range: Range<impl Scalar> ) -> Tensor<&Self>
Create new tensor using values from uniform distribution
sourcepub fn full(&self, shape: impl Into<Shape>, value: impl Scalar) -> Tensor<&Self>
pub fn full(&self, shape: impl Into<Shape>, value: impl Scalar) -> Tensor<&Self>
Create new tensor by repeating single value
sourcepub fn zeros(&self, shape: impl Into<Shape>, dtype: DType) -> Tensor<&Self>
pub fn zeros(&self, shape: impl Into<Shape>, dtype: DType) -> Tensor<&Self>
Create new tensor by repeating zeroes
sourcepub fn ones(&self, shape: impl Into<Shape>, dtype: DType) -> Tensor<&Self>
pub fn ones(&self, shape: impl Into<Shape>, dtype: DType) -> Tensor<&Self>
Create new tensor by repeating ones
sourcepub fn plot_graph<'a, B: Backend + 'a>(
&self,
tensors: impl IntoIterator<Item = &'a Tensor<B>>
) -> String
pub fn plot_graph<'a, B: Backend + 'a>( &self, tensors: impl IntoIterator<Item = &'a Tensor<B>> ) -> String
Create graph of operations between tensors in dot format for visualization
Trait Implementations§
source§impl Backend for &CPU
impl Backend for &CPU
source§fn plot_graph<'a, B: Backend + 'a>(
self,
tensors: impl IntoIterator<Item = &'a Tensor<B>>
) -> String
fn plot_graph<'a, B: Backend + 'a>( self, tensors: impl IntoIterator<Item = &'a Tensor<B>> ) -> String
Create graph of operations between tensors in dot format for visualization
source§fn randn(
self,
shape: impl Into<Shape>,
dtype: DType
) -> Result<Tensor<Self>, ZyxError>
fn randn( self, shape: impl Into<Shape>, dtype: DType ) -> Result<Tensor<Self>, ZyxError>
Create new tensor using values from standard normal distribution
source§fn uniform(
self,
shape: impl Into<Shape>,
range: Range<impl Scalar>
) -> Result<Tensor<Self>, ZyxError>
fn uniform( self, shape: impl Into<Shape>, range: Range<impl Scalar> ) -> Result<Tensor<Self>, ZyxError>
Create new tensor using values from uniform distribution
source§fn backward(
self,
x: Id,
sources: &BTreeSet<Id>
) -> Result<BTreeMap<Id, Id>, ZyxError>
fn backward( self, x: Id, sources: &BTreeSet<Id> ) -> Result<BTreeMap<Id, Id>, ZyxError>
Calculate derivatives of x w.r.t. sources.
Returns map source id -> gradient id
source§fn load<T: Scalar>(self, x: Id) -> Result<Vec<T>, ZyxError>
fn load<T: Scalar>(self, x: Id) -> Result<Vec<T>, ZyxError>
Returns iterator over data stored in backend
source§fn store<T: Scalar, IT>(self, iter: IT) -> Result<Id, ZyxError>
fn store<T: Scalar, IT>(self, iter: IT) -> Result<Id, ZyxError>
Store iterator into backend as tensor
source§fn tensor(self, data: impl IntoTensor<Self>) -> Result<Tensor<Self>, ZyxError>
fn tensor(self, data: impl IntoTensor<Self>) -> Result<Tensor<Self>, ZyxError>
Create new tensor
source§fn full(
self,
shape: impl Into<Shape>,
value: impl Scalar
) -> Result<Tensor<Self>, ZyxError>
fn full( self, shape: impl Into<Shape>, value: impl Scalar ) -> Result<Tensor<Self>, ZyxError>
Create new tensor by repeating single value
source§fn zeros(
self,
shape: impl Into<Shape>,
dtype: DType
) -> Result<Tensor<Self>, ZyxError>
fn zeros( self, shape: impl Into<Shape>, dtype: DType ) -> Result<Tensor<Self>, ZyxError>
Create new tensor by repeating zeroes
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