ArmNN  NotReleased
SubgraphView Class Referencefinal

#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 41 of file SubgraphView.cpp.

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

◆ SubgraphView() [2/5]

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

Constructs a sub-graph with the given arguments.

Definition at line 49 of file SubgraphView.cpp.

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

◆ SubgraphView() [3/5]

SubgraphView ( const SubgraphView subgraph)

Copy-constructor.

Definition at line 57 of file SubgraphView.cpp.

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

◆ SubgraphView() [4/5]

SubgraphView ( SubgraphView &&  subgraph)

Move-constructor.

Definition at line 65 of file SubgraphView.cpp.

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

◆ SubgraphView() [5/5]

Constructs a sub-graph with only the given layer.

Definition at line 73 of file SubgraphView.cpp.

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

Member Function Documentation

◆ begin() [1/2]

Definition at line 163 of file SubgraphView.cpp.

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

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

◆ begin() [2/2]

SubgraphView::ConstIterator begin ( ) const

Definition at line 173 of file SubgraphView.cpp.

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

◆ cbegin()

SubgraphView::ConstIterator cbegin ( ) const

Definition at line 183 of file SubgraphView.cpp.

References SubgraphView::begin().

184 {
185  return begin();
186 }

◆ cend()

Definition at line 188 of file SubgraphView.cpp.

References SubgraphView::end().

189 {
190  return end();
191 }

◆ Clear()

void Clear ( )

Definition at line 193 of file SubgraphView.cpp.

Referenced by Graph::SubstituteSubgraph().

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

◆ end() [1/2]

Definition at line 168 of file SubgraphView.cpp.

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

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

◆ end() [2/2]

Definition at line 178 of file SubgraphView.cpp.

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

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

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

◆ GetInputSlot() [2/2]

InputSlot * GetInputSlot ( unsigned int  index)

Definition at line 133 of file SubgraphView.cpp.

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

◆ GetInputSlots()

const SubgraphView::InputSlots & GetInputSlots ( ) const

Definition at line 118 of file SubgraphView.cpp.

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

119 {
120  return m_InputSlots;
121 }

◆ GetLayers()

const SubgraphView::Layers & GetLayers ( ) const

Definition at line 158 of file SubgraphView.cpp.

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

159 {
160  return m_Layers;
161 }

◆ GetNumInputSlots()

unsigned int GetNumInputSlots ( ) const

Definition at line 148 of file SubgraphView.cpp.

149 {
150  return boost::numeric_cast<unsigned int>(m_InputSlots.size());
151 }

◆ GetNumOutputSlots()

unsigned int GetNumOutputSlots ( ) const

Definition at line 153 of file SubgraphView.cpp.

154 {
155  return boost::numeric_cast<unsigned int>(m_OutputSlots.size());
156 }

◆ GetOutputSlot() [1/2]

const OutputSlot * GetOutputSlot ( unsigned int  index) const

Definition at line 138 of file SubgraphView.cpp.

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

◆ GetOutputSlot() [2/2]

OutputSlot * GetOutputSlot ( unsigned int  index)

Definition at line 143 of file SubgraphView.cpp.

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

◆ GetOutputSlots()

const SubgraphView::OutputSlots & GetOutputSlots ( ) const

Definition at line 123 of file SubgraphView.cpp.

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

124 {
125  return m_OutputSlots;
126 }

◆ operator=()

SubgraphView & operator= ( SubgraphView &&  other)

Move-assignment operator.

Definition at line 95 of file SubgraphView.cpp.

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

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