pub struct TensorBlockRef<'a> { /* private fields */ }
Expand description
Reference to a TensorBlock
Implementations§
Source§impl<'a> TensorBlockRef<'a>
impl<'a> TensorBlockRef<'a>
Sourcepub fn data(&'a self) -> TensorBlockData<'a>
pub fn data(&'a self) -> TensorBlockData<'a>
Get all the data and metadata inside this TensorBlockRef
as a
struct with separate fields, to allow borrowing them separately.
Sourcepub fn components(&self) -> Vec<Labels>
pub fn components(&self) -> Vec<Labels>
Get the components for this block
Sourcepub fn properties(&self) -> Labels
pub fn properties(&self) -> Labels
Get the properties for this block
Sourcepub fn gradient_list(&self) -> Vec<&'a str>
pub fn gradient_list(&self) -> Vec<&'a str>
Get the full list of gradients in this block
Sourcepub fn gradient(&self, parameter: &str) -> Option<TensorBlockRef<'a>>
pub fn gradient(&self, parameter: &str) -> Option<TensorBlockRef<'a>>
Get the data and metadata for the gradient with respect to the given parameter in this block, if it exists.
Sourcepub fn try_clone(&self) -> Result<TensorBlock, Error>
pub fn try_clone(&self) -> Result<TensorBlock, Error>
Clone this block, cloning all the data and metadata contained inside.
This can fail if the external data held inside an mts_array_t
can not
be cloned.
Sourcepub fn gradients(&self) -> GradientsIter<'_> ⓘ
pub fn gradients(&self) -> GradientsIter<'_> ⓘ
Get an iterator over parameter/TensorBlockRef
pairs for all gradients in
this block
Sourcepub fn save(&self, path: impl AsRef<Path>) -> Result<(), Error>
pub fn save(&self, path: impl AsRef<Path>) -> Result<(), Error>
Save the given block to the file at path
This is a convenience function calling crate::io::save_block
Sourcepub fn save_buffer(&self, buffer: &mut Vec<u8>) -> Result<(), Error>
pub fn save_buffer(&self, buffer: &mut Vec<u8>) -> Result<(), Error>
Save the given block to an in-memory buffer
This is a convenience function calling crate::io::save_block_buffer
Trait Implementations§
Source§impl<'a> Clone for TensorBlockRef<'a>
impl<'a> Clone for TensorBlockRef<'a>
Source§fn clone(&self) -> TensorBlockRef<'a>
fn clone(&self) -> TensorBlockRef<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more