A labeled axis used to associate layout of a tensor with human-interpretable names.
A logically one-dimensional tensor requires one LabeledAxis, two-dimensional tensor requires two LabeledAxis, and so on. See Tensor labeling for a detailed explanation of tensor labeling.
All the LabeledAxis modifiers can only be used during the setup stage. Calling any modifiers after the setup stage is forbidden and will result in a runtime error in Debug mode.
All the modifiers return the modified LabeledAxis by reference, so modifiers can be chained. For example
The wrapper (decorator) for cross-referencing unresolved values at parse time.
Definition CrossRef.h:52
A labeled axis used to associate layout of a tensor with human-interpretable names.
Definition LabeledAxis.h:55
LabeledAxis & rename(const std::string &original, const std::string &rename)
Change the label of an item.
Definition LabeledAxis.cxx:68
LabeledAxis & remove(const std::string &name)
Remove an item.
Definition LabeledAxis.cxx:94
The (logical) symmetric second order tensor.
Definition SR2.h:46
|
| LabeledAxis () |
| Empty constructor.
|
|
| LabeledAxis (const LabeledAxis &other) |
| (Shallow) copy constructor
|
|
template<typename T > |
LabeledAxis & | add (const LabeledAxisAccessor &accessor) |
| Add a variable or subaxis.
|
|
LabeledAxis & | add (const LabeledAxisAccessor &accessor, TorchSize sz) |
| Add an arbitrary variable using a LabeledAxisAccessor
|
|
LabeledAxis & | rename (const std::string &original, const std::string &rename) |
| Change the label of an item.
|
|
LabeledAxis & | remove (const std::string &name) |
| Remove an item.
|
|
LabeledAxis & | clear () |
| Clear everything.
|
|
std::vector< LabeledAxisAccessor > | merge (LabeledAxis &other) |
| Merge with another LabeledAxis .
|
|
void | setup_layout () |
|
size_t | nitem () const |
| Number of items.
|
|
size_t | nvariable () const |
| Number of variables.
|
|
size_t | nsubaxis () const |
| Number of subaxes.
|
|
bool | has_item (const LabeledAxisAccessor &name) const |
| Does the item exist?
|
|
template<typename T > |
bool | has_variable (const LabeledAxisAccessor &var) const |
| Does the variable of a given primitive type exist?
|
|
bool | has_variable (const LabeledAxisAccessor &var) const |
| Check the existence of a variable by its LabeledAxisAccessor.
|
|
bool | has_subaxis (const LabeledAxisAccessor &s) const |
| Check the existence of a subaxis by its LabeledAxisAccessor.
|
|
TorchSize | storage_size () const |
| Get the (total) storage size of this axis.
|
|
TorchSize | storage_size (const LabeledAxisAccessor &accessor) const |
| Get the storage size of an item by its LabeledAxisAccessor.
|
|
const AxisLayout & | layout () const |
| Get the layout.
|
|
TorchIndex | indices (const LabeledAxisAccessor &accessor) const |
| Get the indices of a specific item by a LabeledAxisAccessor
|
|
TorchIndex | indices (const LabeledAxis &other, bool recursive=true, bool inclusive=true) const |
| Get the indices using another LabeledAxis .
|
|
std::vector< std::pair< TorchIndex, TorchIndex > > | common_indices (const LabeledAxis &other, bool recursive=true) const |
| Get the common indices of two LabeledAxis s.
|
|
std::vector< std::string > | item_names () const |
| Get the item names.
|
|
const std::map< std::string, TorchSize > & | variables () const |
| Get the variables.
|
|
const std::map< std::string, std::shared_ptr< LabeledAxis > > & | subaxes () const |
| Get the subaxes.
|
|
std::set< LabeledAxisAccessor > | variable_accessors (bool recursive=false, const LabeledAxisAccessor &subaxis={}) const |
| Get the variable accessors.
|
|
const LabeledAxis & | subaxis (const std::string &name) const |
| Get a sub-axis.
|
|
LabeledAxis & | subaxis (const std::string &name) |
| Get a sub-axis.
|
|
bool | equals (const LabeledAxis &other) const |
| Check to see if two LabeledAxis objects are equivalent.
|
|
void | to_dot (std::ostream &os, int &id, std::string name="", bool subgraph=false, bool node_handle=false) const |
| Write this object in dot format.
|
|