ArmNN
 24.05
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 857 of file BaseIterator.hpp.

Constructor & Destructor Documentation

◆ ScaledInt32PerAxisDecoder()

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

Definition at line 860 of file BaseIterator.hpp.

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

Member Function Documentation

◆ DecodeTensor()

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

Implements Decoder< float >.

Definition at line 876 of file BaseIterator.hpp.

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

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

872  {
873  return m_Scales[m_AxisIndex];
874  }

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