ArmNN
 20.05
GraphTests.cpp File Reference
#include "GraphUtils.hpp"
#include <Graph.hpp>
#include <Layer.hpp>
#include <armnn/TypesUtils.hpp>
#include <armnn/Exceptions.hpp>
#include <armnn/utility/PolymorphicDowncast.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 37 of file GraphTests.cpp.

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

38 {
39  armnn::Graph graph;
40  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::InputLayer>(0, "layerA"));
41  BOOST_TEST(GraphHasNamedLayer(graph, "layerA"));
42 }
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:398
bool GraphHasNamedLayer(const armnn::Graph &graph, const std::string &name)
Definition: GraphUtils.cpp:10
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 44 of file GraphTests.cpp.

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

45 {
46  armnn::Graph graph;
47 
48  armnn::ActivationDescriptor activationDefaults;
49 
50  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::InputLayer>(0, "layerA"));
51  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerB"));
52  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::AdditionLayer>("layerC"));
53  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::OutputLayer>(0, "output"));
54  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerD"));
55  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerE"));
56 
57  armnn::Layer* const layerA = GetFirstLayerWithName(graph, "layerA");
58  armnn::Layer* const layerB = GetFirstLayerWithName(graph, "layerB");
59  armnn::Layer* const layerC = GetFirstLayerWithName(graph, "layerC");
60  armnn::Layer* const layerO = GetFirstLayerWithName(graph, "output");
61  armnn::Layer* const layerE = GetFirstLayerWithName(graph, "layerE");
62  armnn::Layer* const layerD = GetFirstLayerWithName(graph, "layerD");
63 
64  // Simple graph which branches and rejoins.
65  // A
66  // / \'
67  // D E
68  // \ |
69  // \ B
70  // \|
71  // C
72  layerA->GetOutputSlot(0).Connect(layerD->GetInputSlot(0));
73  layerA->GetOutputSlot(0).Connect(layerE->GetInputSlot(0));
74  layerE->GetOutputSlot(0).Connect(layerB->GetInputSlot(0));
75  layerD->GetOutputSlot(0).Connect(layerC->GetInputSlot(0));
76  layerB->GetOutputSlot(0).Connect(layerC->GetInputSlot(1));
77  layerC->GetOutputSlot(0).Connect(layerO->GetInputSlot(0));
78 
79  // check order is valid
80  BOOST_TEST(CheckOrder(graph, layerA, layerD));
81  BOOST_TEST(CheckOrder(graph, layerA, layerE));
82  BOOST_TEST(CheckOrder(graph, layerD, layerC));
83  BOOST_TEST(CheckOrder(graph, layerE, layerB));
84  BOOST_TEST(CheckOrder(graph, layerB, layerC));
85 }
armnn::Layer * GetFirstLayerWithName(armnn::Graph &graph, const std::string &name)
Definition: GraphUtils.cpp:22
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:23
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:398
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 87 of file GraphTests.cpp.

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

88 {
89  armnn::Graph graph;
90  armnn::TensorInfo tensorInfo({ 1, 1, 1, 1 }, armnn::DataType::Float32);
91 
92  std::vector<armnn::Layer*> order;
93 
94  armnn::ActivationDescriptor activationDefaults;
95  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::InputLayer>(0, "layerA"));
96  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerB"));
97  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerC"));
98  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::AdditionLayer>("layerD"));
99  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::OutputLayer>(0, "output"));
100 
101  armnn::Layer* const layerA = GetFirstLayerWithName(graph, "layerA");
102  armnn::Layer* const layerB = GetFirstLayerWithName(graph, "layerB");
103  armnn::Layer* const layerC = GetFirstLayerWithName(graph, "layerC");
104  armnn::Layer* const layerD = GetFirstLayerWithName(graph, "layerD");
105  armnn::Layer* const layerO = GetFirstLayerWithName(graph, "output");
106 
107  // A
108  // / \'
109  // B C
110  // \ /
111  // D
112  layerA->GetOutputSlot(0).SetTensorInfo(tensorInfo);
113  layerB->GetOutputSlot(0).SetTensorInfo(tensorInfo);
114  layerC->GetOutputSlot(0).SetTensorInfo(tensorInfo);
115  layerD->GetOutputSlot(0).SetTensorInfo(tensorInfo);
116 
117  layerA->GetOutputSlot(0).Connect(layerB->GetInputSlot(0));
118  layerA->GetOutputSlot(0).Connect(layerC->GetInputSlot(0));
119  layerB->GetOutputSlot(0).Connect(layerD->GetInputSlot(0));
120  layerC->GetOutputSlot(0).Connect(layerD->GetInputSlot(1));
121  layerD->GetOutputSlot(0).Connect(layerO->GetInputSlot(0));
122 
123  // Checks order is valid.
124  BOOST_TEST(CheckOrder(graph, layerA, layerB));
125  BOOST_TEST(CheckOrder(graph, layerA, layerC));
126  BOOST_TEST(CheckOrder(graph, layerB, layerD));
127  BOOST_TEST(CheckOrder(graph, layerC, layerD));
128 
129  // A
130  // / \'
131  // B C
132  // \ |
133  // \ E
134  // \|
135  // D
136  BOOST_CHECK_NO_THROW(graph.InsertNewLayer<armnn::ActivationLayer>(layerD->GetInputSlot(1),
137  activationDefaults,
138  "layerE"));
139 
140  armnn::Layer* const layerE = GetFirstLayerWithName(graph, "layerE");
141 
142  // Checks order is valid.
143  BOOST_TEST(CheckOrder(graph, layerA, layerB));
144  BOOST_TEST(CheckOrder(graph, layerA, layerC));
145  BOOST_TEST(CheckOrder(graph, layerB, layerD));
146  BOOST_TEST(CheckOrder(graph, layerC, layerE));
147  BOOST_TEST(CheckOrder(graph, layerE, layerD));
148 
149  // A
150  // /|
151  // / F
152  // / |
153  // B C
154  // \ |
155  // \ E
156  // \|
157  // D
158  BOOST_CHECK_NO_THROW(graph.InsertNewLayer<armnn::ActivationLayer>(layerC->GetInputSlot(0),
159  activationDefaults,
160  "layerF"));
161 
162  armnn::Layer* const layerF = GetFirstLayerWithName(graph, "layerF");
163 
164  // Checks order is valid.
165  BOOST_TEST(CheckOrder(graph, layerA, layerB));
166  BOOST_TEST(CheckOrder(graph, layerA, layerF));
167  BOOST_TEST(CheckOrder(graph, layerF, layerC));
168  BOOST_TEST(CheckOrder(graph, layerB, layerD));
169  BOOST_TEST(CheckOrder(graph, layerC, layerE));
170  BOOST_TEST(CheckOrder(graph, layerE, layerD));
171 }
armnn::Layer * GetFirstLayerWithName(armnn::Graph &graph, const std::string &name)
Definition: GraphUtils.cpp:22
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:23
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:398
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:410

◆ BOOST_AUTO_TEST_CASE() [4/5]

BOOST_AUTO_TEST_CASE ( InsertNewLayerAfter  )

Definition at line 173 of file GraphTests.cpp.

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

174 {
175  armnn::Graph graph;
176  armnn::TensorInfo tensorInfo({ 1, 1, 1, 1 }, armnn::DataType::Float32);
177 
178  std::vector<armnn::Layer*> order;
179 
180  armnn::ActivationDescriptor activationDefaults;
181  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::InputLayer>(0, "layerA"));
182  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerB"));
183  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerC"));
184  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::AdditionLayer>("layerD"));
185  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::OutputLayer>(0, "output"));
186 
187  armnn::Layer* const layerA = GetFirstLayerWithName(graph, "layerA");
188  armnn::Layer* const layerB = GetFirstLayerWithName(graph, "layerB");
189  armnn::Layer* const layerC = GetFirstLayerWithName(graph, "layerC");
190  armnn::Layer* const layerD = GetFirstLayerWithName(graph, "layerD");
191  armnn::Layer* const layerO = GetFirstLayerWithName(graph, "output");
192 
193  // A
194  // / \'
195  // B C
196  // \ /
197  // D
198  layerA->GetOutputSlot(0).SetTensorInfo(tensorInfo);
199  layerB->GetOutputSlot(0).SetTensorInfo(tensorInfo);
200  layerC->GetOutputSlot(0).SetTensorInfo(tensorInfo);
201  layerD->GetOutputSlot(0).SetTensorInfo(tensorInfo);
202 
203  layerA->GetOutputSlot(0).Connect(layerB->GetInputSlot(0));
204  layerA->GetOutputSlot(0).Connect(layerC->GetInputSlot(0));
205  layerB->GetOutputSlot(0).Connect(layerD->GetInputSlot(0));
206  layerC->GetOutputSlot(0).Connect(layerD->GetInputSlot(1));
207  layerD->GetOutputSlot(0).Connect(layerO->GetInputSlot(0));
208 
209  // Checks order is valid.
210  BOOST_TEST(CheckOrder(graph, layerA, layerB));
211  BOOST_TEST(CheckOrder(graph, layerA, layerC));
212  BOOST_TEST(CheckOrder(graph, layerB, layerD));
213  BOOST_TEST(CheckOrder(graph, layerC, layerD));
214 
215  // A
216  // / \'
217  // B C
218  // \ |
219  // \ E
220  // \|
221  // D
222  BOOST_CHECK_NO_THROW(graph.InsertNewLayer<armnn::ActivationLayer>(layerC->GetOutputSlot(),
223  activationDefaults,
224  "layerE"));
225 
226  armnn::Layer* const layerE = GetFirstLayerWithName(graph, "layerE");
227 
228  // Checks order is valid.
229  BOOST_TEST(CheckOrder(graph, layerA, layerB));
230  BOOST_TEST(CheckOrder(graph, layerA, layerC));
231  BOOST_TEST(CheckOrder(graph, layerB, layerD));
232  BOOST_TEST(CheckOrder(graph, layerC, layerE));
233  BOOST_TEST(CheckOrder(graph, layerE, layerD));
234 
235 
236  // A
237  // |
238  // F
239  // / \'
240  // B C
241  // \ |
242  // \ E
243  // \ /
244  // D
245  BOOST_CHECK_NO_THROW(graph.InsertNewLayer<armnn::ActivationLayer>(layerA->GetOutputSlot(),
246  activationDefaults,
247  "layerF"));
248 
249  armnn::Layer* const layerF = GetFirstLayerWithName(graph, "layerF");
250 
251  // Checks order is valid.
252  BOOST_TEST(CheckOrder(graph, layerA, layerF));
253  BOOST_TEST(CheckOrder(graph, layerF, layerB));
254  BOOST_TEST(CheckOrder(graph, layerF, layerC));
255  BOOST_TEST(CheckOrder(graph, layerB, layerD));
256  BOOST_TEST(CheckOrder(graph, layerC, layerE));
257  BOOST_TEST(CheckOrder(graph, layerE, layerD));
258 }
armnn::Layer * GetFirstLayerWithName(armnn::Graph &graph, const std::string &name)
Definition: GraphUtils.cpp:22
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:23
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:398
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:410

◆ BOOST_AUTO_TEST_CASE() [5/5]

BOOST_AUTO_TEST_CASE ( DuplicateLayerNames  )

Definition at line 589 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().

590 {
591  armnn::Graph graph;
592 
593  armnn::InputLayer* const inputLayer = graph.AddLayer<armnn::InputLayer>(0, "layer");
595 
596  armnn::OutputLayer* const outputLayer = graph.AddLayer<armnn::OutputLayer>(0, "layer");
597  outputLayer->SetBackendId(armnn::Compute::CpuRef);
598 
599  inputLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
600 
601  auto it = graph.TopologicalSort().begin();
602  BOOST_TEST(((*it)->GetType() == armnn::LayerType::Input));
603  BOOST_TEST(((*std::next(it))->GetType() == armnn::LayerType::Output));
604 }
Iterator begin()
Returns iterator pointing to the beginning of the list. Lowercase for range-based for loops...
Definition: Graph.hpp:159
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:398
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:174

◆ BOOST_FIXTURE_TEST_CASE() [1/3]

BOOST_FIXTURE_TEST_CASE ( AddCopyLayers  ,
CopyLayersFixture   
)

Definition at line 529 of file GraphTests.cpp.

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

◆ BOOST_FIXTURE_TEST_CASE() [2/3]

BOOST_FIXTURE_TEST_CASE ( AddCopyLayersSeveralTimes  ,
CopyLayersFixture   
)

Definition at line 538 of file GraphTests.cpp.

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

◆ BOOST_FIXTURE_TEST_CASE() [3/3]

BOOST_FIXTURE_TEST_CASE ( CopyLayersAddedBetweenSameLayersHaveDifferentNames  ,
CopyLayersFixture   
)

Definition at line 553 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().

554 {
555  armnn::Graph graph;
556 
557  armnn::InputLayer* const inputLayer = graph.AddLayer<armnn::InputLayer>(0, "input");
559 
560  armnn::ViewsDescriptor splitterDesc(2);
561  armnn::SplitterLayer* const splitterLayer = graph.AddLayer<armnn::SplitterLayer>(splitterDesc, "splitter");
562  splitterLayer->SetBackendId(armnn::Compute::GpuAcc);
563 
564  armnn::AdditionLayer* const additionLayer = graph.AddLayer<armnn::AdditionLayer>("addition");
565  additionLayer->SetBackendId(armnn::Compute::CpuRef);
566 
567  armnn::OutputLayer* const outputLayer = graph.AddLayer<armnn::OutputLayer>(0, "output");
568  outputLayer->SetBackendId(armnn::Compute::CpuRef);
569 
570  inputLayer->GetOutputSlot(0).Connect(splitterLayer->GetInputSlot(0));
571  splitterLayer->GetOutputSlot(0).Connect(additionLayer->GetInputSlot(0));
572  splitterLayer->GetOutputSlot(1).Connect(additionLayer->GetInputSlot(1));
573  additionLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
574 
579 
580  graph.AddCompatibilityLayers(m_Backends, m_FactoryRegistry);
581 
582  std::vector<Edge> edges = GetEdgeList(graph);
583  BOOST_CHECK(edges.size() == 6u);
584  std::sort(edges.begin(), edges.end());
585  auto last = std::unique(edges.begin(), edges.end());
586  BOOST_CHECK_MESSAGE(last == edges.end(), "Found duplicated edges after AddCompatibilityLayers()");
587 }
This layer represents a split operation.
A ViewsDescriptor for the SplitterLayer.
void SetEdgeStrategy(unsigned int connectionIndex, EdgeStrategy strategy)
Definition: Layer.cpp:178
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:398
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:262

◆ 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 23 of file GraphTests.cpp.

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

Referenced by BOOST_AUTO_TEST_CASE().

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