pub struct GradStore<T: FloatDType>(/* private fields */);Implementations§
Source§impl<T: FloatDType> GradStore<T>
impl<T: FloatDType> GradStore<T>
Sourcepub fn get(&self, tensor: &Tensor<T>) -> Option<&Tensor<T>>
pub fn get(&self, tensor: &Tensor<T>) -> Option<&Tensor<T>>
Get the gradient tensor associated with the given tensor
pub fn get_by_index(&self, index: usize) -> Option<&Tensor<T>>
Sourcepub fn remove(&mut self, tensor: &Tensor<T>) -> Option<Tensor<T>>
pub fn remove(&mut self, tensor: &Tensor<T>) -> Option<Tensor<T>>
Remove the gradient tensor associated with the given tensor, returning it if it exists
Sourcepub fn insert(
&mut self,
tensor: &Tensor<T>,
grad: Tensor<T>,
) -> Option<Tensor<T>>
pub fn insert( &mut self, tensor: &Tensor<T>, grad: Tensor<T>, ) -> Option<Tensor<T>>
Insert a gradient tensor associated with the given tensor, returning the previous gradient tensor if it existed
Sourcepub fn or_insert(&mut self, tensor: &Tensor<T>) -> Result<&mut Tensor<T>>
pub fn or_insert(&mut self, tensor: &Tensor<T>) -> Result<&mut Tensor<T>>
Get the gradient tensor associated with the given tensor, or, if it does not exist, insert a tensor of zeroes, with the same shape and type as the given tensors and return it
Sourcepub fn get_ids(&self) -> impl Iterator<Item = &TensorId>
pub fn get_ids(&self) -> impl Iterator<Item = &TensorId>
Get the tensor ids of the stored gradient tensors
pub fn tensors(&self) -> impl Iterator<Item = &Tensor<T>>
pub fn iter(&self) -> Iter<'_, TensorId, Tensor<T>>
pub fn len(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for GradStore<T>
impl<T> RefUnwindSafe for GradStore<T>where
T: RefUnwindSafe,
impl<T> Send for GradStore<T>
impl<T> Sync for GradStore<T>
impl<T> Unpin for GradStore<T>
impl<T> UnsafeUnpin for GradStore<T>
impl<T> UnwindSafe for GradStore<T>where
T: RefUnwindSafe,
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