15 #include <initializer_list>
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)
45 static float Dequantize(T value,
float scale, int32_t offset)
96 template<
typename ItType>
99 static constexpr
bool value=std::is_floating_point<typename std::iterator_traits<ItType>::value_type>
::value;
102 template <
typename T,
typename FloatIt,
103 typename std::enable_if<IsFloatingPointIterator<FloatIt>::value,
int>::type=0
105 std::vector<T>
QuantizedVector(FloatIt first, FloatIt last,
float qScale, int32_t qOffset)
107 std::vector<T> quantized;
108 quantized.reserve(armnn::numeric_cast<size_t>(std::distance(first, last)));
110 for (
auto it = first; it != last; ++it)
113 T q = SelectiveQuantize<T>(f, qScale, qOffset);
114 quantized.push_back(q);
121 std::vector<T>
QuantizedVector(
const std::vector<float>& array,
float qScale = 1.f, int32_t qOffset = 0)
123 return QuantizedVector<T>(array.begin(), array.end(), qScale, qOffset);
127 std::vector<T>
QuantizedVector(std::initializer_list<float> array,
float qScale = 1.f, int32_t qOffset = 0)
129 return QuantizedVector<T>(array.begin(), array.end(), qScale, qOffset);