ArmNN
 24.02
RangeTracker Class Reference

#include <RangeTracker.hpp>

Public Types

using MinMaxRange = std::pair< float, float >
 

Public Member Functions

MinMaxRange GetRange (LayerGuid guid, unsigned int idx) const
 Retrieve the Range for a particular output slot on a particular layer. More...
 
void SetRange (const IConnectableLayer *layer, unsigned int outputIdx, float min, float max)
 Set the range for an output slot on a layer. More...
 
bool IsEmpty () const
 Query function to check that the RangeTracker is empty. More...
 
bool HasRanges (LayerGuid guid) const
 Query that there is an entry for a layer. More...
 
void RefineMin (LayerGuid guid, unsigned int slotIndex, float newMin)
 Update min in RangeTracker with new_min if it is lower than current value. More...
 
void RefineMax (LayerGuid guid, unsigned int slotIndex, float newMax)
 Update max in RangeTracker with new_max if it is greater than current value. More...
 
void ResetMinMax (LayerGuid guid, unsigned int idx, float newMin, float newMax)
 Overwrite min and max in RangeTracker with newMin and newMax. More...
 
void Reset ()
 
void SetDynamicMode (bool flag)
 
bool IsInDynamicMode () const
 

Detailed Description

Definition at line 19 of file RangeTracker.hpp.

Member Typedef Documentation

◆ MinMaxRange

using MinMaxRange = std::pair<float, float>

Definition at line 22 of file RangeTracker.hpp.

Member Function Documentation

◆ GetRange()

RangeTracker::MinMaxRange GetRange ( LayerGuid  guid,
unsigned int  idx 
) const

Retrieve the Range for a particular output slot on a particular layer.

Definition at line 29 of file RangeTracker.cpp.

30 {
31  auto search = m_GuidToRangesMap.find(guid);
32  if (search == m_GuidToRangesMap.end())
33  {
34  if (IsInDynamicMode())
35  {
36  throw armnn::Exception("Have no entry for layer GUID [" + std::to_string(guid) + "]");
37  }
38  else
39  {
40  return DefaultRange();
41  }
42  }
43  return search->second.at(idx);
44 }

References RangeTracker::IsInDynamicMode().

◆ HasRanges()

bool HasRanges ( LayerGuid  guid) const
inline

Query that there is an entry for a layer.

Definition at line 34 of file RangeTracker.hpp.

34 { return m_GuidToRangesMap.find(guid) != m_GuidToRangesMap.end(); }

◆ IsEmpty()

bool IsEmpty ( ) const
inline

Query function to check that the RangeTracker is empty.

Definition at line 31 of file RangeTracker.hpp.

31 { return m_GuidToRangesMap.empty(); }

◆ IsInDynamicMode()

bool IsInDynamicMode ( ) const
inline

Definition at line 49 of file RangeTracker.hpp.

49 { return m_DynamicMode; }

Referenced by RangeTracker::GetRange().

◆ RefineMax()

void RefineMax ( LayerGuid  guid,
unsigned int  slotIndex,
float  newMax 
)

Update max in RangeTracker with new_max if it is greater than current value.

Definition at line 55 of file RangeTracker.cpp.

56 {
57  auto& currentMax = m_GuidToRangesMap.find(guid)->second.at(idx).second;
58  if (newMax > currentMax)
59  {
60  currentMax = newMax;
61  }
62 }

◆ RefineMin()

void RefineMin ( LayerGuid  guid,
unsigned int  slotIndex,
float  newMin 
)

Update min in RangeTracker with new_min if it is lower than current value.

Definition at line 46 of file RangeTracker.cpp.

47 {
48  auto& currentMin = m_GuidToRangesMap.find(guid)->second.at(idx).first;
49  if (newMin < currentMin)
50  {
51  currentMin = newMin;
52  }
53 }

◆ Reset()

void Reset ( )

Definition at line 74 of file RangeTracker.cpp.

75 {
76  m_GuidToRangesMap.clear();
77 }

◆ ResetMinMax()

void ResetMinMax ( LayerGuid  guid,
unsigned int  idx,
float  newMin,
float  newMax 
)

Overwrite min and max in RangeTracker with newMin and newMax.

Definition at line 64 of file RangeTracker.cpp.

65 {
66  auto minMaxPair = m_GuidToRangesMap.find(guid);
67  auto& currentMin = minMaxPair->second.at(idx).first;
68  auto& currentMax = minMaxPair->second.at(idx).second;
69 
70  currentMin = newMin;
71  currentMax = newMax;
72 }

◆ SetDynamicMode()

void SetDynamicMode ( bool  flag)
inline

Definition at line 47 of file RangeTracker.hpp.

47 { m_DynamicMode = flag; }

◆ SetRange()

void SetRange ( const IConnectableLayer layer,
unsigned int  outputIdx,
float  min,
float  max 
)

Set the range for an output slot on a layer.

Definition at line 12 of file RangeTracker.cpp.

13 {
14  auto& ranges = m_GuidToRangesMap[layer->GetGuid()];
15 
16  unsigned int numOfOutputSlots = layer->GetNumOutputSlots();
17  // output layers are a special case
18  if (numOfOutputSlots == 0)
19  {
20  ++numOfOutputSlots;
21  }
22  if (ranges.size() < numOfOutputSlots)
23  {
24  ranges.resize(numOfOutputSlots);
25  }
26  ranges[outputIdx] = std::make_pair(min, max);
27 }

References IConnectableLayer::GetGuid(), and IConnectableLayer::GetNumOutputSlots().


The documentation for this class was generated from the following files:
armnn::Exception
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46
armnn::RangeTracker::IsInDynamicMode
bool IsInDynamicMode() const
Definition: RangeTracker.hpp:49