ArmNN
 20.05
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 43 of file SubgraphView.cpp.

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

◆ SubgraphView() [2/5]

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

Constructs a sub-graph with the given arguments.

Definition at line 51 of file SubgraphView.cpp.

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

◆ SubgraphView() [3/5]

SubgraphView ( const SubgraphView subgraph)

Copy-constructor.

Definition at line 59 of file SubgraphView.cpp.

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

◆ SubgraphView() [4/5]

SubgraphView ( SubgraphView &&  subgraph)

Move-constructor.

Definition at line 67 of file SubgraphView.cpp.

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

◆ SubgraphView() [5/5]

Constructs a sub-graph with only the given layer.

Definition at line 75 of file SubgraphView.cpp.

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

Member Function Documentation

◆ begin() [1/2]

Definition at line 165 of file SubgraphView.cpp.

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

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

◆ begin() [2/2]

SubgraphView::ConstIterator begin ( ) const

Definition at line 175 of file SubgraphView.cpp.

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

◆ cbegin()

SubgraphView::ConstIterator cbegin ( ) const

Definition at line 185 of file SubgraphView.cpp.

References SubgraphView::begin().

186 {
187  return begin();
188 }

◆ cend()

Definition at line 190 of file SubgraphView.cpp.

References SubgraphView::end().

191 {
192  return end();
193 }

◆ Clear()

void Clear ( )

Definition at line 195 of file SubgraphView.cpp.

Referenced by Graph::SubstituteSubgraph().

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

◆ end() [1/2]

Definition at line 170 of file SubgraphView.cpp.

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

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

◆ end() [2/2]

Definition at line 180 of file SubgraphView.cpp.

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

◆ 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 130 of file SubgraphView.cpp.

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

◆ GetInputSlot() [2/2]

InputSlot * GetInputSlot ( unsigned int  index)

Definition at line 135 of file SubgraphView.cpp.

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

◆ GetInputSlots()

const SubgraphView::InputSlots & GetInputSlots ( ) const

Definition at line 120 of file SubgraphView.cpp.

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

121 {
122  return m_InputSlots;
123 }

◆ GetLayers()

const SubgraphView::Layers & GetLayers ( ) const

Definition at line 160 of file SubgraphView.cpp.

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

161 {
162  return m_Layers;
163 }

◆ GetNumInputSlots()

unsigned int GetNumInputSlots ( ) const

Definition at line 150 of file SubgraphView.cpp.

References armnn::numeric_cast().

151 {
152  return boost::numeric_cast<unsigned int>(m_InputSlots.size());
153 }
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 155 of file SubgraphView.cpp.

References armnn::numeric_cast().

156 {
157  return boost::numeric_cast<unsigned int>(m_OutputSlots.size());
158 }
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 140 of file SubgraphView.cpp.

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

◆ GetOutputSlot() [2/2]

OutputSlot * GetOutputSlot ( unsigned int  index)

Definition at line 145 of file SubgraphView.cpp.

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

◆ GetOutputSlots()

const SubgraphView::OutputSlots & GetOutputSlots ( ) const

Definition at line 125 of file SubgraphView.cpp.

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

126 {
127  return m_OutputSlots;
128 }

◆ operator=()

SubgraphView & operator= ( SubgraphView &&  other)

Move-assignment operator.

Definition at line 97 of file SubgraphView.cpp.

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

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