ArmNN
 20.02
SubgraphView Class Referencefinal

The SubgraphView class represents a subgraph of a Graph. More...

#include <SubgraphView.hpp>

Public Types

using SubgraphViewPtr = std::unique_ptr< SubgraphView >
 
using InputSlots = std::vector< InputSlot * >
 
using OutputSlots = std::vector< OutputSlot * >
 
using Layers = std::list< Layer * >
 
using Iterator = Layers::iterator
 
using ConstIterator = Layers::const_iterator
 

Public Member Functions

template<typename Func >
void ForEachLayer (Func func) const
 
 SubgraphView (Graph &graph)
 Constructs a sub-graph from the entire given graph. More...
 
 SubgraphView (InputSlots &&inputs, OutputSlots &&outputs, Layers &&layers)
 Constructs a sub-graph with the given arguments. More...
 
 SubgraphView (const SubgraphView &subgraph)
 Copy-constructor. More...
 
 SubgraphView (SubgraphView &&subgraph)
 Move-constructor. More...
 
 SubgraphView (IConnectableLayer *layer)
 Constructs a sub-graph with only the given layer. More...
 
SubgraphViewoperator= (SubgraphView &&other)
 Move-assignment operator. More...
 
const InputSlotsGetInputSlots () const
 
const OutputSlotsGetOutputSlots () const
 
const LayersGetLayers () const
 
const InputSlotGetInputSlot (unsigned int index) const
 
InputSlotGetInputSlot (unsigned int index)
 
const OutputSlotGetOutputSlot (unsigned int index) const
 
OutputSlotGetOutputSlot (unsigned int index)
 
unsigned int GetNumInputSlots () const
 
unsigned int GetNumOutputSlots () const
 
Iterator begin ()
 
Iterator end ()
 
ConstIterator begin () const
 
ConstIterator end () const
 
ConstIterator cbegin () const
 
ConstIterator cend () const
 
void Clear ()
 

Detailed Description

The SubgraphView class represents a subgraph of a Graph.

The data it holds, points to data held by layers of the Graph, so the the contents of the SubgraphView become invalid when the Layers are destroyed or changed.

Definition at line 23 of file SubgraphView.hpp.

Member Typedef Documentation

◆ ConstIterator

using ConstIterator = Layers::const_iterator

Definition at line 42 of file SubgraphView.hpp.

◆ InputSlots

using InputSlots = std::vector<InputSlot*>

Definition at line 38 of file SubgraphView.hpp.

◆ Iterator

using Iterator = Layers::iterator

Definition at line 41 of file SubgraphView.hpp.

◆ Layers

using Layers = std::list<Layer*>

Definition at line 40 of file SubgraphView.hpp.

◆ OutputSlots

using OutputSlots = std::vector<OutputSlot*>

Definition at line 39 of file SubgraphView.hpp.

◆ SubgraphViewPtr

using SubgraphViewPtr = std::unique_ptr<SubgraphView>

Definition at line 37 of file SubgraphView.hpp.

Constructor & Destructor Documentation

◆ SubgraphView() [1/5]

SubgraphView ( Graph graph)
explicit

Constructs a sub-graph from the entire given graph.

Definition at line 42 of file SubgraphView.cpp.

43  : m_InputSlots{}
44  , m_OutputSlots{}
45  , m_Layers(graph.begin(), graph.end())
46 {
47  CheckSubgraph();
48 }

◆ SubgraphView() [2/5]

SubgraphView ( InputSlots &&  inputs,
OutputSlots &&  outputs,
Layers &&  layers 
)

Constructs a sub-graph with the given arguments.

Definition at line 50 of file SubgraphView.cpp.

51  : m_InputSlots{inputs}
52  , m_OutputSlots{outputs}
53  , m_Layers{layers}
54 {
55  CheckSubgraph();
56 }

◆ SubgraphView() [3/5]

SubgraphView ( const SubgraphView subgraph)

Copy-constructor.

Definition at line 58 of file SubgraphView.cpp.

59  : m_InputSlots(subgraph.m_InputSlots.begin(), subgraph.m_InputSlots.end())
60  , m_OutputSlots(subgraph.m_OutputSlots.begin(), subgraph.m_OutputSlots.end())
61  , m_Layers(subgraph.m_Layers.begin(), subgraph.m_Layers.end())
62 {
63  CheckSubgraph();
64 }

◆ SubgraphView() [4/5]

SubgraphView ( SubgraphView &&  subgraph)

Move-constructor.

Definition at line 66 of file SubgraphView.cpp.

67  : m_InputSlots(std::move(subgraph.m_InputSlots))
68  , m_OutputSlots(std::move(subgraph.m_OutputSlots))
69  , m_Layers(std::move(subgraph.m_Layers))
70 {
71  CheckSubgraph();
72 }

◆ SubgraphView() [5/5]

Constructs a sub-graph with only the given layer.

Definition at line 74 of file SubgraphView.cpp.

75  : m_InputSlots{}
76  , m_OutputSlots{}
77  , m_Layers{boost::polymorphic_downcast<Layer*>(layer)}
78 {
79  unsigned int numInputSlots = layer->GetNumInputSlots();
80  m_InputSlots.resize(numInputSlots);
81  for (unsigned int i = 0; i < numInputSlots; i++)
82  {
83  m_InputSlots.at(i) = boost::polymorphic_downcast<InputSlot*>(&(layer->GetInputSlot(i)));
84  }
85 
86  unsigned int numOutputSlots = layer->GetNumOutputSlots();
87  m_OutputSlots.resize(numOutputSlots);
88  for (unsigned int i = 0; i < numOutputSlots; i++)
89  {
90  m_OutputSlots.at(i) = boost::polymorphic_downcast<OutputSlot*>(&(layer->GetOutputSlot(i)));
91  }
92 
93  CheckSubgraph();
94 }

Member Function Documentation

◆ begin() [1/2]

Definition at line 164 of file SubgraphView.cpp.

Referenced by armnn::ApplyBackendOptimizations(), armnn::AssignBackends(), and SubgraphView::cbegin().

165 {
166  return m_Layers.begin();
167 }

◆ begin() [2/2]

SubgraphView::ConstIterator begin ( ) const

Definition at line 174 of file SubgraphView.cpp.

175 {
176  return m_Layers.begin();
177 }

◆ cbegin()

SubgraphView::ConstIterator cbegin ( ) const

Definition at line 184 of file SubgraphView.cpp.

References SubgraphView::begin().

185 {
186  return begin();
187 }

◆ cend()

Definition at line 189 of file SubgraphView.cpp.

References SubgraphView::end().

190 {
191  return end();
192 }

◆ Clear()

void Clear ( )

Definition at line 194 of file SubgraphView.cpp.

Referenced by Graph::SubstituteSubgraph().

195 {
196  m_InputSlots.clear();
197  m_OutputSlots.clear();
198  m_Layers.clear();
199 }

◆ end() [1/2]

Definition at line 169 of file SubgraphView.cpp.

Referenced by armnn::ApplyBackendOptimizations(), armnn::AssignBackends(), and SubgraphView::cend().

170 {
171  return m_Layers.end();
172 }

◆ end() [2/2]

Definition at line 179 of file SubgraphView.cpp.

180 {
181  return m_Layers.end();
182 }

◆ ForEachLayer()

void ForEachLayer ( Func  func) const
inline

Definition at line 27 of file SubgraphView.hpp.

Referenced by Graph::SubstituteSubgraph().

28  {
29  for (auto it = m_Layers.begin(); it != m_Layers.end(); )
30  {
31  auto next = std::next(it);
32  func(*it);
33  it = next;
34  }
35  }

◆ GetInputSlot() [1/2]

const InputSlot * GetInputSlot ( unsigned int  index) const

Definition at line 129 of file SubgraphView.cpp.

130 {
131  return m_InputSlots.at(index);
132 }

◆ GetInputSlot() [2/2]

InputSlot * GetInputSlot ( unsigned int  index)

Definition at line 134 of file SubgraphView.cpp.

135 {
136  return m_InputSlots.at(index);
137 }

◆ GetInputSlots()

const SubgraphView::InputSlots & GetInputSlots ( ) const

Definition at line 119 of file SubgraphView.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), Graph::SubstituteSubgraph(), and OptimizationViews::Validate().

120 {
121  return m_InputSlots;
122 }

◆ GetLayers()

const SubgraphView::Layers & GetLayers ( ) const

Definition at line 159 of file SubgraphView.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), MockBackend::OptimizeSubgraphView(), Graph::SubstituteSubgraph(), and OptimizationViews::Validate().

160 {
161  return m_Layers;
162 }

◆ GetNumInputSlots()

unsigned int GetNumInputSlots ( ) const

Definition at line 149 of file SubgraphView.cpp.

References armnn::numeric_cast().

150 {
151  return boost::numeric_cast<unsigned int>(m_InputSlots.size());
152 }
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:33

◆ GetNumOutputSlots()

unsigned int GetNumOutputSlots ( ) const

Definition at line 154 of file SubgraphView.cpp.

References armnn::numeric_cast().

155 {
156  return boost::numeric_cast<unsigned int>(m_OutputSlots.size());
157 }
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:33

◆ GetOutputSlot() [1/2]

const OutputSlot * GetOutputSlot ( unsigned int  index) const

Definition at line 139 of file SubgraphView.cpp.

140 {
141  return m_OutputSlots.at(index);
142 }

◆ GetOutputSlot() [2/2]

OutputSlot * GetOutputSlot ( unsigned int  index)

Definition at line 144 of file SubgraphView.cpp.

145 {
146  return m_OutputSlots.at(index);
147 }

◆ GetOutputSlots()

const SubgraphView::OutputSlots & GetOutputSlots ( ) const

Definition at line 124 of file SubgraphView.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), Graph::SubstituteSubgraph(), and OptimizationViews::Validate().

125 {
126  return m_OutputSlots;
127 }

◆ operator=()

SubgraphView & operator= ( SubgraphView &&  other)

Move-assignment operator.

Definition at line 96 of file SubgraphView.cpp.

97 {
98  m_InputSlots = std::move(other.m_InputSlots);
99  m_OutputSlots = std::move(other.m_OutputSlots);
100  m_Layers = std::move(other.m_Layers);
101 
102  CheckSubgraph();
103 
104  return *this;
105 }

The documentation for this class was generated from the following files: