NEML2 2.0.0
|
The accessor containing all the information needed to access an item in a LabeledAxis
.
More...
The accessor containing all the information needed to access an item in a LabeledAxis
.
The accessor consists of an arbitrary number of item names. The last item name can be either a variable name or a sub-axis name. All the other item names are considered to be sub-axis names.
The LabeledAxisAccessor stores the item labels and does not resolve the actual layout of the item. This way an accessor can be used access the same variable from different tensor layouts.
The item names cannot contain whitespace, ".", ",", ";", or "/".
#include <LabeledAxisAccessor.h>
Public Types | |
using | iterator = c10::SmallVector<std::string>::iterator |
using | const_iterator = c10::SmallVector<std::string>::const_iterator |
Public Member Functions | |
LabeledAxisAccessor ()=default | |
template<typename... S> | |
LabeledAxisAccessor (const char *name, S &&... names) | |
template<typename... S> | |
LabeledAxisAccessor (const std::string &name, S &&... names) | |
template<typename Container , typename = typename std::enable_if_t< !std::is_convertible_v<Container, std::string> && std::is_convertible_v<typename std::iterator_traits< decltype(std::declval<Container>().begin())>::value_type, std::string> && std::is_convertible_v<typename std::iterator_traits< decltype(std::declval<Container>().end())>::value_type, std::string > > > | |
LabeledAxisAccessor (const Container &c) | |
operator std::vector< std::string > () const | |
const c10::SmallVector< std::string > & | vec () const |
bool | empty () const |
size_t | size () const |
const std::string & | operator[] (size_t i) const |
LabeledAxisAccessor | with_suffix (const std::string &suffix) const |
Append a suffix to the final item name. | |
LabeledAxisAccessor | append (const LabeledAxisAccessor &axis) const |
Append another accessor. | |
LabeledAxisAccessor | prepend (const LabeledAxisAccessor &axis) const |
Prepend another accessor. | |
LabeledAxisAccessor | slice (int64_t n) const |
Remove the leading n items from the labels. | |
LabeledAxisAccessor | slice (int64_t n1, int64_t n2) const |
Extract out the labels from n1 to n2 . | |
LabeledAxisAccessor | remount (const LabeledAxisAccessor &axis, int64_t n=1) const |
A combination of slice and prepend. | |
bool | start_with (const LabeledAxisAccessor &axis) const |
Check if this accessor begins with another accessor. | |
LabeledAxisAccessor | current () const |
Returns the "current" counterpart. | |
LabeledAxisAccessor | old () const |
Returns the "old" counterpart. | |
Iterators | |
Begin and end iterators for the underlying data. | |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
bool | is_state () const |
bool | is_old_state () const |
bool | is_force () const |
bool | is_old_force () const |
bool | is_residual () const |
bool | is_parameter () const |
using const_iterator = c10::SmallVector<std::string>::const_iterator |
|
default |
|
inline |
|
inline |
|
inline |
LabeledAxisAccessor append | ( | const LabeledAxisAccessor & | axis | ) | const |
Append another accessor.
|
inline |
|
inline |
LabeledAxisAccessor current | ( | ) | const |
Returns the "current" counterpart.
bool empty | ( | ) | const |
|
inline |
|
inline |
bool is_force | ( | ) | const |
bool is_old_force | ( | ) | const |
bool is_old_state | ( | ) | const |
bool is_parameter | ( | ) | const |
bool is_residual | ( | ) | const |
bool is_state | ( | ) | const |
Check if the accessor is on a specific sub-axis
LabeledAxisAccessor old | ( | ) | const |
Returns the "old" counterpart.
|
explicit |
LabeledAxisAccessor prepend | ( | const LabeledAxisAccessor & | axis | ) | const |
Prepend another accessor.
LabeledAxisAccessor remount | ( | const LabeledAxisAccessor & | axis, |
int64_t | n = 1 ) const |
A combination of slice and prepend.
size_t size | ( | ) | const |
LabeledAxisAccessor slice | ( | int64_t | n | ) | const |
Remove the leading n
items from the labels.
LabeledAxisAccessor slice | ( | int64_t | n1, |
int64_t | n2 ) const |
Extract out the labels from n1
to n2
.
bool start_with | ( | const LabeledAxisAccessor & | axis | ) | const |
Check if this accessor begins with another accessor.
|
inline |
LabeledAxisAccessor with_suffix | ( | const std::string & | suffix | ) | const |
Append a suffix to the final item name.