NEML2 1.4.0
|
A single-batched, logically 1D LabeledTensor. More...
A single-batched, logically 1D LabeledTensor.
#include <LabeledVector.h>
Public Member Functions | |
LabeledVector | slice (const std::string &name) const |
Slice the logically 1D tensor by a single sub-axis. | |
void | accumulate (const LabeledVector &other, bool recursive=true) |
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, 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 LabeledVector &other) | |
Copy constructor. | |
void | operator= (const LabeledVector &other) |
Assignment operator. | |
operator BatchTensor () const | |
A potentially dangerous implicit conversion. | |
operator torch::Tensor () const | |
A potentially dangerous implicit conversion. | |
LabeledVector | clone (torch::MemoryFormat memory_format=torch::MemoryFormat::Contiguous) const |
Clone this LabeledTensor. | |
void | copy_ (const T &other) |
Copy the value from another tensor. | |
LabeledVector | 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 LabeledAxis & | axis (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 |
LabeledVector | slice (TorchSize i, const std::string &name) const |
Slice the tensor on the given dimension by a single variable or sub-axis. | |
LabeledVector | block (S &&... names) const |
Get the sub-block labeled by the given sub-axis names. | |
LabeledVector | 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. | |
LabeledVector | operator- () const |
Negation. | |
LabeledVector | to (const torch::TensorOptions &options) const |
Change tensor options. | |
const BatchTensor & | tensor () const |
BatchTensor & | tensor () |
Additional Inherited Members | |
Static Public Member Functions inherited from LabeledTensor< LabeledVector, 1 > | |
static LabeledVector | empty (TorchShapeRef batch_shape, const std::vector< const LabeledAxis * > &axes, const torch::TensorOptions &options=default_tensor_options()) |
Setup new empty storage. | |
static LabeledVector | empty_like (const LabeledVector &other) |
Setup new empty storage like another LabeledTensor. | |
static LabeledVector | zeros (TorchShapeRef batch_shape, const std::vector< const LabeledAxis * > &axes, const torch::TensorOptions &options=default_tensor_options()) |
Setup new storage with zeros. | |
static LabeledVector | zeros_like (const LabeledVector &other) |
Setup new storage with zeros like another LabeledTensor. | |
Protected Attributes inherited from LabeledTensor< LabeledVector, 1 > | |
BatchTensor | _tensor |
The tensor. | |
std::vector< const LabeledAxis * > | _axes |
The labeled axes of this tensor. | |
void accumulate | ( | const LabeledVector & | other, |
bool | recursive = true ) |
Add another vector into this vector. The item set of the other vector must be a subset of this vector's item set.
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.
LabeledVector slice | ( | const std::string & | name | ) | const |
Slice the logically 1D tensor by a single sub-axis.