ArmNN
 24.08
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 861 of file BaseIterator.hpp.

Constructor & Destructor Documentation

◆ ScaledInt32PerAxisDecoder()

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

Definition at line 864 of file BaseIterator.hpp.

865  : PerAxisIterator(data, tensorInfo.GetShape(), tensorInfo.GetQuantizationDim().value()),
866  m_Scales(tensorInfo.GetQuantizationScales())
867  {}

Member Function Documentation

◆ DecodeTensor()

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

Implements Decoder< float >.

Definition at line 880 of file BaseIterator.hpp.

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

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 875 of file BaseIterator.hpp.

876  {
877  return m_Scales[m_AxisIndex];
878  }

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:788
armnn::TensorInfo::GetQuantizationDim
Optional< unsigned int > GetQuantizationDim() const
Definition: Tensor.cpp:498
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:48
armnn::PerAxisIterator< const int32_t, Decoder< float > >::m_Iterator
const int32_t * m_Iterator
Definition: BaseIterator.hpp:786
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:779
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:710
armnn::OptionalReferenceSwitch::value
const T & value() const
Definition: Optional.hpp:146