14 #include <boost/assert.hpp> 37 template<
typename IType>
45 virtual void Reset(
void*) = 0;
47 virtual IType Get()
const = 0;
50 template<
typename IType>
58 virtual void Reset(
void*) = 0;
60 virtual void Set(IType right) = 0;
62 virtual IType Get()
const = 0;
65 template<
typename T,
typename Base>
70 : m_Iterator(data), m_Start(data)
75 m_Iterator =
reinterpret_cast<T*
>(data);
81 BOOST_ASSERT(m_Iterator);
88 BOOST_ASSERT(m_Iterator);
89 m_Iterator += increment;
95 BOOST_ASSERT(m_Iterator);
96 m_Iterator -= increment;
102 BOOST_ASSERT(m_Iterator);
103 m_Iterator = m_Start + index;
110 BOOST_ASSERT(m_Iterator);
111 m_Iterator = m_Start + index;
129 float Get()
const override 136 const int32_t m_Offset;
148 float Get()
const override 155 const int32_t m_Offset;
167 float Get()
const override 174 const int32_t m_Offset;
186 float Get()
const override 193 const int32_t m_Offset;
205 float Get()
const override 222 float Get()
const override 239 float Get()
const override 254 float Get()
const override 256 return static_cast<float>(*m_Iterator) * m_Scale;
272 float Get()
const override 274 return static_cast<float>(*m_Iterator);
287 void Set(
float right)
override 289 *m_Iterator = armnn::Quantize<uint8_t>(right, m_Scale, m_Offset);
292 float Get()
const override 299 const int32_t m_Offset;
311 void Set(
float right)
override 313 *m_Iterator = armnn::Quantize<int8_t>(right, m_Scale, m_Offset);
316 float Get()
const override 323 const int32_t m_Offset;
335 void Set(
float right)
override 337 *m_Iterator = armnn::Quantize<int8_t>(right, m_Scale, m_Offset);
340 float Get()
const override 347 const int32_t m_Offset;
359 void Set(
float right)
override 361 *m_Iterator = armnn::Quantize<int16_t>(right, m_Scale, m_Offset);
364 float Get()
const override 371 const int32_t m_Offset;
383 void Set(
float right)
override 388 float Get()
const override 405 void Set(
float right)
override 410 float Get()
const override 427 void Set(
float right)
override 432 float Get()
const override 447 void Set(
float right)
override 449 *m_Iterator =
static_cast<int32_t
>(right);
452 float Get()
const override 454 return static_cast<float>(*m_Iterator);
467 void Set(
bool right)
override 479 template<
typename T,
typename Base>
485 : m_Iterator(data), m_Start(data), m_AxisIndex(0), m_AxisFactor(axisFactor)
491 BOOST_ASSERT(m_Iterator);
492 m_Iterator = m_Start + index;
493 m_AxisIndex = axisIndex;
499 m_Iterator =
reinterpret_cast<T*
>(data);
500 m_Start = m_Iterator;
506 BOOST_ASSERT(m_Iterator);
508 m_AxisIndex =
static_cast<unsigned int>(*m_Iterator) % m_AxisFactor;
514 BOOST_ASSERT(m_Iterator);
515 m_Iterator += increment;
516 m_AxisIndex =
static_cast<unsigned int>(*m_Iterator) % m_AxisFactor;
522 BOOST_ASSERT(m_Iterator);
523 m_Iterator -= decrement;
524 m_AxisIndex =
static_cast<unsigned int>(*m_Iterator) % m_AxisFactor;
530 BOOST_ASSERT(m_Iterator);
531 m_Iterator = m_Start + index;
532 m_AxisIndex =
static_cast<unsigned int>(*m_Iterator) % m_AxisFactor;
549 float Get()
const override 557 return m_Scale[m_AxisIndex];
561 std::vector<float> m_Scale;
572 *m_Iterator = armnn::Quantize<int8_t>(right, m_Scale[m_AxisIndex], 0);
583 return m_Scale[m_AxisIndex];
587 std::vector<float> m_Scale;
596 float Get()
const override 604 return m_Scales[m_AxisIndex];
608 std::vector<float> m_Scales;
PerAxisIterator & operator++() override
Float32Decoder(const float *data)
QSymm8PerAxisDecoder(const int8_t *data, const std::vector< float > &scale, unsigned int axisFactor)
void Set(float right) override
ScaledInt32Decoder(const float scale)
BFloat16Decoder(const BFloat16 *data)
PerAxisIterator(T *data=nullptr, unsigned int axisFactor=0)
unsigned int m_AxisFactor
virtual BaseIterator & operator-=(const unsigned int increment)=0
float Get() const override
PerAxisIterator & operator[](const unsigned int index) override
QSymmS8Decoder(const float scale, const int32_t offset)
float Get() const override
QSymm16Encoder(const float scale, const int32_t offset)
static void ConvertBFloat16ToFloat32(const void *srcBFloat16Buffer, size_t numElements, float *dstFloat32Buffer)
void Reset(void *data) override
void Set(float right) override
ScaledInt32Decoder(const int32_t *data, const float scale)
QSymm16Decoder(const int16_t *data, const float scale, const int32_t offset)
void Set(bool right) override
float Get() const override
QSymmS8Encoder(int8_t *data, const float scale, const int32_t offset)
ScaledInt32PerAxisDecoder(const int32_t *data, const std::vector< float > &scales, unsigned int axisFactor)
BFloat16Encoder(armnn::BFloat16 *data)
void Set(float right) override
QSymmS8Decoder(const int8_t *data, const float scale, const int32_t offset)
Copyright (c) 2020 ARM Limited.
void IgnoreUnused(Ts &&...)
float Get() const override
void Set(float right) override
float Get() const override
float Get() const override
QASymmS8Decoder(const int8_t *data, const float scale, const int32_t offset)
float Get() const override
Int32Decoder(const int32_t *data)
float Get() const override
virtual BaseIterator & operator[](const unsigned int index)=0
TypedIterator & operator[](const unsigned int index) override
QASymmS8Decoder(const float scale, const int32_t offset)
QASymm8Encoder(const float scale, const int32_t offset)
static void ConvertFloat32To16(const float *srcFloat32Buffer, size_t numElements, void *dstFloat16Buffer)
Converts a buffer of FP32 values to FP16, and stores in the given dstFloat16Buffer.
float Get() const override
QSymmS8Encoder(const float scale, const int32_t offset)
Int32Encoder(int32_t *data)
void Set(float right) override
void Reset(void *data) override
virtual BaseIterator & operator++()=0
float Get() const override
QASymm8Encoder(uint8_t *data, const float scale, const int32_t offset)
float Get() const override
static void ConvertFloat16To32(const void *srcFloat16Buffer, size_t numElements, float *dstFloat32Buffer)
BooleanEncoder(uint8_t *data)
float Get() const override
float Get() const override
float Get() const override
Float16Encoder(Half *data)
QSymm8PerAxisEncoder(int8_t *data, const std::vector< float > &scale, unsigned int axisFactor)
QASymm8Decoder(const float scale, const int32_t offset)
TypedIterator & operator++() override
Float16Decoder(const Half *data)
virtual BaseIterator & SetIndex(unsigned int index, unsigned int axisIndex=0)=0
float Get() const override
float Get() const override
PerAxisIterator & SetIndex(unsigned int index, unsigned int axisIndex) override
QASymmS8Encoder(const float scale, const int32_t offset)
PerAxisIterator & operator-=(const unsigned int decrement) override
virtual BaseIterator & operator+=(const unsigned int increment)=0
static void ConvertFloat32ToBFloat16(const float *srcFloat32Buffer, size_t numElements, void *dstBFloat16Buffer)
void Set(float right) override
QSymm16Decoder(const float scale, const int32_t offset)
Float32Encoder(float *data)
float Get() const override
QASymm8Decoder(const uint8_t *data, const float scale, const int32_t offset)
TypedIterator & operator+=(const unsigned int increment) override
float Get() const override
QSymm16Encoder(int16_t *data, const float scale, const int32_t offset)
PerAxisIterator & operator+=(const unsigned int increment) override
void Set(float right) override
QASymmS8Encoder(int8_t *data, const float scale, const int32_t offset)
TypedIterator & SetIndex(unsigned int index, unsigned int axisIndex=0) override
TypedIterator & operator-=(const unsigned int increment) override
TypedIterator(T *data=nullptr)
void Set(float right) override
bool Get() const override
float Get() const override