diff options
author | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-02-07 17:51:09 +0000 |
---|---|---|
committer | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-02-08 12:23:05 +0000 |
commit | a8d572dc48f47e66cd7abd6ad9b2d3a0f40ea94b (patch) | |
tree | 5de7809a8fbc19d6d2a940a51a982bd633156945 /src/armnn/StaticRangeVisitor.hpp | |
parent | e0a4ad8a8e6ef271883e8029985eeab16d838972 (diff) | |
download | armnn-a8d572dc48f47e66cd7abd6ad9b2d3a0f40ea94b.tar.gz |
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 <matteo.martincigh@arm.com>
Diffstat (limited to 'src/armnn/StaticRangeVisitor.hpp')
-rw-r--r-- | src/armnn/StaticRangeVisitor.hpp | 29 |
1 files changed, 15 insertions, 14 deletions
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 <armnn/INetwork.hpp> +#include <armnn/INetworkQuantizer.hpp> -#include <map> -#include <vector> +#include <unordered_map> 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<VisitorNoThrowPolicy> { +private: + using MinMaxRange = std::pair<float, float>; + using MinMaxRanges = std::vector<MinMaxRange>; + public: - StaticRangeVisitor() = default; + StaticRangeVisitor(std::unordered_map<LayerGuid, MinMaxRanges>& guidToRangesMap); ~StaticRangeVisitor() = default; - using MinMaxRange = std::pair<float, float>; - using MinMaxRanges = std::vector<MinMaxRange>; - /// 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<LayerGuid, MinMaxRanges> m_GuidToRangesMap; + /// Mapping from a layer Guid to an array of ranges for outputs + std::unordered_map<LayerGuid, MinMaxRanges>& m_GuidToRangesMap; }; -} //namespace armnn
\ No newline at end of file +} //namespace armnn |