ArmNN
 20.02
GraphTests.cpp File Reference
#include "GraphUtils.hpp"
#include <Graph.hpp>
#include <Layer.hpp>
#include <armnn/TypesUtils.hpp>
#include <armnn/Exceptions.hpp>
#include <armnn/backends/IBackendInternal.hpp>
#include <backendsCommon/CpuTensorHandle.hpp>
#include <backendsCommon/TensorHandleFactoryRegistry.hpp>
#include <boost/cast.hpp>
#include <boost/test/unit_test.hpp>

Go to the source code of this file.

Functions

bool CheckOrder (const armnn::Graph &graph, const armnn::Layer *first, const armnn::Layer *second)
 Checks that first comes before second in the order. More...
 
 BOOST_AUTO_TEST_CASE (ClassGraph)
 
 BOOST_AUTO_TEST_CASE (TopologicalSort)
 
 BOOST_AUTO_TEST_CASE (InsertNewLayerBefore)
 
 BOOST_AUTO_TEST_CASE (InsertNewLayerAfter)
 
 BOOST_FIXTURE_TEST_CASE (AddCopyLayers, CopyLayersFixture)
 
 BOOST_FIXTURE_TEST_CASE (AddCopyLayersSeveralTimes, CopyLayersFixture)
 
 BOOST_FIXTURE_TEST_CASE (CopyLayersAddedBetweenSameLayersHaveDifferentNames, CopyLayersFixture)
 
 BOOST_AUTO_TEST_CASE (DuplicateLayerNames)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/5]

BOOST_AUTO_TEST_CASE ( ClassGraph  )

Definition at line 36 of file GraphTests.cpp.

References Graph::AddLayer(), and GraphHasNamedLayer().

37 {
38  armnn::Graph graph;
39  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::InputLayer>(0, "layerA"));
40  BOOST_TEST(GraphHasNamedLayer(graph, "layerA"));
41 }
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:397
bool GraphHasNamedLayer(const armnn::Graph &graph, const std::string &name)
Definition: GraphUtils.cpp:8
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: InputLayer.hpp:13

◆ BOOST_AUTO_TEST_CASE() [2/5]

BOOST_AUTO_TEST_CASE ( TopologicalSort  )

Definition at line 43 of file GraphTests.cpp.

References Graph::AddLayer(), CheckOrder(), OutputSlot::Connect(), GetFirstLayerWithName(), Layer::GetInputSlot(), and Layer::GetOutputSlot().

44 {
45  armnn::Graph graph;
46 
47  armnn::ActivationDescriptor activationDefaults;
48 
49  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::InputLayer>(0, "layerA"));
50  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerB"));
51  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::AdditionLayer>("layerC"));
52  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::OutputLayer>(0, "output"));
53  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerD"));
54  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerE"));
55 
56  armnn::Layer* const layerA = GetFirstLayerWithName(graph, "layerA");
57  armnn::Layer* const layerB = GetFirstLayerWithName(graph, "layerB");
58  armnn::Layer* const layerC = GetFirstLayerWithName(graph, "layerC");
59  armnn::Layer* const layerO = GetFirstLayerWithName(graph, "output");
60  armnn::Layer* const layerE = GetFirstLayerWithName(graph, "layerE");
61  armnn::Layer* const layerD = GetFirstLayerWithName(graph, "layerD");
62 
63  // Simple graph which branches and rejoins.
64  // A
65  // / \'
66  // D E
67  // \ |
68  // \ B
69  // \|
70  // C
71  layerA->GetOutputSlot(0).Connect(layerD->GetInputSlot(0));
72  layerA->GetOutputSlot(0).Connect(layerE->GetInputSlot(0));
73  layerE->GetOutputSlot(0).Connect(layerB->GetInputSlot(0));
74  layerD->GetOutputSlot(0).Connect(layerC->GetInputSlot(0));
75  layerB->GetOutputSlot(0).Connect(layerC->GetInputSlot(1));
76  layerC->GetOutputSlot(0).Connect(layerO->GetInputSlot(0));
77 
78  // check order is valid
79  BOOST_TEST(CheckOrder(graph, layerA, layerD));
80  BOOST_TEST(CheckOrder(graph, layerA, layerE));
81  BOOST_TEST(CheckOrder(graph, layerD, layerC));
82  BOOST_TEST(CheckOrder(graph, layerE, layerB));
83  BOOST_TEST(CheckOrder(graph, layerB, layerC));
84 }
armnn::Layer * GetFirstLayerWithName(armnn::Graph &graph, const std::string &name)
Definition: GraphUtils.cpp:20
bool CheckOrder(const armnn::Graph &graph, const armnn::Layer *first, const armnn::Layer *second)
Checks that first comes before second in the order.
Definition: GraphTests.cpp:22
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:397
int Connect(InputSlot &destination)
Definition: Layer.cpp:79
This layer represents an activation operation with the specified activation function.
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:310
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: OutputLayer.hpp:13
An ActivationDescriptor for the ActivationLayer.
Definition: Descriptors.hpp:20
This layer represents an addition operation.
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: InputLayer.hpp:13
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:312

◆ BOOST_AUTO_TEST_CASE() [3/5]

BOOST_AUTO_TEST_CASE ( InsertNewLayerBefore  )

Definition at line 86 of file GraphTests.cpp.

References Graph::AddLayer(), CheckOrder(), OutputSlot::Connect(), armnn::Float32, GetFirstLayerWithName(), Layer::GetInputSlot(), Layer::GetOutputSlot(), Graph::InsertNewLayer(), and OutputSlot::SetTensorInfo().

87 {
88  armnn::Graph graph;
89  armnn::TensorInfo tensorInfo({ 1, 1, 1, 1 }, armnn::DataType::Float32);
90 
91  std::vector<armnn::Layer*> order;
92 
93  armnn::ActivationDescriptor activationDefaults;
94  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::InputLayer>(0, "layerA"));
95  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerB"));
96  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerC"));
97  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::AdditionLayer>("layerD"));
98  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::OutputLayer>(0, "output"));
99 
100  armnn::Layer* const layerA = GetFirstLayerWithName(graph, "layerA");
101  armnn::Layer* const layerB = GetFirstLayerWithName(graph, "layerB");
102  armnn::Layer* const layerC = GetFirstLayerWithName(graph, "layerC");
103  armnn::Layer* const layerD = GetFirstLayerWithName(graph, "layerD");
104  armnn::Layer* const layerO = GetFirstLayerWithName(graph, "output");
105 
106  // A
107  // / \'
108  // B C
109  // \ /
110  // D
111  layerA->GetOutputSlot(0).SetTensorInfo(tensorInfo);
112  layerB->GetOutputSlot(0).SetTensorInfo(tensorInfo);
113  layerC->GetOutputSlot(0).SetTensorInfo(tensorInfo);
114  layerD->GetOutputSlot(0).SetTensorInfo(tensorInfo);
115 
116  layerA->GetOutputSlot(0).Connect(layerB->GetInputSlot(0));
117  layerA->GetOutputSlot(0).Connect(layerC->GetInputSlot(0));
118  layerB->GetOutputSlot(0).Connect(layerD->GetInputSlot(0));
119  layerC->GetOutputSlot(0).Connect(layerD->GetInputSlot(1));
120  layerD->GetOutputSlot(0).Connect(layerO->GetInputSlot(0));
121 
122  // Checks order is valid.
123  BOOST_TEST(CheckOrder(graph, layerA, layerB));
124  BOOST_TEST(CheckOrder(graph, layerA, layerC));
125  BOOST_TEST(CheckOrder(graph, layerB, layerD));
126  BOOST_TEST(CheckOrder(graph, layerC, layerD));
127 
128  // A
129  // / \'
130  // B C
131  // \ |
132  // \ E
133  // \|
134  // D
135  BOOST_CHECK_NO_THROW(graph.InsertNewLayer<armnn::ActivationLayer>(layerD->GetInputSlot(1),
136  activationDefaults,
137  "layerE"));
138 
139  armnn::Layer* const layerE = GetFirstLayerWithName(graph, "layerE");
140 
141  // Checks order is valid.
142  BOOST_TEST(CheckOrder(graph, layerA, layerB));
143  BOOST_TEST(CheckOrder(graph, layerA, layerC));
144  BOOST_TEST(CheckOrder(graph, layerB, layerD));
145  BOOST_TEST(CheckOrder(graph, layerC, layerE));
146  BOOST_TEST(CheckOrder(graph, layerE, layerD));
147 
148  // A
149  // /|
150  // / F
151  // / |
152  // B C
153  // \ |
154  // \ E
155  // \|
156  // D
157  BOOST_CHECK_NO_THROW(graph.InsertNewLayer<armnn::ActivationLayer>(layerC->GetInputSlot(0),
158  activationDefaults,
159  "layerF"));
160 
161  armnn::Layer* const layerF = GetFirstLayerWithName(graph, "layerF");
162 
163  // Checks order is valid.
164  BOOST_TEST(CheckOrder(graph, layerA, layerB));
165  BOOST_TEST(CheckOrder(graph, layerA, layerF));
166  BOOST_TEST(CheckOrder(graph, layerF, layerC));
167  BOOST_TEST(CheckOrder(graph, layerB, layerD));
168  BOOST_TEST(CheckOrder(graph, layerC, layerE));
169  BOOST_TEST(CheckOrder(graph, layerE, layerD));
170 }
armnn::Layer * GetFirstLayerWithName(armnn::Graph &graph, const std::string &name)
Definition: GraphUtils.cpp:20
bool CheckOrder(const armnn::Graph &graph, const armnn::Layer *first, const armnn::Layer *second)
Checks that first comes before second in the order.
Definition: GraphTests.cpp:22
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:397
int Connect(InputSlot &destination)
Definition: Layer.cpp:79
This layer represents an activation operation with the specified activation function.
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:310
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: OutputLayer.hpp:13
An ActivationDescriptor for the ActivationLayer.
Definition: Descriptors.hpp:20
This layer represents an addition operation.
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: InputLayer.hpp:13
void SetTensorInfo(const TensorInfo &tensorInfo) override
Definition: Layer.cpp:58
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:312
LayerT * InsertNewLayer(InputSlot &insertBefore, Args &&... args)
Inserts a new layer between the output slot currently connected to insertBefore and insertBefore itse...
Definition: Graph.hpp:409

◆ BOOST_AUTO_TEST_CASE() [4/5]

BOOST_AUTO_TEST_CASE ( InsertNewLayerAfter  )

Definition at line 172 of file GraphTests.cpp.

References Graph::AddLayer(), CheckOrder(), OutputSlot::Connect(), armnn::Float32, GetFirstLayerWithName(), Layer::GetInputSlot(), Layer::GetOutputSlot(), Graph::InsertNewLayer(), and OutputSlot::SetTensorInfo().

173 {
174  armnn::Graph graph;
175  armnn::TensorInfo tensorInfo({ 1, 1, 1, 1 }, armnn::DataType::Float32);
176 
177  std::vector<armnn::Layer*> order;
178 
179  armnn::ActivationDescriptor activationDefaults;
180  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::InputLayer>(0, "layerA"));
181  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerB"));
182  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerC"));
183  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::AdditionLayer>("layerD"));
184  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::OutputLayer>(0, "output"));
185 
186  armnn::Layer* const layerA = GetFirstLayerWithName(graph, "layerA");
187  armnn::Layer* const layerB = GetFirstLayerWithName(graph, "layerB");
188  armnn::Layer* const layerC = GetFirstLayerWithName(graph, "layerC");
189  armnn::Layer* const layerD = GetFirstLayerWithName(graph, "layerD");
190  armnn::Layer* const layerO = GetFirstLayerWithName(graph, "output");
191 
192  // A
193  // / \'
194  // B C
195  // \ /
196  // D
197  layerA->GetOutputSlot(0).SetTensorInfo(tensorInfo);
198  layerB->GetOutputSlot(0).SetTensorInfo(tensorInfo);
199  layerC->GetOutputSlot(0).SetTensorInfo(tensorInfo);
200  layerD->GetOutputSlot(0).SetTensorInfo(tensorInfo);
201 
202  layerA->GetOutputSlot(0).Connect(layerB->GetInputSlot(0));
203  layerA->GetOutputSlot(0).Connect(layerC->GetInputSlot(0));
204  layerB->GetOutputSlot(0).Connect(layerD->GetInputSlot(0));
205  layerC->GetOutputSlot(0).Connect(layerD->GetInputSlot(1));
206  layerD->GetOutputSlot(0).Connect(layerO->GetInputSlot(0));
207 
208  // Checks order is valid.
209  BOOST_TEST(CheckOrder(graph, layerA, layerB));
210  BOOST_TEST(CheckOrder(graph, layerA, layerC));
211  BOOST_TEST(CheckOrder(graph, layerB, layerD));
212  BOOST_TEST(CheckOrder(graph, layerC, layerD));
213 
214  // A
215  // / \'
216  // B C
217  // \ |
218  // \ E
219  // \|
220  // D
221  BOOST_CHECK_NO_THROW(graph.InsertNewLayer<armnn::ActivationLayer>(layerC->GetOutputSlot(),
222  activationDefaults,
223  "layerE"));
224 
225  armnn::Layer* const layerE = GetFirstLayerWithName(graph, "layerE");
226 
227  // Checks order is valid.
228  BOOST_TEST(CheckOrder(graph, layerA, layerB));
229  BOOST_TEST(CheckOrder(graph, layerA, layerC));
230  BOOST_TEST(CheckOrder(graph, layerB, layerD));
231  BOOST_TEST(CheckOrder(graph, layerC, layerE));
232  BOOST_TEST(CheckOrder(graph, layerE, layerD));
233 
234 
235  // A
236  // |
237  // F
238  // / \'
239  // B C
240  // \ |
241  // \ E
242  // \ /
243  // D
244  BOOST_CHECK_NO_THROW(graph.InsertNewLayer<armnn::ActivationLayer>(layerA->GetOutputSlot(),
245  activationDefaults,
246  "layerF"));
247 
248  armnn::Layer* const layerF = GetFirstLayerWithName(graph, "layerF");
249 
250  // Checks order is valid.
251  BOOST_TEST(CheckOrder(graph, layerA, layerF));
252  BOOST_TEST(CheckOrder(graph, layerF, layerB));
253  BOOST_TEST(CheckOrder(graph, layerF, layerC));
254  BOOST_TEST(CheckOrder(graph, layerB, layerD));
255  BOOST_TEST(CheckOrder(graph, layerC, layerE));
256  BOOST_TEST(CheckOrder(graph, layerE, layerD));
257 }
armnn::Layer * GetFirstLayerWithName(armnn::Graph &graph, const std::string &name)
Definition: GraphUtils.cpp:20
bool CheckOrder(const armnn::Graph &graph, const armnn::Layer *first, const armnn::Layer *second)
Checks that first comes before second in the order.
Definition: GraphTests.cpp:22
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:397
int Connect(InputSlot &destination)
Definition: Layer.cpp:79
This layer represents an activation operation with the specified activation function.
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:310
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: OutputLayer.hpp:13
An ActivationDescriptor for the ActivationLayer.
Definition: Descriptors.hpp:20
This layer represents an addition operation.
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: InputLayer.hpp:13
void SetTensorInfo(const TensorInfo &tensorInfo) override
Definition: Layer.cpp:58
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:312
LayerT * InsertNewLayer(InputSlot &insertBefore, Args &&... args)
Inserts a new layer between the output slot currently connected to insertBefore and insertBefore itse...
Definition: Graph.hpp:409

◆ BOOST_AUTO_TEST_CASE() [5/5]

BOOST_AUTO_TEST_CASE ( DuplicateLayerNames  )

Definition at line 588 of file GraphTests.cpp.

References Graph::AddLayer(), Graph::begin(), BOOST_AUTO_TEST_SUITE_END(), OutputSlot::Connect(), armnn::CpuRef, Layer::GetInputSlot(), Layer::GetOutputSlot(), armnn::Input, armnn::Output, Layer::SetBackendId(), and Graph::TopologicalSort().

589 {
590  armnn::Graph graph;
591 
592  armnn::InputLayer* const inputLayer = graph.AddLayer<armnn::InputLayer>(0, "layer");
594 
595  armnn::OutputLayer* const outputLayer = graph.AddLayer<armnn::OutputLayer>(0, "layer");
596  outputLayer->SetBackendId(armnn::Compute::CpuRef);
597 
598  inputLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
599 
600  auto it = graph.TopologicalSort().begin();
601  BOOST_TEST(((*it)->GetType() == armnn::LayerType::Input));
602  BOOST_TEST(((*std::next(it))->GetType() == armnn::LayerType::Output));
603 }
Iterator begin()
Returns iterator pointing to the beginning of the list. Lowercase for range-based for loops...
Definition: Graph.hpp:158
CPU Execution: Reference C++ kernels.
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:397
int Connect(InputSlot &destination)
Definition: Layer.cpp:79
void SetBackendId(const BackendId &id)
Definition: Layer.hpp:264
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:310
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: OutputLayer.hpp:13
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: InputLayer.hpp:13
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:312
Graph & TopologicalSort()
Sorts layers in topological order and return this.
Definition: Graph.hpp:173

◆ BOOST_FIXTURE_TEST_CASE() [1/3]

BOOST_FIXTURE_TEST_CASE ( AddCopyLayers  ,
CopyLayersFixture   
)

Definition at line 528 of file GraphTests.cpp.

529 {
530  InitialiseTestGraph();
531  const armnn::Graph origGraph(m_Graph);
532  m_Graph.AddCompatibilityLayers(m_Backends, m_FactoryRegistry);
533 
534  TestGraphAfterAddingCopyLayers(m_Graph, origGraph);
535 }

◆ BOOST_FIXTURE_TEST_CASE() [2/3]

BOOST_FIXTURE_TEST_CASE ( AddCopyLayersSeveralTimes  ,
CopyLayersFixture   
)

Definition at line 537 of file GraphTests.cpp.

538 {
539  InitialiseTestGraph();
540  m_Graph.AddCompatibilityLayers(m_Backends, m_FactoryRegistry);
541 
542  // Calling AddCompatibilityLayers() several times should not change the connections.
543  const std::vector<Edge> edges = GetEdgeList(m_Graph);
544  for (int i = 0; i < 4; ++i)
545  {
546  m_Graph.AddCompatibilityLayers(m_Backends, m_FactoryRegistry);
547  const std::vector<Edge> otherEdges = GetEdgeList(m_Graph);
548  BOOST_TEST((edges == otherEdges));
549  }
550 }

◆ BOOST_FIXTURE_TEST_CASE() [3/3]

BOOST_FIXTURE_TEST_CASE ( CopyLayersAddedBetweenSameLayersHaveDifferentNames  ,
CopyLayersFixture   
)

Definition at line 552 of file GraphTests.cpp.

References Graph::AddCompatibilityLayers(), Graph::AddLayer(), OutputSlot::Connect(), armnn::CopyToTarget, armnn::CpuRef, armnn::DirectCompatibility, Layer::GetInputSlot(), Layer::GetOutputSlot(), armnn::GpuAcc, Layer::SetBackendId(), and OutputSlot::SetEdgeStrategy().

553 {
554  armnn::Graph graph;
555 
556  armnn::InputLayer* const inputLayer = graph.AddLayer<armnn::InputLayer>(0, "input");
558 
559  armnn::ViewsDescriptor splitterDesc(2);
560  armnn::SplitterLayer* const splitterLayer = graph.AddLayer<armnn::SplitterLayer>(splitterDesc, "splitter");
561  splitterLayer->SetBackendId(armnn::Compute::GpuAcc);
562 
563  armnn::AdditionLayer* const additionLayer = graph.AddLayer<armnn::AdditionLayer>("addition");
564  additionLayer->SetBackendId(armnn::Compute::CpuRef);
565 
566  armnn::OutputLayer* const outputLayer = graph.AddLayer<armnn::OutputLayer>(0, "output");
567  outputLayer->SetBackendId(armnn::Compute::CpuRef);
568 
569  inputLayer->GetOutputSlot(0).Connect(splitterLayer->GetInputSlot(0));
570  splitterLayer->GetOutputSlot(0).Connect(additionLayer->GetInputSlot(0));
571  splitterLayer->GetOutputSlot(1).Connect(additionLayer->GetInputSlot(1));
572  additionLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
573 
578 
579  graph.AddCompatibilityLayers(m_Backends, m_FactoryRegistry);
580 
581  std::vector<Edge> edges = GetEdgeList(graph);
582  BOOST_CHECK(edges.size() == 6u);
583  std::sort(edges.begin(), edges.end());
584  auto last = std::unique(edges.begin(), edges.end());
585  BOOST_CHECK_MESSAGE(last == edges.end(), "Found duplicated edges after AddCompatibilityLayers()");
586 }
This layer represents a split operation.
A ViewsDescriptor for the SplitterLayer.
void SetEdgeStrategy(unsigned int connectionIndex, EdgeStrategy strategy)
Definition: Layer.cpp:177
No strategy has been defined. Used internally to verify integrity of optimizations.
CPU Execution: Reference C++ kernels.
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:397
Source backends tensor data can be exported to destination backend tensor without copy...
int Connect(InputSlot &destination)
Definition: Layer.cpp:79
void SetBackendId(const BackendId &id)
Definition: Layer.hpp:264
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:310
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: OutputLayer.hpp:13
GPU Execution: OpenCL: ArmCompute.
This layer represents an addition operation.
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: InputLayer.hpp:13
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:312
void AddCompatibilityLayers(std::map< BackendId, std::unique_ptr< class IBackendInternal >> &backends, TensorHandleFactoryRegistry &registry)
Modifies the graph in-place, removing edges connecting layers using different compute devices...
Definition: Graph.cpp:263

◆ CheckOrder()

bool CheckOrder ( const armnn::Graph graph,
const armnn::Layer first,
const armnn::Layer second 
)

Checks that first comes before second in the order.

Definition at line 22 of file GraphTests.cpp.

References BOOST_AUTO_TEST_SUITE(), Graph::Print(), and Graph::TopologicalSort().

Referenced by BOOST_AUTO_TEST_CASE().

23 {
24  graph.Print();
25 
26  const auto& order = graph.TopologicalSort();
27 
28  auto firstPos = std::find(order.begin(), order.end(), first);
29  auto secondPos = std::find(firstPos, order.end(), second);
30 
31  return (secondPos != order.end());
32 }
Graph & TopologicalSort()
Sorts layers in topological order and return this.
Definition: Graph.hpp:173
Status Print() const
Definition: Graph.cpp:61