ArmNN  NotReleased
RangeTracker.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 
8 #include <armnn/INetwork.hpp>
9 #include <armnn/Types.hpp>
10 
11 #include <utility>
12 #include <unordered_map>
13 
14 namespace armnn
15 {
16 
18 {
19 public:
20  using MinMaxRange = std::pair<float, float>;
21 
23  MinMaxRange GetRange(LayerGuid guid, unsigned int idx) const;
24 
26  void SetRange(const IConnectableLayer* layer, unsigned int outputIdx, float min, float max);
27 
29  bool IsEmpty() const { return m_GuidToRangesMap.empty(); }
30 
32  bool HasRanges(LayerGuid guid) const { return m_GuidToRangesMap.find(guid) != m_GuidToRangesMap.end(); }
33 
35  void RefineMin(LayerGuid guid, unsigned int slotIndex, float newMin);
36 
38  void RefineMax(LayerGuid guid, unsigned int slotIndex, float newMax);
39 
41  void ResetMinMax(LayerGuid guid, unsigned int idx, float newMin, float newMax);
42 
43  void Reset();
44 
45  void SetDynamicMode(bool flag) { m_DynamicMode = flag; }
46 
47  bool IsInDynamicMode() const { return m_DynamicMode; }
48 
49 private:
50  using MinMaxRanges = std::vector<MinMaxRange>;
51 
53  MinMaxRange DefaultRange() const { return std::make_pair(-15.0f, 15.0f); }
54 
56  std::unordered_map<LayerGuid, MinMaxRanges> m_GuidToRangesMap;
57 
58  bool m_DynamicMode = false;
59 };
60 
61 } //namespace armnn
std::pair< float, float > MinMaxRange
bool IsEmpty() const
Query function to check that the RangeTracker is empty.
void RefineMax(LayerGuid guid, unsigned int slotIndex, float newMax)
Update max in RangeTracker with new_max if it is greater than current value.
bool HasRanges(LayerGuid guid) const
Query that there is an entry for a layer.
void RefineMin(LayerGuid guid, unsigned int slotIndex, float newMin)
Update min in RangeTracker with new_min if it is lower than current value.
bool IsInDynamicMode() const
void SetRange(const IConnectableLayer *layer, unsigned int outputIdx, float min, float max)
Set the range for an output slot on a layer.
MinMaxRange GetRange(LayerGuid guid, unsigned int idx) const
Retrieve the Range for a particular output slot on a particular layer.
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:61
void ResetMinMax(LayerGuid guid, unsigned int idx, float newMin, float newMax)
Overwrite min and max in RangeTracker with newMin and newMax.
void SetDynamicMode(bool flag)