|
NEML2 2.0.0
|
A labeled axis is used to associate layout of a tensor with human-interpretable names. More...
A labeled axis is used to associate layout of a tensor with human-interpretable names.
A one-dimensional tensor requires one LabeledAxis, two-dimensional tensor requires two LabeledAxis, and so on. See Model assembly for a detailed explanation of tensor labeling and assembly.
Variables and axes can only be added during the setup stage. Adding items after the setup stage is forbidden and will result in a runtime error in Debug mode.
#include <LabeledAxis.h>
Public Member Functions | |
| LabeledAxis ()=default | |
| Empty constructor. | |
| LabeledAxis (LabeledAxisAccessor prefix) | |
| Sub-axis constructor. | |
| void | clear () |
| De-initialize the axis. | |
| bool | is_setup () const |
| Whether the axis has been set up. | |
| LabeledAxisAccessor | qualify (const LabeledAxisAccessor &accessor) const |
| Return the fully qualified name of an item (i.e. useful when this axis is a sub-axis) | |
| LabeledAxisAccessor | disqualify (const LabeledAxisAccessor &accessor) const |
| Return the disqualified name of an item (i.e. remove the prefix) | |
| LabeledAxis & | add_subaxis (const std::string &name) |
| Add a sub-axis. | |
| void | add_variable (const LabeledAxisAccessor &name, TensorShapeRef intmd_sizes, TensorShapeRef base_sizes) |
| Add a variable with known storage size. | |
| void | set_intmd_sizes (const LabeledAxisAccessor &name, TensorShapeRef shape) |
| Set intermediate shape of a variable. | |
| void | setup_layout () |
| Setup the layout of all items recursively. | |
| Size | size () const |
| Get the storage size of the entire axis. | |
| Size | size (const LabeledAxisAccessor &name) const |
| Get the storage size of a variable or a local sub-axis. | |
| indexing::Slice | slice (const LabeledAxisAccessor &name) const |
| Get the slicing indices of a variable or a local sub-axis. | |
| bool | equals (const LabeledAxis &other) const |
| Check to see if two axes are equivalent. | |
| std::size_t | nvariable () const |
| bool | has_variable (const LabeledAxisAccessor &name) const |
| Check the existence of a variable by its name. | |
| std::size_t | variable_id (const LabeledAxisAccessor &name) const |
| Get the assembly ID of a variable. | |
| std::vector< LabeledAxisAccessor > | variable_names_unsrt () const |
| Get variable names in unsorted order. | |
| const std::vector< LabeledAxisAccessor > & | variable_names () const |
| Get the variable names. | |
| const std::vector< std::pair< Size, Size > > & | variable_slices () const |
| Get the variable slicing indices (in assembly order) | |
| const std::pair< Size, Size > & | variable_slice (const LabeledAxisAccessor &name) const |
| Get the slicing indices of a variable by name. | |
| const std::vector< Size > & | variable_sizes () const |
| Get the variable storage sizes (in assembly order) | |
| Size | variable_size (const LabeledAxisAccessor &name) const |
| Get the storage size of a variable by name. | |
| const std::vector< TensorShape > & | variable_intmd_sizes () const |
| Get the variable left-batch shapes (in assembly order) | |
| const std::vector< TensorShape > & | variable_base_sizes () const |
| Get the variable base shapes (in assembly order) | |
| std::size_t | nsubaxis () const |
| bool | has_subaxis (const LabeledAxisAccessor &name) const |
| Check the existence of a subaxis by its name. | |
| std::size_t | subaxis_id (const std::string &name) const |
| Get the assembly ID of a sub-axis. | |
| const std::vector< const LabeledAxis * > & | subaxes () const |
| Get the sub-axes (in assembly order) | |
| const LabeledAxis & | subaxis (const LabeledAxisAccessor &name) const |
| Get a sub-axis by name. | |
| LabeledAxis & | subaxis (const LabeledAxisAccessor &name) |
| Get a sub-axis by name. | |
| std::vector< std::string > | subaxis_names_unsrt () const |
| Get subaxis names in unsorted order. | |
| const std::vector< std::string > & | subaxis_names () const |
| Get the sub-axis names. | |
| const std::vector< std::pair< Size, Size > > & | subaxis_slices () const |
| Get the sub-axis slicing indices (in assembly order) | |
| std::pair< Size, Size > | subaxis_slice (const LabeledAxisAccessor &name) const |
| Get the slicing indices of a sub-axis by name. | |
| const std::vector< Size > & | subaxis_sizes () const |
| Get the sub-axis storage sizes (in assembly order) | |
| Size | subaxis_size (const LabeledAxisAccessor &name) const |
| Get the storage size of a sub-axis by name. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const LabeledAxis &axis) |
|
default |
Empty constructor.
| LabeledAxis | ( | LabeledAxisAccessor | prefix | ) |
Sub-axis constructor.
| LabeledAxis & add_subaxis | ( | const std::string & | name | ) |
Add a sub-axis.
| void add_variable | ( | const LabeledAxisAccessor & | name, |
| TensorShapeRef | intmd_sizes, | ||
| TensorShapeRef | base_sizes ) |
Add a variable with known storage size.
| void clear | ( | ) |
De-initialize the axis.
| LabeledAxisAccessor disqualify | ( | const LabeledAxisAccessor & | accessor | ) | const |
Return the disqualified name of an item (i.e. remove the prefix)
| bool equals | ( | const LabeledAxis & | other | ) | const |
Check to see if two axes are equivalent.
| bool has_subaxis | ( | const LabeledAxisAccessor & | name | ) | const |
Check the existence of a subaxis by its name.
| bool has_variable | ( | const LabeledAxisAccessor & | name | ) | const |
Check the existence of a variable by its name.
|
inline |
Whether the axis has been set up.
| std::size_t nsubaxis | ( | ) | const |
Get sub-axis information Number of subaxes
| std::size_t nvariable | ( | ) | const |
Get variable information Number of variables
| LabeledAxisAccessor qualify | ( | const LabeledAxisAccessor & | accessor | ) | const |
Return the fully qualified name of an item (i.e. useful when this axis is a sub-axis)
| void set_intmd_sizes | ( | const LabeledAxisAccessor & | name, |
| TensorShapeRef | shape ) |
Set intermediate shape of a variable.
| void setup_layout | ( | ) |
Setup the layout of all items recursively.
| Size size | ( | ) | const |
Get the storage size of the entire axis.
| Size size | ( | const LabeledAxisAccessor & | name | ) | const |
Get the storage size of a variable or a local sub-axis.
| indexing::Slice slice | ( | const LabeledAxisAccessor & | name | ) | const |
Get the slicing indices of a variable or a local sub-axis.
| const std::vector< const LabeledAxis * > & subaxes | ( | ) | const |
Get the sub-axes (in assembly order)
| LabeledAxis & subaxis | ( | const LabeledAxisAccessor & | name | ) |
Get a sub-axis by name.
| const LabeledAxis & subaxis | ( | const LabeledAxisAccessor & | name | ) | const |
Get a sub-axis by name.
| std::size_t subaxis_id | ( | const std::string & | name | ) | const |
Get the assembly ID of a sub-axis.
| const std::vector< std::string > & subaxis_names | ( | ) | const |
Get the sub-axis names.
| std::vector< std::string > subaxis_names_unsrt | ( | ) | const |
Get subaxis names in unsorted order.
| Size subaxis_size | ( | const LabeledAxisAccessor & | name | ) | const |
Get the storage size of a sub-axis by name.
| const std::vector< Size > & subaxis_sizes | ( | ) | const |
Get the sub-axis storage sizes (in assembly order)
| std::pair< Size, Size > subaxis_slice | ( | const LabeledAxisAccessor & | name | ) | const |
Get the slicing indices of a sub-axis by name.
Get the sub-axis slicing indices (in assembly order)
| const std::vector< TensorShape > & variable_base_sizes | ( | ) | const |
Get the variable base shapes (in assembly order)
| std::size_t variable_id | ( | const LabeledAxisAccessor & | name | ) | const |
Get the assembly ID of a variable.
| const std::vector< TensorShape > & variable_intmd_sizes | ( | ) | const |
Get the variable left-batch shapes (in assembly order)
| const std::vector< LabeledAxisAccessor > & variable_names | ( | ) | const |
Get the variable names.
| std::vector< LabeledAxisAccessor > variable_names_unsrt | ( | ) | const |
Get variable names in unsorted order.
| Size variable_size | ( | const LabeledAxisAccessor & | name | ) | const |
Get the storage size of a variable by name.
| const std::vector< Size > & variable_sizes | ( | ) | const |
Get the variable storage sizes (in assembly order)
| const std::pair< Size, Size > & variable_slice | ( | const LabeledAxisAccessor & | name | ) | const |
Get the slicing indices of a variable by name.
Get the variable slicing indices (in assembly order)
|
friend |