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.cpp | |
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.cpp')
-rw-r--r-- | src/armnn/StaticRangeVisitor.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/armnn/StaticRangeVisitor.cpp b/src/armnn/StaticRangeVisitor.cpp index 1986e427f2..258d499279 100644 --- a/src/armnn/StaticRangeVisitor.cpp +++ b/src/armnn/StaticRangeVisitor.cpp @@ -12,6 +12,20 @@ namespace armnn { +StaticRangeVisitor::StaticRangeVisitor(std::unordered_map<LayerGuid, MinMaxRanges>& guidToRangesMap) + : m_GuidToRangesMap(guidToRangesMap) +{} + +StaticRangeVisitor::MinMaxRange StaticRangeVisitor::GetRange(LayerGuid guid, unsigned int idx) const +{ + auto search = m_GuidToRangesMap.find(guid); + if (search == m_GuidToRangesMap.end()) + { + return DefaultRange(); + } + return search->second.at(idx); +} + void StaticRangeVisitor::SetRange(const IConnectableLayer* layer, unsigned int outputIdx, float min, float max) { auto& ranges = m_GuidToRangesMap[layer->GetGuid()]; @@ -23,20 +37,10 @@ void StaticRangeVisitor::SetRange(const IConnectableLayer* layer, unsigned int o ranges[outputIdx] = std::make_pair(min, max); } -StaticRangeVisitor::MinMaxRange StaticRangeVisitor::GetRange(LayerGuid guid, unsigned int idx) const -{ - auto found = m_GuidToRangesMap.find(guid); - if (found != m_GuidToRangesMap.end()) - { - return found->second.at(idx); - } - return DefaultRange(); -} - -void StaticRangeVisitor::VisitAdditionLayer(const IConnectableLayer *layer, const char *name) +void StaticRangeVisitor::VisitAdditionLayer(const IConnectableLayer* layer, const char* name) { SetRange(layer, 0, -20.f, 20.f); -}; +} void StaticRangeVisitor::VisitBatchNormalizationLayer(const IConnectableLayer* layer, const BatchNormalizationDescriptor& desc, @@ -55,9 +59,9 @@ void StaticRangeVisitor::VisitBatchNormalizationLayer(const IConnectableLayer* l SetRange(layer, 0, -15.0f, 15.0f); } -void StaticRangeVisitor::VisitActivationLayer(const IConnectableLayer *layer, +void StaticRangeVisitor::VisitActivationLayer(const IConnectableLayer* layer, const ActivationDescriptor& activationDescriptor, - const char *name) + const char* name) { switch (activationDescriptor.m_Function) { @@ -83,4 +87,4 @@ void StaticRangeVisitor::VisitActivationLayer(const IConnectableLayer *layer, } } -} //namespace armnn
\ No newline at end of file +} //namespace armnn |