ArmNN
 21.05
GraphTests.cpp File Reference

Go to the source code of this file.

Functions

 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)
 
 BOOST_AUTO_TEST_CASE (CheckGraphConstTensorSharing)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/6]

BOOST_AUTO_TEST_CASE ( ClassGraph  )

Definition at line 24 of file GraphTests.cpp.

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

25 {
26  armnn::Graph graph;
27  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::InputLayer>(0, "layerA"));
28  BOOST_TEST(GraphHasNamedLayer(graph, "layerA"));
29 }
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:402
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/6]

BOOST_AUTO_TEST_CASE ( TopologicalSort  )

Definition at line 31 of file GraphTests.cpp.

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

32 {
33  armnn::Graph graph;
34 
35  armnn::ActivationDescriptor activationDefaults;
36 
37  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::InputLayer>(0, "layerA"));
38  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerB"));
39  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::AdditionLayer>("layerC"));
40  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::OutputLayer>(0, "output"));
41  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerD"));
42  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerE"));
43 
44  armnn::Layer* const layerA = GetFirstLayerWithName(graph, "layerA");
45  armnn::Layer* const layerB = GetFirstLayerWithName(graph, "layerB");
46  armnn::Layer* const layerC = GetFirstLayerWithName(graph, "layerC");
47  armnn::Layer* const layerO = GetFirstLayerWithName(graph, "output");
48  armnn::Layer* const layerE = GetFirstLayerWithName(graph, "layerE");
49  armnn::Layer* const layerD = GetFirstLayerWithName(graph, "layerD");
50 
51  // Simple graph which branches and rejoins.
52  // A
53  // / \'
54  // D E
55  // \ |
56  // \ B
57  // \|
58  // C
59  layerA->GetOutputSlot(0).Connect(layerD->GetInputSlot(0));
60  layerA->GetOutputSlot(0).Connect(layerE->GetInputSlot(0));
61  layerE->GetOutputSlot(0).Connect(layerB->GetInputSlot(0));
62  layerD->GetOutputSlot(0).Connect(layerC->GetInputSlot(0));
63  layerB->GetOutputSlot(0).Connect(layerC->GetInputSlot(1));
64  layerC->GetOutputSlot(0).Connect(layerO->GetInputSlot(0));
65 
66  // check order is valid
67  BOOST_TEST(CheckOrder(graph, layerA, layerD));
68  BOOST_TEST(CheckOrder(graph, layerA, layerE));
69  BOOST_TEST(CheckOrder(graph, layerD, layerC));
70  BOOST_TEST(CheckOrder(graph, layerE, layerB));
71  BOOST_TEST(CheckOrder(graph, layerB, layerC));
72 }
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: GraphUtils.cpp:68
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:402
int Connect(InputSlot &destination)
Definition: Layer.cpp:83
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:316
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:25
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:318

◆ BOOST_AUTO_TEST_CASE() [3/6]

BOOST_AUTO_TEST_CASE ( InsertNewLayerBefore  )

Definition at line 74 of file GraphTests.cpp.

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

75 {
76  armnn::Graph graph;
77  armnn::TensorInfo tensorInfo({ 1, 1, 1, 1 }, armnn::DataType::Float32);
78 
79  std::vector<armnn::Layer*> order;
80 
81  armnn::ActivationDescriptor activationDefaults;
82  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::InputLayer>(0, "layerA"));
83  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerB"));
84  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerC"));
85  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::AdditionLayer>("layerD"));
86  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::OutputLayer>(0, "output"));
87 
88  armnn::Layer* const layerA = GetFirstLayerWithName(graph, "layerA");
89  armnn::Layer* const layerB = GetFirstLayerWithName(graph, "layerB");
90  armnn::Layer* const layerC = GetFirstLayerWithName(graph, "layerC");
91  armnn::Layer* const layerD = GetFirstLayerWithName(graph, "layerD");
92  armnn::Layer* const layerO = GetFirstLayerWithName(graph, "output");
93 
94  // A
95  // / \'
96  // B C
97  // \ /
98  // D
99  layerA->GetOutputSlot(0).SetTensorInfo(tensorInfo);
100  layerB->GetOutputSlot(0).SetTensorInfo(tensorInfo);
101  layerC->GetOutputSlot(0).SetTensorInfo(tensorInfo);
102  layerD->GetOutputSlot(0).SetTensorInfo(tensorInfo);
103 
104  layerA->GetOutputSlot(0).Connect(layerB->GetInputSlot(0));
105  layerA->GetOutputSlot(0).Connect(layerC->GetInputSlot(0));
106  layerB->GetOutputSlot(0).Connect(layerD->GetInputSlot(0));
107  layerC->GetOutputSlot(0).Connect(layerD->GetInputSlot(1));
108  layerD->GetOutputSlot(0).Connect(layerO->GetInputSlot(0));
109 
110  // Checks order is valid.
111  BOOST_TEST(CheckOrder(graph, layerA, layerB));
112  BOOST_TEST(CheckOrder(graph, layerA, layerC));
113  BOOST_TEST(CheckOrder(graph, layerB, layerD));
114  BOOST_TEST(CheckOrder(graph, layerC, layerD));
115 
116  // A
117  // / \'
118  // B C
119  // \ |
120  // \ E
121  // \|
122  // D
123  BOOST_CHECK_NO_THROW(graph.InsertNewLayer<armnn::ActivationLayer>(layerD->GetInputSlot(1),
124  activationDefaults,
125  "layerE"));
126 
127  armnn::Layer* const layerE = GetFirstLayerWithName(graph, "layerE");
128 
129  // Checks order is valid.
130  BOOST_TEST(CheckOrder(graph, layerA, layerB));
131  BOOST_TEST(CheckOrder(graph, layerA, layerC));
132  BOOST_TEST(CheckOrder(graph, layerB, layerD));
133  BOOST_TEST(CheckOrder(graph, layerC, layerE));
134  BOOST_TEST(CheckOrder(graph, layerE, layerD));
135 
136  // A
137  // /|
138  // / F
139  // / |
140  // B C
141  // \ |
142  // \ E
143  // \|
144  // D
145  BOOST_CHECK_NO_THROW(graph.InsertNewLayer<armnn::ActivationLayer>(layerC->GetInputSlot(0),
146  activationDefaults,
147  "layerF"));
148 
149  armnn::Layer* const layerF = GetFirstLayerWithName(graph, "layerF");
150 
151  // Checks order is valid.
152  BOOST_TEST(CheckOrder(graph, layerA, layerB));
153  BOOST_TEST(CheckOrder(graph, layerA, layerF));
154  BOOST_TEST(CheckOrder(graph, layerF, layerC));
155  BOOST_TEST(CheckOrder(graph, layerB, layerD));
156  BOOST_TEST(CheckOrder(graph, layerC, layerE));
157  BOOST_TEST(CheckOrder(graph, layerE, layerD));
158 }
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: GraphUtils.cpp:68
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:402
int Connect(InputSlot &destination)
Definition: Layer.cpp:83
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:316
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:25
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:318
LayerT * InsertNewLayer(InputSlot &insertBefore, Args &&... args)
Inserts a new layer between the output slot currently connected to insertBefore and insertBefore itse...
Definition: Graph.hpp:416

◆ BOOST_AUTO_TEST_CASE() [4/6]

BOOST_AUTO_TEST_CASE ( InsertNewLayerAfter  )

Definition at line 160 of file GraphTests.cpp.

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

161 {
162  armnn::Graph graph;
163  armnn::TensorInfo tensorInfo({ 1, 1, 1, 1 }, armnn::DataType::Float32);
164 
165  std::vector<armnn::Layer*> order;
166 
167  armnn::ActivationDescriptor activationDefaults;
168  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::InputLayer>(0, "layerA"));
169  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerB"));
170  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::ActivationLayer>(activationDefaults, "layerC"));
171  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::AdditionLayer>("layerD"));
172  BOOST_CHECK_NO_THROW(graph.AddLayer<armnn::OutputLayer>(0, "output"));
173 
174  armnn::Layer* const layerA = GetFirstLayerWithName(graph, "layerA");
175  armnn::Layer* const layerB = GetFirstLayerWithName(graph, "layerB");
176  armnn::Layer* const layerC = GetFirstLayerWithName(graph, "layerC");
177  armnn::Layer* const layerD = GetFirstLayerWithName(graph, "layerD");
178  armnn::Layer* const layerO = GetFirstLayerWithName(graph, "output");
179 
180  // A
181  // / \'
182  // B C
183  // \ /
184  // D
185  layerA->GetOutputSlot(0).SetTensorInfo(tensorInfo);
186  layerB->GetOutputSlot(0).SetTensorInfo(tensorInfo);
187  layerC->GetOutputSlot(0).SetTensorInfo(tensorInfo);
188  layerD->GetOutputSlot(0).SetTensorInfo(tensorInfo);
189 
190  layerA->GetOutputSlot(0).Connect(layerB->GetInputSlot(0));
191  layerA->GetOutputSlot(0).Connect(layerC->GetInputSlot(0));
192  layerB->GetOutputSlot(0).Connect(layerD->GetInputSlot(0));
193  layerC->GetOutputSlot(0).Connect(layerD->GetInputSlot(1));
194  layerD->GetOutputSlot(0).Connect(layerO->GetInputSlot(0));
195 
196  // Checks order is valid.
197  BOOST_TEST(CheckOrder(graph, layerA, layerB));
198  BOOST_TEST(CheckOrder(graph, layerA, layerC));
199  BOOST_TEST(CheckOrder(graph, layerB, layerD));
200  BOOST_TEST(CheckOrder(graph, layerC, layerD));
201 
202  // A
203  // / \'
204  // B C
205  // \ |
206  // \ E
207  // \|
208  // D
209  BOOST_CHECK_NO_THROW(graph.InsertNewLayer<armnn::ActivationLayer>(layerC->GetOutputSlot(),
210  activationDefaults,
211  "layerE"));
212 
213  armnn::Layer* const layerE = GetFirstLayerWithName(graph, "layerE");
214 
215  // Checks order is valid.
216  BOOST_TEST(CheckOrder(graph, layerA, layerB));
217  BOOST_TEST(CheckOrder(graph, layerA, layerC));
218  BOOST_TEST(CheckOrder(graph, layerB, layerD));
219  BOOST_TEST(CheckOrder(graph, layerC, layerE));
220  BOOST_TEST(CheckOrder(graph, layerE, layerD));
221 
222 
223  // A
224  // |
225  // F
226  // / \'
227  // B C
228  // \ |
229  // \ E
230  // \ /
231  // D
232  BOOST_CHECK_NO_THROW(graph.InsertNewLayer<armnn::ActivationLayer>(layerA->GetOutputSlot(),
233  activationDefaults,
234  "layerF"));
235 
236  armnn::Layer* const layerF = GetFirstLayerWithName(graph, "layerF");
237 
238  // Checks order is valid.
239  BOOST_TEST(CheckOrder(graph, layerA, layerF));
240  BOOST_TEST(CheckOrder(graph, layerF, layerB));
241  BOOST_TEST(CheckOrder(graph, layerF, layerC));
242  BOOST_TEST(CheckOrder(graph, layerB, layerD));
243  BOOST_TEST(CheckOrder(graph, layerC, layerE));
244  BOOST_TEST(CheckOrder(graph, layerE, layerD));
245 }
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: GraphUtils.cpp:68
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:402
int Connect(InputSlot &destination)
Definition: Layer.cpp:83
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:316
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:25
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:318
LayerT * InsertNewLayer(InputSlot &insertBefore, Args &&... args)
Inserts a new layer between the output slot currently connected to insertBefore and insertBefore itse...
Definition: Graph.hpp:416

◆ BOOST_AUTO_TEST_CASE() [5/6]

BOOST_AUTO_TEST_CASE ( DuplicateLayerNames  )

Definition at line 576 of file GraphTests.cpp.

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

577 {
578  armnn::Graph graph;
579 
580  armnn::InputLayer* const inputLayer = graph.AddLayer<armnn::InputLayer>(0, "layer");
582 
583  armnn::OutputLayer* const outputLayer = graph.AddLayer<armnn::OutputLayer>(0, "layer");
584  outputLayer->SetBackendId(armnn::Compute::CpuRef);
585 
586  inputLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
587 
588  auto it = graph.TopologicalSort().begin();
589  BOOST_TEST(((*it)->GetType() == armnn::LayerType::Input));
590  BOOST_TEST(((*std::next(it))->GetType() == armnn::LayerType::Output));
591 }
Iterator begin()
Returns iterator pointing to the beginning of the list. Lowercase for range-based for loops...
Definition: Graph.hpp:162
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:402
int Connect(InputSlot &destination)
Definition: Layer.cpp:83
void SetBackendId(const BackendId &id)
Definition: Layer.hpp:270
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:316
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:318
Graph & TopologicalSort()
Sorts layers in topological order and return this.
Definition: Graph.hpp:177

◆ BOOST_AUTO_TEST_CASE() [6/6]

BOOST_AUTO_TEST_CASE ( CheckGraphConstTensorSharing  )

Definition at line 593 of file GraphTests.cpp.

References Graph::AddLayer(), BOOST_AUTO_TEST_SUITE_END(), armnn::Float32, and FullyConnectedLayer::m_Weight.

594 {
595  armnn::Graph graph0;
596  const float* sharedWeightPtr;
597 
598  {
599  armnn::Graph graph1;
600 
601  armnn::FullyConnectedLayer* const fcLayer =
603 
604  float weight = 1.0f;
605  armnn::ConstTensor constTensor({{ 1, 1 }, armnn::DataType::Float32}, &weight);
606  fcLayer->m_Weight = std::make_shared<armnn::ScopedTensorHandle>(constTensor);;
607  // point sharedWeightPtr to graph1's const tensor
608  sharedWeightPtr = fcLayer->m_Weight->GetConstTensor<float>();
609 
610  graph0 = armnn::Graph(graph1);
611  // graph1 goes out of scope
612  }
613 
614  BOOST_TEST(*sharedWeightPtr == 1);
615 }
LayerT * AddLayer(Args &&... args)
Adds a new layer, of type LayerType, to the graph constructed with the arguments passed.
Definition: Graph.hpp:402
This layer represents a fully connected operation.
std::shared_ptr< ConstTensorHandle > m_Weight
A unique pointer to store Weight values.
A FullyConnectedDescriptor for the FullyConnectedLayer.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314

◆ BOOST_FIXTURE_TEST_CASE() [1/3]

BOOST_FIXTURE_TEST_CASE ( AddCopyLayers  ,
CopyLayersFixture   
)

Definition at line 516 of file GraphTests.cpp.

517 {
518  InitialiseTestGraph();
519  const armnn::Graph origGraph(m_Graph);
520  m_Graph.AddCompatibilityLayers(m_Backends, m_FactoryRegistry);
521 
522  TestGraphAfterAddingCopyLayers(m_Graph, origGraph);
523 }

◆ BOOST_FIXTURE_TEST_CASE() [2/3]

BOOST_FIXTURE_TEST_CASE ( AddCopyLayersSeveralTimes  ,
CopyLayersFixture   
)

Definition at line 525 of file GraphTests.cpp.

526 {
527  InitialiseTestGraph();
528  m_Graph.AddCompatibilityLayers(m_Backends, m_FactoryRegistry);
529 
530  // Calling AddCompatibilityLayers() several times should not change the connections.
531  const std::vector<Edge> edges = GetEdgeList(m_Graph);
532  for (int i = 0; i < 4; ++i)
533  {
534  m_Graph.AddCompatibilityLayers(m_Backends, m_FactoryRegistry);
535  const std::vector<Edge> otherEdges = GetEdgeList(m_Graph);
536  BOOST_TEST((edges == otherEdges));
537  }
538 }

◆ BOOST_FIXTURE_TEST_CASE() [3/3]

BOOST_FIXTURE_TEST_CASE ( CopyLayersAddedBetweenSameLayersHaveDifferentNames  ,
CopyLayersFixture   
)

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

541 {
542  armnn::Graph graph;
543 
544  armnn::InputLayer* const inputLayer = graph.AddLayer<armnn::InputLayer>(0, "input");
546 
547  armnn::ViewsDescriptor splitterDesc(2);
548  armnn::SplitterLayer* const splitterLayer = graph.AddLayer<armnn::SplitterLayer>(splitterDesc, "splitter");
549  splitterLayer->SetBackendId(armnn::Compute::GpuAcc);
550 
551  armnn::AdditionLayer* const additionLayer = graph.AddLayer<armnn::AdditionLayer>("addition");
552  additionLayer->SetBackendId(armnn::Compute::CpuRef);
553 
554  armnn::OutputLayer* const outputLayer = graph.AddLayer<armnn::OutputLayer>(0, "output");
555  outputLayer->SetBackendId(armnn::Compute::CpuRef);
556 
557  inputLayer->GetOutputSlot(0).Connect(splitterLayer->GetInputSlot(0));
558  splitterLayer->GetOutputSlot(0).Connect(additionLayer->GetInputSlot(0));
559  splitterLayer->GetOutputSlot(1).Connect(additionLayer->GetInputSlot(1));
560  additionLayer->GetOutputSlot(0).Connect(outputLayer->GetInputSlot(0));
561 
566 
567  graph.AddCompatibilityLayers(m_Backends, m_FactoryRegistry);
568 
569  std::vector<Edge> edges = GetEdgeList(graph);
570  BOOST_CHECK(edges.size() == 6u);
571  std::sort(edges.begin(), edges.end());
572  auto last = std::unique(edges.begin(), edges.end());
573  BOOST_CHECK_MESSAGE(last == edges.end(), "Found duplicated edges after AddCompatibilityLayers()");
574 }
This layer represents a split operation.
A ViewsDescriptor for the SplitterLayer.
void SetEdgeStrategy(unsigned int connectionIndex, EdgeStrategy strategy)
Definition: Layer.cpp:181
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:402
Source backends tensor data can be exported to destination backend tensor without copy...
int Connect(InputSlot &destination)
Definition: Layer.cpp:83
void SetBackendId(const BackendId &id)
Definition: Layer.hpp:270
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:316
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:318
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:300