pub trait Storage<E>: 'static + Debug + Default + Clone + HasErr {
type Vec: 'static + Debug + Clone + Send + Sync;
// Required methods
fn try_alloc_len(&self, len: usize) -> Result<Self::Vec, Self::Err>;
fn tensor_to_vec<S: Shape, T>(
&self,
tensor: &Tensor<S, E, Self, T>
) -> Vec<E>;
fn len(&self, v: &Self::Vec) -> usize;
// Provided method
fn try_alloc_grad(
&self,
storage: &Self::Vec
) -> Result<Self::Vec, Self::Err> { ... }
}
Expand description
Something that can store nd arrays for a given Shape and Dtype
Allocates a gradient for the given nd array