ArmNN
 21.02
ScaledInt32PerAxisDecoder Class Reference

#include <BaseIterator.hpp>

Inheritance diagram for ScaledInt32PerAxisDecoder:
PerAxisIterator< const int32_t, Decoder< float > > Decoder< float > BaseIterator

Public Member Functions

 ScaledInt32PerAxisDecoder (const int32_t *data, const std::vector< float > &scales, 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 int32_t, Decoder< float > >
 PerAxisIterator (const int32_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 int32_t, Decoder< float > >
const int32_t * m_Iterator
 
const int32_t * m_Start
 
unsigned int m_AxisIndex
 
unsigned int m_AxisFactor
 

Detailed Description

Definition at line 920 of file BaseIterator.hpp.

Constructor & Destructor Documentation

◆ ScaledInt32PerAxisDecoder()

ScaledInt32PerAxisDecoder ( const int32_t *  data,
const std::vector< float > &  scales,
unsigned int  axisFactor 
)
inline

Definition at line 923 of file BaseIterator.hpp.

924  : PerAxisIterator(data, axisFactor), m_Scales(scales) {}
PerAxisIterator(const int32_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 937 of file BaseIterator.hpp.

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

940  {
941  const uint32_t size = tensorShape.GetNumElements();
942  const uint32_t scaleSize = static_cast<uint32_t>(m_Scales.size());
943 
944  const uint32_t stepSize = isDepthwise ?
945  tensorShape[2] * tensorShape[3] : tensorShape.GetNumElements() / tensorShape[0];
946 
947  const uint32_t stepNum = size / (stepSize * channelMultiplier);
948  uint32_t scale;
949 
950  std::vector<float> decodedTensor;
951  decodedTensor.reserve(size);
952 
953  // channelMultiplier is only used in depthwise convolutions and in other cases will have no effect
954  // stepSize is the length of a contiguous area sharing a quantization scale within a tensor
955  // stepNum is the number of those steps/blocks in the tensor
956  for (uint32_t mult = 0; mult < channelMultiplier; ++mult)
957  {
958  for (uint32_t step = 0; step < stepNum; ++step)
959  {
960  scale = (channelMultiplier * step + mult) % scaleSize;
961  for (uint32_t i = 0; i < stepSize; ++i)
962  {
963  unsigned int index = mult * stepSize * channelMultiplier +
964  step * stepSize + i;
965  this->operator[](index);
966  decodedTensor.emplace_back(armnn::Dequantize(*m_Iterator, m_Scales[scale], 0));
967  }
968  }
969  }
970  return decodedTensor;
971  }
PerAxisIterator & operator[](const unsigned int index) override

◆ Get()

float Get ( ) const
inlineoverridevirtual

◆ GetScale()

float GetScale ( ) const
inline

Definition at line 932 of file BaseIterator.hpp.

933  {
934  return m_Scales[m_AxisIndex];
935  }

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