pub struct Cpu { /* private fields */ }
Expand description
A device that stores data on the heap.
The Default impl seeds the underlying rng with seed of 0.
Use Cpu::seed_from_u64 to control what seed is used.
Implementations§
Trait Implementations§
source§impl DeviceStorage for Cpu
impl DeviceStorage for Cpu
source§fn try_alloc_grad<E: Unit>(
&self,
other: &Self::Vec<E>
) -> Result<Self::Vec<E>, Self::Err>
fn try_alloc_grad<E: Unit>( &self, other: &Self::Vec<E> ) -> Result<Self::Vec<E>, Self::Err>
Allocates a gradient for the given nd array
source§fn random_u64(&self) -> u64
fn random_u64(&self) -> u64
Generates a random u64 number
fn tensor_to_vec<S: Shape, E: Unit, T>( &self, tensor: &Tensor<S, E, Self, T> ) -> Vec<E>
source§impl<E: Unit> OnesTensor<E> for Cpu
impl<E: Unit> OnesTensor<E> for Cpu
source§fn try_ones_like<S: HasShape>(
&self,
src: &S
) -> Result<Tensor<S::Shape, E, Self>, Self::Err>
fn try_ones_like<S: HasShape>( &self, src: &S ) -> Result<Tensor<S::Shape, E, Self>, Self::Err>
Fallible version of OnesTensor::ones_like
source§fn ones<S: ConstShape>(&self) -> Tensor<S, E, Self>
fn ones<S: ConstShape>(&self) -> Tensor<S, E, Self>
Creates a tensor filled with ones. Read more
source§fn try_ones<S: ConstShape>(&self) -> Result<Tensor<S, E, Self>, Self::Err>
fn try_ones<S: ConstShape>(&self) -> Result<Tensor<S, E, Self>, Self::Err>
Fallible version of OnesTensor::ones
source§impl<E: Unit> SampleTensor<E> for Cpu
impl<E: Unit> SampleTensor<E> for Cpu
source§fn try_sample_like<S: HasShape, D: Distribution<E>>(
&self,
src: &S,
distr: D
) -> Result<Tensor<S::Shape, E, Self>, Self::Err>
fn try_sample_like<S: HasShape, D: Distribution<E>>( &self, src: &S, distr: D ) -> Result<Tensor<S::Shape, E, Self>, Self::Err>
Fallibly samples a tensor with a given shape from a given distribution.
source§fn try_fill_with_distr<D: Distribution<E>>(
&self,
storage: &mut Self::Vec<E>,
distr: D
) -> Result<(), Self::Err>
fn try_fill_with_distr<D: Distribution<E>>( &self, storage: &mut Self::Vec<E>, distr: D ) -> Result<(), Self::Err>
Fills tensor storage with data from a given distribution
source§fn sample<S: ConstShape, D: Distribution<E>>(
&self,
distr: D
) -> Tensor<S, E, Self>
fn sample<S: ConstShape, D: Distribution<E>>( &self, distr: D ) -> Tensor<S, E, Self>
Samples a const tensor from a given distribution.
source§fn try_sample<S: ConstShape, D: Distribution<E>>(
&self,
distr: D
) -> Result<Tensor<S, E, Self>, Self::Err>
fn try_sample<S: ConstShape, D: Distribution<E>>( &self, distr: D ) -> Result<Tensor<S, E, Self>, Self::Err>
Fallibly samples a const tensor from a given distribution.
source§fn sample_like<S: HasShape, D: Distribution<E>>(
&self,
src: &S,
distr: D
) -> Tensor<S::Shape, E, Self>
fn sample_like<S: HasShape, D: Distribution<E>>( &self, src: &S, distr: D ) -> Tensor<S::Shape, E, Self>
Samples a tensor with a given shape from a given distribution.
source§impl<E: Unit> TensorFromVec<E> for Cpu
impl<E: Unit> TensorFromVec<E> for Cpu
source§impl<E: Unit> ZerosTensor<E> for Cpu
impl<E: Unit> ZerosTensor<E> for Cpu
source§fn try_zeros_like<S: HasShape>(
&self,
src: &S
) -> Result<Tensor<S::Shape, E, Self>, Self::Err>
fn try_zeros_like<S: HasShape>( &self, src: &S ) -> Result<Tensor<S::Shape, E, Self>, Self::Err>
Fallible version of ZerosTensor::zeros_like
source§fn zeros<S: ConstShape>(&self) -> Tensor<S, E, Self>
fn zeros<S: ConstShape>(&self) -> Tensor<S, E, Self>
Creates a tensor filled with zeros. Read more
source§fn try_zeros<S: ConstShape>(&self) -> Result<Tensor<S, E, Self>, Self::Err>
fn try_zeros<S: ConstShape>(&self) -> Result<Tensor<S, E, Self>, Self::Err>
Fallible version of ZerosTensor::zeros