ArmNN
 24.02
ScaledInt32PerAxisDecoder Class Reference

#include <BaseIterator.hpp>

Inheritance diagram for ScaledInt32PerAxisDecoder:
[legend]
Collaboration diagram for ScaledInt32PerAxisDecoder:
[legend]

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 ()
 
virtual float Get () const=0
 
- 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 858 of file BaseIterator.hpp.

Constructor & Destructor Documentation

◆ ScaledInt32PerAxisDecoder()

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

Definition at line 861 of file BaseIterator.hpp.

862  : PerAxisIterator(data, tensorInfo.GetShape(), tensorInfo.GetQuantizationDim().value()),
863  m_Scales(tensorInfo.GetQuantizationScales())
864  {}

Member Function Documentation

◆ DecodeTensor()

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

Implements Decoder< float >.

Definition at line 877 of file BaseIterator.hpp.

879  {
880  const uint32_t size = tensorShape.GetNumElements();
881 
882  const uint32_t stepSize = isDepthwise ?
883  tensorShape[2] * tensorShape[3] : tensorShape.GetNumElements() / tensorShape[0];
884 
885  const uint32_t stepNum = size / stepSize;
886 
887  std::vector<float> decodedTensor;
888  decodedTensor.reserve(size);
889 
890  // channelMultiplier is only used in depthwise convolutions and in other cases will have no effect
891  // stepSize is the length of a contiguous area sharing a quantization scale within a tensor
892  // stepNum is the number of those steps/blocks in the tensor
893  for (uint32_t step = 0; step < stepNum; ++step)
894  {
895  //scale = (channelMultiplier * step + mult) % scaleSize;
896  for (uint32_t i = 0; i < stepSize; ++i)
897  {
898  unsigned int index = step * stepSize + i;
899  this->operator[](index);
900  decodedTensor.emplace_back(armnn::Dequantize(*m_Iterator, m_Scales[step], 0));
901  }
902  }
903  return decodedTensor;
904  }

References armnn::Dequantize(), TensorShape::GetNumElements(), PerAxisIterator< const int32_t, Decoder< float > >::m_Iterator, and PerAxisIterator< const int32_t, Decoder< float > >::operator[]().

◆ Get()

float Get ( ) const
inlineoverride

◆ GetScale()

float GetScale ( ) const
inline

Definition at line 872 of file BaseIterator.hpp.

873  {
874  return m_Scales[m_AxisIndex];
875  }

References PerAxisIterator< const int32_t, Decoder< float > >::m_AxisIndex.


The documentation for this class was generated from the following file:
armnn::TensorInfo::GetQuantizationScales
std::vector< float > GetQuantizationScales() const
Definition: Tensor.cpp:451
armnn::PerAxisIterator< const int32_t, Decoder< float > >::m_AxisIndex
unsigned int m_AxisIndex
Definition: BaseIterator.hpp:789
armnn::TensorInfo::GetQuantizationDim
Optional< unsigned int > GetQuantizationDim() const
Definition: Tensor.cpp:494
armnn::Dequantize
float Dequantize(QuantizedType value, float scale, int32_t offset)
Dequantize an 8-bit data type into a floating point data type.
Definition: TypesUtils.cpp:52
armnn::PerAxisIterator< const int32_t, Decoder< float > >::m_Iterator
const int32_t * m_Iterator
Definition: BaseIterator.hpp:787
armnn::TensorInfo::GetShape
const TensorShape & GetShape() const
Definition: Tensor.hpp:193
armnn::PerAxisIterator< const int32_t, Decoder< float > >::operator[]
PerAxisIterator & operator[](const unsigned int index) override
Definition: BaseIterator.hpp:780
armnn::PerAxisIterator< const int32_t, Decoder< float > >::PerAxisIterator
PerAxisIterator(const int32_t *data=nullptr, unsigned int axisFactor=0, unsigned int axisDimensionality=0)
Definition: BaseIterator.hpp:711
armnn::OptionalReferenceSwitch::value
const T & value() const
Definition: Optional.hpp:146