aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/OverrideInputRangeVisitor.hpp
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-02-07 17:51:09 +0000
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-02-08 12:23:05 +0000
commita8d572dc48f47e66cd7abd6ad9b2d3a0f40ea94b (patch)
tree5de7809a8fbc19d6d2a940a51a982bd633156945 /src/armnn/OverrideInputRangeVisitor.hpp
parente0a4ad8a8e6ef271883e8029985eeab16d838972 (diff)
downloadarmnn-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/OverrideInputRangeVisitor.hpp')
-rw-r--r--src/armnn/OverrideInputRangeVisitor.hpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/armnn/OverrideInputRangeVisitor.hpp b/src/armnn/OverrideInputRangeVisitor.hpp
new file mode 100644
index 0000000000..a2da6c702e
--- /dev/null
+++ b/src/armnn/OverrideInputRangeVisitor.hpp
@@ -0,0 +1,45 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "NetworkQuantizer.hpp"
+#include "LayerVisitorBase.hpp"
+
+#include <unordered_map>
+
+namespace armnn
+{
+
+/// Visitor object for overriding the input range of the quantized input layers in a network
+class OverrideInputRangeVisitor : public LayerVisitorBase<VisitorNoThrowPolicy>
+{
+private:
+ using MinMaxRange = std::pair<float, float>;
+ using MinMaxRanges = std::vector<MinMaxRange>;
+
+public:
+ OverrideInputRangeVisitor(std::unordered_map<LayerGuid, MinMaxRanges>& guidToRangesMap,
+ LayerBindingId layerId,
+ const MinMaxRange& minMaxRange);
+ ~OverrideInputRangeVisitor() = default;
+
+ void VisitInputLayer(const IConnectableLayer *layer, LayerBindingId id, const char *name = nullptr) override;
+
+private:
+ /// Sets the range for the given input layer
+ void SetRange(const IConnectableLayer* layer);
+
+ /// Mapping from a layer Guid to an array of ranges for outputs
+ std::unordered_map<LayerGuid, MinMaxRanges>& m_GuidToRangesMap;
+
+ /// The id of the input layer of which to override the input range
+ LayerBindingId m_LayerId;
+
+ /// The new input range to be applied to the input layer
+ MinMaxRange m_MinMaxRange;
+};
+
+} // namespace armnn