ArmNN
 21.02
QSymm8PerAxisDecoder Class Reference

#include <BaseIterator.hpp>

Inheritance diagram for QSymm8PerAxisDecoder:
PerAxisIterator< const int8_t, Decoder< float > > Decoder< float > BaseIterator

Public Member Functions

 QSymm8PerAxisDecoder (const int8_t *data, const std::vector< float > &scale, unsigned int axisFactor)
 
float Get () const override
 
float GetScale () const
 
std::vector< float > DecodeTensor (const TensorShape &tensorShape, const unsigned int channelMultiplier, bool isDepthwise) override
 
- Public Member Functions inherited from PerAxisIterator< const int8_t, Decoder< float > >
 PerAxisIterator (const int8_t *data=nullptr, unsigned int axisFactor=0)
 
PerAxisIteratorSetIndex (unsigned int index, unsigned int axisIndex) override
 
void Reset (void *data) override
 
PerAxisIteratoroperator++ () override
 
PerAxisIteratoroperator+= (const unsigned int increment) override
 
PerAxisIteratoroperator-= (const unsigned int decrement) override
 
PerAxisIteratoroperator[] (const unsigned int index) override
 
- Public Member Functions inherited from Decoder< float >
 Decoder ()
 
virtual ~Decoder ()
 
- Public Member Functions inherited from BaseIterator
 BaseIterator ()
 
virtual ~BaseIterator ()
 

Additional Inherited Members

- Protected Attributes inherited from PerAxisIterator< const int8_t, Decoder< float > >
const int8_t * m_Iterator
 
const int8_t * m_Start
 
unsigned int m_AxisIndex
 
unsigned int m_AxisFactor
 

Detailed Description

Definition at line 837 of file BaseIterator.hpp.

Constructor & Destructor Documentation

◆ QSymm8PerAxisDecoder()

QSymm8PerAxisDecoder ( const int8_t *  data,
const std::vector< float > &  scale,
unsigned int  axisFactor 
)
inline

Definition at line 840 of file BaseIterator.hpp.

841  : PerAxisIterator(data, axisFactor), m_Scales(scale) {}
PerAxisIterator(const int8_t *data=nullptr, unsigned int axisFactor=0)

Member Function Documentation

◆ DecodeTensor()

std::vector<float> DecodeTensor ( const TensorShape tensorShape,
const unsigned int  channelMultiplier,
bool  isDepthwise 
)
inlineoverridevirtual

Implements Decoder< float >.

Definition at line 854 of file BaseIterator.hpp.

References armnn::Dequantize, TensorShape::GetNumElements(), and BaseIterator::operator[]().

857  {
858  const uint32_t size = tensorShape.GetNumElements();
859  const uint32_t scaleSize = static_cast<uint32_t>(m_Scales.size());
860 
861  const uint32_t stepSize = isDepthwise ?
862  tensorShape[2] * tensorShape[3] : tensorShape.GetNumElements() / tensorShape[0];
863 
864  const uint32_t stepNum = size / (stepSize * channelMultiplier);
865  uint32_t scale;
866 
867  std::vector<float> decodedTensor;
868  decodedTensor.reserve(size);
869 
870  // channelMultiplier is only used in depthwise convolutions and in other cases will have no effect
871  // stepSize is the length of a contiguous area sharing a quantization scale within a tensor
872  // stepNum is the number of those steps/blocks in the tensor
873  for (uint32_t mult = 0; mult < channelMultiplier; ++mult)
874  {
875  for (uint32_t step = 0; step < stepNum; ++step)
876  {
877  scale = (channelMultiplier * step + mult) % scaleSize;
878  for (uint32_t i = 0; i < stepSize; ++i)
879  {
880  unsigned int index = mult * stepSize * channelMultiplier +
881  step * stepSize + i;
882  this->operator[](index);
883  decodedTensor.emplace_back(armnn::Dequantize(*m_Iterator, m_Scales[scale], 0));
884  }
885  }
886  }
887  return decodedTensor;
888  }
PerAxisIterator & operator[](const unsigned int index) override

◆ Get()

float Get ( ) const
inlineoverridevirtual

◆ GetScale()

float GetScale ( ) const
inline

Definition at line 849 of file BaseIterator.hpp.

850  {
851  return m_Scales[m_AxisIndex];
852  }

The documentation for this class was generated from the following file: