From a8d572dc48f47e66cd7abd6ad9b2d3a0f40ea94b Mon Sep 17 00:00:00 2001 From: Matteo Martincigh Date: Thu, 7 Feb 2019 17:51:09 +0000 Subject: IVGCVSW-2607 Implement Input range override mechanism * Added the OverrideInputRange method to the Quantizer API * Created OverrideInputRangeVisitor to implement the override mechanism * Moved the quantizer utility functions to the new NetworkQuantizerUtils files * Moved the map of quantization ranges out of the StaticRangeVisitor and into the NetworkQuantizer * Added unit tests * Code refactoring and cleanup Change-Id: I9c1d006c1b6a35fbc04584a832fbe489f8f9276d Signed-off-by: Matteo Martincigh --- src/armnn/StaticRangeVisitor.hpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/armnn/StaticRangeVisitor.hpp') diff --git a/src/armnn/StaticRangeVisitor.hpp b/src/armnn/StaticRangeVisitor.hpp index ed02fb57dd..ea27947e7a 100644 --- a/src/armnn/StaticRangeVisitor.hpp +++ b/src/armnn/StaticRangeVisitor.hpp @@ -8,9 +8,9 @@ #include "LayerVisitorBase.hpp" #include +#include -#include -#include +#include namespace armnn { @@ -18,15 +18,16 @@ namespace armnn /// Visitor class to establish min/max ranges based on the type of the layer class StaticRangeVisitor : public LayerVisitorBase { +private: + using MinMaxRange = std::pair; + using MinMaxRanges = std::vector; + public: - StaticRangeVisitor() = default; + StaticRangeVisitor(std::unordered_map& guidToRangesMap); ~StaticRangeVisitor() = default; - using MinMaxRange = std::pair; - using MinMaxRanges = std::vector; - /// Functions to set the Range on a per-layer-type basis - void VisitAdditionLayer(const IConnectableLayer *layer, const char *name = nullptr) override; + void VisitAdditionLayer(const IConnectableLayer* layer, const char* name = nullptr) override; void VisitBatchNormalizationLayer(const IConnectableLayer* layer, const BatchNormalizationDescriptor& desc, const ConstTensor& mean, @@ -34,22 +35,22 @@ public: const ConstTensor& beta, const ConstTensor& gamma, const char* name = nullptr) override; - void VisitActivationLayer(const IConnectableLayer *layer, + void VisitActivationLayer(const IConnectableLayer* layer, const ActivationDescriptor& activationDescriptor, - const char *name = nullptr) override; + const char* name = nullptr) override; - /// Retreive the default range + /// Retrieve the default range MinMaxRange DefaultRange() const { return std::make_pair(-15.0f, 15.0f); } - /// Retreive the Range for a particular output slot on a particular layer + /// Retrieve the Range for a particular output slot on a particular layer MinMaxRange GetRange(LayerGuid guid, unsigned int idx) const; private: /// Set the range for an output slot on a layer void SetRange(const IConnectableLayer* layer, unsigned int outputIdx, float min, float max); - /// Mapping from Guid to an array of ranges for outputs - std::map m_GuidToRangesMap; + /// Mapping from a layer Guid to an array of ranges for outputs + std::unordered_map& m_GuidToRangesMap; }; -} //namespace armnn \ No newline at end of file +} //namespace armnn -- cgit v1.2.1