12 #include <initializer_list> 16 #include <boost/core/ignore_unused.hpp> 17 #include <boost/numeric/conversion/cast.hpp> 22 template<
typename T,
bool DoQuantize=true>
25 static T
Quantize(
float value,
float scale, int32_t offset)
27 return armnn::Quantize<T>(value, scale, offset);
30 static float Dequantize(T value,
float scale, int32_t offset)
39 static T
Quantize(
float value,
float scale, int32_t offset)
41 boost::ignore_unused(scale, offset);
45 static float Dequantize(T value,
float scale, int32_t offset)
47 boost::ignore_unused(scale, offset);
57 boost::ignore_unused(scale, offset);
63 boost::ignore_unused(scale, offset);
80 template<
typename ItType>
83 static constexpr
bool value=std::is_floating_point<typename std::iterator_traits<ItType>::value_type>::value;
86 template <
typename T,
typename FloatIt,
87 typename std::enable_if<IsFloatingPointIterator<FloatIt>::value,
int>::type=0
89 std::vector<T>
QuantizedVector(FloatIt first, FloatIt last,
float qScale, int32_t qOffset)
91 std::vector<T> quantized;
92 quantized.reserve(boost::numeric_cast<size_t>(std::distance(first, last)));
94 for (
auto it = first; it != last; ++it)
97 T q = SelectiveQuantize<T>(f, qScale, qOffset);
98 quantized.push_back(q);
105 std::vector<T>
QuantizedVector(
const std::vector<float>& array,
float qScale = 1.f, int32_t qOffset = 0)
107 return QuantizedVector<T>(array.begin(), array.end(), qScale, qOffset);
111 std::vector<T>
QuantizedVector(std::initializer_list<float> array,
float qScale = 1.f, int32_t qOffset = 0)
113 return QuantizedVector<T>(array.begin(), array.end(), qScale, qOffset);
static armnn::Half Quantize(float value, float scale, int32_t offset)
float Dequantize(QuantizedType value, float scale, int32_t offset)
std::vector< T > QuantizedVector(FloatIt first, FloatIt last, float qScale, int32_t qOffset)
static float Dequantize(T value, float scale, int32_t offset)
static T Quantize(float value, float scale, int32_t offset)
static T Quantize(float value, float scale, int32_t offset)
static float Dequantize(T value, float scale, int32_t offset)
static float Dequantize(armnn::Half value, float scale, int32_t offset)
float SelectiveDequantize(T value, float scale, int32_t offset)
T SelectiveQuantize(float value, float scale, int32_t offset)