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

The accessor containing all the information needed to access an item in a LabeledAxis. More...

Detailed Description

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
 
 ~LabeledAxisAccessor ()
 
template<typename... S>
 LabeledAxisAccessor (const char *name, S &&... names)
 
template<typename... S>
 LabeledAxisAccessor (const std::string &name, S &&... names)
 
template<typename Container , typename = std::enable_if_t<!std::is_convertible_v<Container, 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
 
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 (size_t n) const
 Remove the leading n items from the labels.
 
LabeledAxisAccessor slice (size_t n1, size_t n2) const
 Extract out the labels from n1 to n2.
 
LabeledAxisAccessor remount (const LabeledAxisAccessor &axis, size_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 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
 

Member Typedef Documentation

◆ const_iterator

using const_iterator = c10::SmallVector<std::string>::const_iterator

◆ iterator

using iterator = c10::SmallVector<std::string>::iterator

Constructor & Destructor Documentation

◆ LabeledAxisAccessor() [1/4]

LabeledAxisAccessor ( )
default

◆ ~LabeledAxisAccessor()

~LabeledAxisAccessor ( )
inline

◆ LabeledAxisAccessor() [2/4]

template<typename... S>
LabeledAxisAccessor ( const char * name,
S &&... names )
inline

◆ LabeledAxisAccessor() [3/4]

template<typename... S>
LabeledAxisAccessor ( const std::string & name,
S &&... names )
inline

◆ LabeledAxisAccessor() [4/4]

template<typename Container , typename = std::enable_if_t<!std::is_convertible_v<Container, std::string>>>
LabeledAxisAccessor ( const Container & c)
inline

Member Function Documentation

◆ append()

Append another accessor.

◆ begin() [1/2]

iterator begin ( )
inline

◆ begin() [2/2]

const_iterator begin ( ) const
inline

◆ empty()

bool empty ( ) const

◆ end() [1/2]

iterator end ( )
inline

◆ end() [2/2]

const_iterator end ( ) const
inline

◆ old()

LabeledAxisAccessor old ( ) const

Returns the "old" counterpart.

◆ operator std::vector< std::string >()

operator std::vector< std::string > ( ) const
explicit

◆ prepend()

Prepend another accessor.

◆ remount()

LabeledAxisAccessor remount ( const LabeledAxisAccessor & axis,
size_t n = 1 ) const

A combination of slice and prepend.

◆ size()

size_t size ( ) const

◆ slice() [1/2]

LabeledAxisAccessor slice ( size_t n) const

Remove the leading n items from the labels.

◆ slice() [2/2]

LabeledAxisAccessor slice ( size_t n1,
size_t n2 ) const

Extract out the labels from n1 to n2.

◆ start_with()

bool start_with ( const LabeledAxisAccessor & axis) const

Check if this accessor begins with another accessor.

◆ vec()

const c10::SmallVector< std::string > & vec ( ) const
inline

◆ with_suffix()

LabeledAxisAccessor with_suffix ( const std::string & suffix) const

Append a suffix to the final item name.