Struct dfdx::tensor::Cpu

source ·
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§

source§

impl Cpu

source

pub fn seed_from_u64(seed: u64) -> Self

Constructs rng with the given seed.

Trait Implementations§

source§

impl<E: Float + Dtype> AdamKernel<E> for Cpu

source§

fn update( &self, t: i32, cfg: &AdamConfig<E>, param: &mut Self::Vec<E>, moment1: &mut Self::Vec<E>, moment2: &mut Self::Vec<E>, grad: &Self::Vec<E> ) -> Result<(), Self::Err>

source§

impl Clone for Cpu

source§

fn clone(&self) -> Cpu

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<E: Unit> CopySlice<E> for Cpu

source§

fn copy_from<S: Shape, T>(dst: &mut Tensor<S, E, Self, T>, src: &[E])

source§

fn copy_into<S: Shape, T>(src: &Tensor<S, E, Self, T>, dst: &mut [E])

source§

impl Debug for Cpu

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Cpu

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl DeviceStorage for Cpu

§

type Vec<E: Unit> = Vec<E, Global>

Generic storage type
source§

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

Generates a random u64 number
source§

fn tensor_to_vec<S: Shape, E: Unit, T>( &self, tensor: &Tensor<S, E, Self, T> ) -> Vec<E>

source§

impl HasErr for Cpu

source§

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>

Fallible version of OnesTensor::ones_like
source§

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>

Fallible version of OnesTensor::ones
source§

fn ones_like<S: HasShape>(&self, src: &S) -> Tensor<S::Shape, E, Self>

Build the tensor with a shape given by something else. Read more
source§

impl<E: Float + Dtype> RMSpropKernel<E> for Cpu

source§

fn update( &self, cfg: &RMSpropConfig<E>, param: &mut Self::Vec<E>, momentum: &mut Self::Vec<E>, square_avg: &mut Self::Vec<E>, grad_avg: &mut Self::Vec<E>, grad: &Self::Vec<E> ) -> Result<(), Self::Err>

source§

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>

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>

Fills tensor storage with data from a given distribution
source§

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>

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>

Samples a tensor with a given shape from a given distribution.
source§

impl<E: Dtype> SgdKernel<E> for Cpu

source§

fn update( &self, cfg: &SgdConfig<E>, param: &mut Self::Vec<E>, velocity: &mut Self::Vec<E>, grad: &Self::Vec<E> ) -> Result<(), Self::Err>

source§

impl<E: Unit> TensorFromVec<E> for Cpu

source§

fn try_tensor_from_vec<S: Shape>( &self, src: Vec<E>, shape: S ) -> Result<Tensor<S, E, Self>, Self::Err>

source§

fn tensor_from_vec<S: Shape>(&self, src: Vec<E>, shape: S) -> Tensor<S, E, Self>

source§

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>

Fallible version of ZerosTensor::zeros_like
source§

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>

Fallible version of ZerosTensor::zeros
source§

fn zeros_like<S: HasShape>(&self, src: &S) -> Tensor<S::Shape, E, Self>

Build the tensor with a shape given by something else. Read more
source§

impl Device<f32> for Cpu

source§

impl Device<f64> for Cpu

Auto Trait Implementations§

§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V