ArmNN
 22.05.01
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 armnn::TensorInfo tensorInfo)
 
float Get () const override
 
float GetScale () const
 
std::vector< float > DecodeTensor (const TensorShape &tensorShape, bool isDepthwise) override
 
- Public Member Functions inherited from PerAxisIterator< const int32_t, Decoder< float > >
 PerAxisIterator (const int32_t *data=nullptr, unsigned int axisFactor=0, unsigned int axisDimensionality=0)
 
 PerAxisIterator (const int32_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
 
- 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_AxisDimensionality
 
unsigned int m_AxisFactor
 
unsigned int m_Index
 

Detailed Description

Definition at line 907 of file BaseIterator.hpp.

Constructor & Destructor Documentation

◆ ScaledInt32PerAxisDecoder()

ScaledInt32PerAxisDecoder ( const int32_t *  data,
const armnn::TensorInfo  tensorInfo 
)
inline

Definition at line 910 of file BaseIterator.hpp.

911  : PerAxisIterator(data, tensorInfo.GetShape(), tensorInfo.GetQuantizationDim().value()),
912  m_Scales(tensorInfo.GetQuantizationScales())
913  {}
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
Optional< unsigned int > GetQuantizationDim() const
Definition: Tensor.cpp:494
std::vector< float > GetQuantizationScales() const
Definition: Tensor.cpp:451
PerAxisIterator(const int32_t *data=nullptr, unsigned int axisFactor=0, unsigned int axisDimensionality=0)

Member Function Documentation

◆ DecodeTensor()

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

Implements Decoder< float >.

Definition at line 926 of file BaseIterator.hpp.

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

928  {
929  const uint32_t size = tensorShape.GetNumElements();
930 
931  const uint32_t stepSize = isDepthwise ?
932  tensorShape[2] * tensorShape[3] : tensorShape.GetNumElements() / tensorShape[0];
933 
934  const uint32_t stepNum = size / stepSize;
935 
936  std::vector<float> decodedTensor;
937  decodedTensor.reserve(size);
938 
939  // channelMultiplier is only used in depthwise convolutions and in other cases will have no effect
940  // stepSize is the length of a contiguous area sharing a quantization scale within a tensor
941  // stepNum is the number of those steps/blocks in the tensor
942  for (uint32_t step = 0; step < stepNum; ++step)
943  {
944  //scale = (channelMultiplier * step + mult) % scaleSize;
945  for (uint32_t i = 0; i < stepSize; ++i)
946  {
947  unsigned int index = step * stepSize + i;
948  this->operator[](index);
949  decodedTensor.emplace_back(armnn::Dequantize(*m_Iterator, m_Scales[step], 0));
950  }
951  }
952  return decodedTensor;
953  }
PerAxisIterator & operator[](const unsigned int index) override

◆ Get()

float Get ( ) const
inlineoverridevirtual

◆ GetScale()

float GetScale ( ) const
inline

Definition at line 921 of file BaseIterator.hpp.

922  {
923  return m_Scales[m_AxisIndex];
924  }

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