pub trait DeviceStorage: 'static + Debug + Default + Clone + HasErr {
    type Vec<E: Unit>: 'static + Debug + Clone + Send + Sync;

    // Required methods
    fn random_u64(&self) -> u64;
    fn try_alloc_grad<E: Unit>(
        &self,
        storage: &Self::Vec<E>
    ) -> Result<Self::Vec<E>, Self::Err>;
    fn tensor_to_vec<S: Shape, E: Unit, T>(
        &self,
        tensor: &Tensor<S, E, Self, T>
    ) -> Vec<E>;
}
Expand description

Something that can store nd arrays for a given Shape and Dtype

Required Associated Types§

source

type Vec<E: Unit>: 'static + Debug + Clone + Send + Sync

Generic storage type

Required Methods§

source

fn random_u64(&self) -> u64

Generates a random u64 number

source

fn try_alloc_grad<E: Unit>( &self, storage: &Self::Vec<E> ) -> Result<Self::Vec<E>, Self::Err>

Allocates a gradient for the given nd array

source

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

Implementors§