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

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

Detailed Description

A single-batched, logically 1D LabeledTensor.

#include <LabeledVector.h>

Inheritance diagram for LabeledVector:

Public Member Functions

LabeledVector slice (const std::string &name) const
 Slice the logically 1D tensor by a single sub-axis.
 
void fill (const LabeledVector &other, bool recursive=true)
 
- Public Member Functions inherited from LabeledTensor< LabeledVector, 1 >
 LabeledTensor ()=default
 Default constructor.
 
 LabeledTensor (const torch::Tensor &tensor, const std::array< const LabeledAxis *, D > &axes)
 Construct from a torch::Tensor and array of LabeledAxis
 
 LabeledTensor (const Tensor &tensor, const std::array< const LabeledAxis *, D > &axes)
 Construct from a Tensor with array of LabeledAxis
 
 LabeledTensor (const LabeledVector &other)
 Copy constructor.
 
LabeledTensor< LabeledVector, D > & operator= (const LabeledVector &other)
 Assignment operator.
 
reinterpret (indexing::TensorLabelsRef indices) const
 Get a tensor by slicing on the base dimensions AND reinterpret it as a primitive tensor.
 
const std::array< const LabeledAxis *, D > & axes () const
 Get all the labeled axes.
 
const LabeledAxisaxis (Size i=0) const
 Get a specific labeled axis.
 
 operator Tensor () const
 
 operator torch::Tensor () const
 
const Tensortensor () const
 
Tensortensor ()
 
LabeledVector clone (torch::MemoryFormat memory_format=torch::MemoryFormat::Contiguous) const
 
LabeledVector detach () const
 Return a copy without gradient graphs.
 
void detach_ ()
 Detach from gradient graphs.
 
LabeledVector to (const torch::TensorOptions &options) const
 Change tensor options.
 
void copy_ (const torch::Tensor &other)
 Copy another tensor.
 
void zero_ ()
 Set all entries to zero.
 
bool requires_grad () const
 Get the requires_grad property.
 
void requires_grad_ (bool req=true)
 Set the requires_grad property.
 
LabeledVector operator- () const
 Negation.
 
torch::TensorOptions options () const
 
torch::Dtype scalar_type () const
 Tensor options.
 
torch::Device device () const
 Tensor options.
 
Size dim () const
 Number of tensor dimensions.
 
TensorShapeRef sizes () const
 Tensor shape.
 
Size size (Size dim) const
 Tensor shape.
 
bool batched () const
 Whether the tensor is batched.
 
Size batch_dim () const
 Return the number of batch dimensions.
 
constexpr Size base_dim () const
 Return the number of base dimensions.
 
TensorShapeRef batch_sizes () const
 Return the batch size.
 
Size batch_size (Size d) const
 Return the length of some batch axis.
 
TensorShapeRef base_sizes () const
 Return the base size.
 
Size base_size (Size d) const
 Return the length of some base axis.
 
Size base_storage () const
 Return the flattened storage needed just for the base indices.
 
LabeledVector batch_index (indexing::TensorIndicesRef indices) const
 
Tensor base_index (indexing::TensorLabelsRef labels) const
 Get a tensor by slicing on the base dimensions.
 
void batch_index_put_ (indexing::TensorIndicesRef indices, const torch::Tensor &other)
 Set values by slicing on the batch dimensions.
 
void base_index_put_ (indexing::TensorLabelsRef labels, const Tensor &other)
 Set values by slicing on the base dimensions.
 

Additional Inherited Members

- Static Public Member Functions inherited from LabeledTensor< LabeledVector, 1 >
static LabeledVector empty (TensorShapeRef batch_shape, const std::array< const LabeledAxis *, D > &axes, const torch::TensorOptions &options=default_tensor_options())
 Setup new empty storage.
 
static LabeledVector zeros (TensorShapeRef batch_shape, const std::array< const LabeledAxis *, D > &axes, const torch::TensorOptions &options=default_tensor_options())
 Setup new storage with zeros.
 
- Protected Attributes inherited from LabeledTensor< LabeledVector, 1 >
Tensor _tensor
 The tensor.
 
std::array< const LabeledAxis *, D_axes
 The labeled axes of this tensor.
 

Member Function Documentation

◆ fill()

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

Fill (override) another vector into this vector. The item set of the other vector must be a subset of this vector's item set.

◆ slice()

LabeledVector slice ( const std::string & name) const

Slice the logically 1D tensor by a single sub-axis.