NEML2 1.4.0
Loading...
Searching...
No Matches
LabeledMatrix Class Reference

A single-batched, logically 2D LabeledTensor. More...

Detailed Description

A single-batched, logically 2D LabeledTensor.

#include <LabeledMatrix.h>

Inheritance diagram for LabeledMatrix:

Public Member Functions

void accumulate (const LabeledMatrix &other, bool recursive=true)
 
void fill (const LabeledMatrix &other, bool recursive=true)
 
LabeledMatrix chain (const LabeledMatrix &other) const
 Chain rule product of two derivatives.
 
LabeledMatrix inverse () const
 Invert a LabeledMatrix for use in an implicit function derivative.
 
- Public Member Functions inherited from LabeledTensor< LabeledMatrix, 2 >
 LabeledTensor ()=default
 Default constructor.
 
 LabeledTensor (const torch::Tensor &tensor, TorchSize batch_dim, const std::vector< const LabeledAxis * > &axes)
 Construct from a Tensor with batch dim and vector of LabeledAxis
 
 LabeledTensor (const BatchTensor &tensor, const std::vector< const LabeledAxis * > &axes)
 Construct from a BatchTensor with vector of LabeledAxis
 
 LabeledTensor (const LabeledMatrix &other)
 Copy constructor.
 
void operator= (const LabeledMatrix &other)
 Assignment operator.
 
 operator BatchTensor () const
 A potentially dangerous implicit conversion.
 
 operator torch::Tensor () const
 A potentially dangerous implicit conversion.
 
LabeledMatrix clone (torch::MemoryFormat memory_format=torch::MemoryFormat::Contiguous) const
 Clone this LabeledTensor.
 
void copy_ (const T &other)
 Copy the value from another tensor.
 
LabeledMatrix detach () const
 Return a copy without gradient graphs.
 
void detach_ ()
 Detach from gradient graphs.
 
void zero_ ()
 Zero out this tensor.
 
torch::TensorOptions options () const
 Get the tensor options.
 
TorchSize batch_dim () const
 Return the number of batch dimensions.
 
TorchSize base_dim () const
 Return the number of base dimensions.
 
TorchShapeRef batch_sizes () const
 Return the batch size.
 
TorchShapeRef base_sizes () const
 Return the base size.
 
const std::vector< const LabeledAxis * > & axes () const
 Get all the labeled axes.
 
const LabeledAxisaxis (TorchSize i=0) const
 Get a specific labeled axis.
 
TorchSlice slice_indices (S &&... names) const
 How to slice the tensor given the names on each axis.
 
TorchShapeRef storage_size () const
 The shape of the entire LabeledTensor.
 
TorchShape storage_size (S &&... names) const
 The shape of a sub-block specified by the names on each dimension.
 
BatchTensor operator() (S &&... names) const
 
LabeledMatrix slice (TorchSize i, const std::string &name) const
 Slice the tensor on the given dimension by a single variable or sub-axis.
 
LabeledMatrix block (S &&... names) const
 Get the sub-block labeled by the given sub-axis names.
 
LabeledMatrix batch_index (TorchSlice indices) const
 Get a batch.
 
void batch_index_put (TorchSlice indices, const torch::Tensor &other)
 Set a index sliced on the batch dimensions to a value.
 
BatchTensor base_index (TorchSlice indices) const
 Return an index sliced on the batch dimensions.
 
void base_index_put (TorchSlice indices, const torch::Tensor &other)
 Set a index sliced on the batch dimensions to a value.
 
variable_type< T >::type get (S &&... names) const
 Get and interpret the view as an object.
 
variable_type< T >::type get_list (S &&... names) const
 Get and interpret the view as a list of objects.
 
void set (const BatchTensorBase< T > &value, S &&... names)
 Set and interpret the input as an object.
 
void set_list (const BatchTensorBase< T > &value, S &&... names)
 Set and interpret the input as a list of objects.
 
LabeledMatrix operator- () const
 Negation.
 
LabeledMatrix to (const torch::TensorOptions &options) const
 Change tensor options.
 
const BatchTensortensor () const
 
BatchTensortensor ()
 

Static Public Member Functions

static LabeledMatrix identity (TorchShapeRef batch_size, const LabeledAxis &axis, const torch::TensorOptions &options=default_tensor_options())
 Create a labeled identity tensor.
 
- Static Public Member Functions inherited from LabeledTensor< LabeledMatrix, 2 >
static LabeledMatrix empty (TorchShapeRef batch_shape, const std::vector< const LabeledAxis * > &axes, const torch::TensorOptions &options=default_tensor_options())
 Setup new empty storage.
 
static LabeledMatrix empty_like (const LabeledMatrix &other)
 Setup new empty storage like another LabeledTensor.
 
static LabeledMatrix zeros (TorchShapeRef batch_shape, const std::vector< const LabeledAxis * > &axes, const torch::TensorOptions &options=default_tensor_options())
 Setup new storage with zeros.
 
static LabeledMatrix zeros_like (const LabeledMatrix &other)
 Setup new storage with zeros like another LabeledTensor.
 

Additional Inherited Members

- Protected Attributes inherited from LabeledTensor< LabeledMatrix, 2 >
BatchTensor _tensor
 The tensor.
 
std::vector< const LabeledAxis * > _axes
 The labeled axes of this tensor.
 

Member Function Documentation

◆ accumulate()

void accumulate ( const LabeledMatrix & other,
bool recursive = true )

Add another matrix into this matrix. The item set of the other matrix must be a subset of this matrix's item set.

◆ chain()

LabeledMatrix chain ( const LabeledMatrix & other) const

Chain rule product of two derivatives.

◆ fill()

void fill ( const LabeledMatrix & other,
bool recursive = true )

Fill another matrix into this matrix. The item set of the other matrix must be a subset of this matrix's item set.

◆ identity()

LabeledMatrix identity ( TorchShapeRef batch_size,
const LabeledAxis & axis,
const torch::TensorOptions & options = default_tensor_options() )
static

Create a labeled identity tensor.

◆ inverse()

LabeledMatrix inverse ( ) const

Invert a LabeledMatrix for use in an implicit function derivative.