ArmNN
 24.02
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 708 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 711 of file BaseIterator.hpp.

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

◆ PerAxisIterator() [2/2]

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

Definition at line 722 of file BaseIterator.hpp.

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

Member Function Documentation

◆ operator++()

PerAxisIterator& operator++ ( )
inlineoverride

Definition at line 742 of file BaseIterator.hpp.

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

◆ operator+=()

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

Definition at line 749 of file BaseIterator.hpp.

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

◆ operator-=()

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

Definition at line 756 of file BaseIterator.hpp.

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

◆ operator[]()

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

◆ Reset()

void Reset ( void *  data)
inlineoverride

Definition at line 734 of file BaseIterator.hpp.

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

◆ SetIndexOnMem()

PerAxisIterator& SetIndexOnMem ( const unsigned int  index)
inline

Definition at line 764 of file BaseIterator.hpp.

765  {
767  m_Iterator = m_Start + index;
768  if (index < m_AxisFactor)
769  {
770  m_AxisIndex = 0;
771  }
772  else
773  {
775  }
776  m_Index = index;
777  return *this;
778  }

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_ASSERT
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
armnn::PerAxisIterator::m_AxisIndex
unsigned int m_AxisIndex
Definition: BaseIterator.hpp:789
armnn::PerAxisIterator::m_Iterator
T * m_Iterator
Definition: BaseIterator.hpp:787
armnn::PerAxisIterator::m_Start
T * m_Start
Definition: BaseIterator.hpp:788
armnn::PerAxisIterator::SetIndexOnMem
PerAxisIterator & SetIndexOnMem(const unsigned int index)
Definition: BaseIterator.hpp:764
armnn::PerAxisIterator::operator[]
PerAxisIterator & operator[](const unsigned int index) override
Definition: BaseIterator.hpp:780
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:791
armnn::PerAxisIterator::m_Index
unsigned int m_Index
Definition: BaseIterator.hpp:792
armnn::PerAxisIterator::m_AxisDimensionality
unsigned int m_AxisDimensionality
Definition: BaseIterator.hpp:790