ArmNN
 24.08
PerAxisIterator< T, Base > Class Template Reference

PerAxisIterator for per-axis quantization. More...

#include <BaseIterator.hpp>

Inheritance diagram for PerAxisIterator< T, Base >:
[legend]
Collaboration diagram for PerAxisIterator< T, Base >:
[legend]

Public Member Functions

 PerAxisIterator (T *data=nullptr, unsigned int axisFactor=0, unsigned int axisDimensionality=0)
 
 PerAxisIterator (T *data=nullptr, const armnn::TensorShape &tensorShape=TensorShape(), const unsigned int axis=0)
 
void Reset (void *data) override
 
PerAxisIteratoroperator++ () override
 
PerAxisIteratoroperator+= (const unsigned int increment) override
 
PerAxisIteratoroperator-= (const unsigned int decrement) override
 
PerAxisIteratorSetIndexOnMem (const unsigned int index)
 
PerAxisIteratoroperator[] (const unsigned int index) override
 

Protected Attributes

T * m_Iterator
 
T * m_Start
 
unsigned int m_AxisIndex
 
unsigned int m_AxisDimensionality
 
unsigned int m_AxisFactor
 
unsigned int m_Index
 

Detailed Description

template<typename T, typename Base>
class armnn::PerAxisIterator< T, Base >

PerAxisIterator for per-axis quantization.

Iterates over a tensor as layed out in memory and keeps track of the axis index.

Definition at line 707 of file BaseIterator.hpp.

Constructor & Destructor Documentation

◆ PerAxisIterator() [1/2]

PerAxisIterator ( T *  data = nullptr,
unsigned int  axisFactor = 0,
unsigned int  axisDimensionality = 0 
)
inline

Definition at line 710 of file BaseIterator.hpp.

713  : m_Iterator(data),
714  m_Start(data),
715  m_AxisIndex(0), // iterates over the dimension of axis
716  m_AxisDimensionality(axisDimensionality), // tensorShape[quantization_dim]
717  m_AxisFactor(axisFactor),
718  m_Index(0)
719  {}

◆ PerAxisIterator() [2/2]

PerAxisIterator ( T *  data = nullptr,
const armnn::TensorShape tensorShape = TensorShape(),
const unsigned int  axis = 0 
)
inline

Definition at line 721 of file BaseIterator.hpp.

724  : m_Iterator(data),
725  m_Start(data),
726  m_AxisIndex(0),
727  m_Index(0)
728  {
729  m_AxisDimensionality = tensorShape[axis];
730  m_AxisFactor = armnnUtils::GetNumElementsAfter(tensorShape, axis);
731  }

Member Function Documentation

◆ operator++()

PerAxisIterator& operator++ ( )
inlineoverride

Definition at line 741 of file BaseIterator.hpp.

742  {
743  ++m_Index;
744  this -> operator[](m_Index);
745  return *this;
746  }

◆ operator+=()

PerAxisIterator& operator+= ( const unsigned int  increment)
inlineoverride

Definition at line 748 of file BaseIterator.hpp.

749  {
750  m_Index += increment;
751  this -> operator[](m_Index);
752  return *this;
753  }

◆ operator-=()

PerAxisIterator& operator-= ( const unsigned int  decrement)
inlineoverride

Definition at line 755 of file BaseIterator.hpp.

756  {
757  m_Index -= decrement;
758  this -> operator[](m_Index);
759  return *this;
760  }

◆ operator[]()

PerAxisIterator& operator[] ( const unsigned int  index)
inlineoverride

◆ Reset()

void Reset ( void *  data)
inlineoverride

Definition at line 733 of file BaseIterator.hpp.

734  {
735  m_Iterator = reinterpret_cast<T*>(data);
737  m_AxisIndex = 0;
738  m_Index = 0;
739  }

◆ SetIndexOnMem()

PerAxisIterator& SetIndexOnMem ( const unsigned int  index)
inline

Definition at line 763 of file BaseIterator.hpp.

764  {
765  ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(m_Iterator, "PerAxisIterator: m_Iterator is null!");
766  m_Iterator = m_Start + index;
767  if (index < m_AxisFactor || m_AxisDimensionality < 1)
768  {
769  m_AxisIndex = 0;
770  }
771  else
772  {
774  }
775  m_Index = index;
776  return *this;
777  }

Referenced by PerAxisIterator< const int8_t, Decoder< float > >::operator[]().

Member Data Documentation

◆ m_AxisDimensionality

◆ m_AxisFactor

◆ m_AxisIndex

◆ m_Index

◆ m_Iterator

◆ m_Start


The documentation for this class was generated from the following file:
armnn::PerAxisIterator::m_AxisIndex
unsigned int m_AxisIndex
Definition: BaseIterator.hpp:788
armnn::PerAxisIterator::m_Iterator
T * m_Iterator
Definition: BaseIterator.hpp:786
armnn::PerAxisIterator::m_Start
T * m_Start
Definition: BaseIterator.hpp:787
armnn::PerAxisIterator::SetIndexOnMem
PerAxisIterator & SetIndexOnMem(const unsigned int index)
Definition: BaseIterator.hpp:763
armnn::PerAxisIterator::operator[]
PerAxisIterator & operator[](const unsigned int index) override
Definition: BaseIterator.hpp:779
armnnUtils::GetNumElementsAfter
unsigned int GetNumElementsAfter(const armnn::TensorShape &shape, unsigned int axis)
Definition: TensorUtils.cpp:261
armnn::PerAxisIterator::m_AxisFactor
unsigned int m_AxisFactor
Definition: BaseIterator.hpp:790
armnn::PerAxisIterator::m_Index
unsigned int m_Index
Definition: BaseIterator.hpp:791
armnn::PerAxisIterator::m_AxisDimensionality
unsigned int m_AxisDimensionality
Definition: BaseIterator.hpp:789
ARMNN_THROW_INVALIDARG_MSG_IF_FALSE
#define ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(_cond, _str)
Definition: Exceptions.hpp:210