From 6940dd720ebb6b3d1df8ca203ab696daefe58189 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Fri, 20 Mar 2020 12:25:56 +0000 Subject: renamed Documentation folder 20.02 and added .nojekyll file Signed-off-by: Jim Flynn --- 20.02/_network_quantizer_utils_8hpp_source.xhtml | 128 +++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 20.02/_network_quantizer_utils_8hpp_source.xhtml (limited to '20.02/_network_quantizer_utils_8hpp_source.xhtml') diff --git a/20.02/_network_quantizer_utils_8hpp_source.xhtml b/20.02/_network_quantizer_utils_8hpp_source.xhtml new file mode 100644 index 0000000000..f309f75d6d --- /dev/null +++ b/20.02/_network_quantizer_utils_8hpp_source.xhtml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + +ArmNN: src/armnn/NetworkQuantizerUtils.hpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  20.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
NetworkQuantizerUtils.hpp
+
+
+Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
9 
10 #include <armnn/Tensor.hpp>
11 #include <armnn/TypesUtils.hpp>
12 #include <armnn/ILayerVisitor.hpp>
13 
14 #include <utility>
15 #include <limits>
16 
17 #include <boost/assert.hpp>
18 
19 namespace armnn
20 {
21 
22 template<typename srcType>
23 void QuantizeConstant(const srcType* src, uint8_t* dst, size_t numElements, float& scale, int& offset)
24 {
25  BOOST_ASSERT(src);
26  BOOST_ASSERT(dst);
27 
28  float min = std::numeric_limits<srcType>::max();
29  float max = std::numeric_limits<srcType>::lowest();
30  for (size_t i = 0; i < numElements; ++i)
31  {
32  min = std::min(min, src[i]);
33  max = std::max(max, src[i]);
34  }
35 
36  QAsymmU8QuantizationScheme quantizationScheme;
37  OffsetScalePair qParams = quantizationScheme.ComputeScheme(min, max);
38  scale = qParams.first;
39  offset = qParams.second;
40 
41  for (size_t i = 0; i < numElements; ++i)
42  {
43  dst[i] = armnn::Quantize<uint8_t>(src[i], scale, offset);
44  }
45 }
46 
47 ConstTensor CreateQuantizedConst(const ConstTensor& tensor, std::vector<uint8_t>& backing);
48 
49 template <typename LayerContainer>
50 void VisitLayers(const LayerContainer& layerContainer, ILayerVisitor& visitor)
51 {
52  visitor.StartVisit();
53  for (auto layer : layerContainer)
54  {
55  layer->Accept(visitor);
56  }
57  visitor.FinishVisit();
58 }
59 
60 } // namespace armnn
std::pair< float, int > OffsetScalePair
+ +
Copyright (c) 2020 ARM Limited.
+
void VisitLayers(const LayerContainer &layerContainer, ILayerVisitor &visitor)
+ + + +
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:199
+
void QuantizeConstant(const srcType *src, uint8_t *dst, size_t numElements, float &scale, int &offset)
+
virtual void StartVisit()
+ + +
OffsetScalePair ComputeScheme(double min, double max) const override
+
ConstTensor CreateQuantizedConst(const ConstTensor &tensor, std::vector< uint8_t > &backing)
+
virtual void FinishVisit()
+
+
+ + + + -- cgit v1.2.1