Struct metatensor::TensorBlock

source ·
pub struct TensorBlock { /* private fields */ }
Expand description

A single block, containing both values & optionally gradients of these values w.r.t. any relevant quantity.

Implementations§

source§

impl TensorBlock

source

pub fn as_ref(&self) -> TensorBlockRef<'_>

Get a non mutable reference to this block

source

pub fn as_ref_mut(&mut self) -> TensorBlockRefMut<'_>

Get a non mutable reference to this block

source

pub fn values(&self) -> ArrayRef<'_>

Get the array for the values in this block

source

pub fn samples(&self) -> Labels

Get the samples for this block

source

pub fn components(&self) -> Vec<Labels>

Get the components for this block

source

pub fn properties(&self) -> Labels

Get the properties for this block

source

pub fn new( data: impl Array, samples: &Labels, components: &[Labels], properties: &Labels ) -> Result<TensorBlock, Error>

Create a new TensorBlock containing the given data, described by the samples, components, and properties labels. The block is initialized without any gradients.

source

pub fn add_gradient( &mut self, parameter: &str, gradient: TensorBlock ) -> Result<(), Error>

Add a gradient with respect to parameter to this block.

The property of the gradient should match the ones of this block. The components of the gradients must contain at least the same entries as the value components, and can prepend other components.

Trait Implementations§

source§

impl Debug for TensorBlock

source§

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

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

impl Drop for TensorBlock

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for TensorBlock

source§

impl Sync for TensorBlock

Auto Trait Implementations§

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
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.
source§

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

Performs the conversion.