ArmNN
 20.02
GraphUtils.cpp File Reference
#include "GraphUtils.hpp"

Go to the source code of this file.

Functions

bool GraphHasNamedLayer (const armnn::Graph &graph, const std::string &name)
 
armnn::LayerGetFirstLayerWithName (armnn::Graph &graph, const std::string &name)
 
bool CheckNumberOfInputSlot (armnn::Layer *layer, unsigned int num)
 
bool CheckNumberOfOutputSlot (armnn::Layer *layer, unsigned int num)
 
bool IsConnected (armnn::Layer *srcLayer, armnn::Layer *destLayer, unsigned int srcSlot, unsigned int destSlot, const armnn::TensorInfo &expectedTensorInfo)
 

Function Documentation

◆ CheckNumberOfInputSlot()

bool CheckNumberOfInputSlot ( armnn::Layer layer,
unsigned int  num 
)

Definition at line 32 of file GraphUtils.cpp.

References Layer::GetNumInputSlots().

Referenced by BOOST_FIXTURE_TEST_CASE().

33 {
34  return layer->GetNumInputSlots() == num;
35 }
unsigned int GetNumInputSlots() const override
Returns the number of connectable input slots.
Definition: Layer.hpp:307

◆ CheckNumberOfOutputSlot()

bool CheckNumberOfOutputSlot ( armnn::Layer layer,
unsigned int  num 
)

Definition at line 37 of file GraphUtils.cpp.

References Layer::GetNumOutputSlots().

Referenced by BOOST_FIXTURE_TEST_CASE().

38 {
39  return layer->GetNumOutputSlots() == num;
40 }
unsigned int GetNumOutputSlots() const override
Returns the number of connectable output slots.
Definition: Layer.hpp:308

◆ GetFirstLayerWithName()

armnn::Layer* GetFirstLayerWithName ( armnn::Graph graph,
const std::string &  name 
)

Definition at line 20 of file GraphUtils.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_FIXTURE_TEST_CASE().

21 {
22  for (auto&& layer : graph)
23  {
24  if (layer->GetNameStr() == name)
25  {
26  return layer;
27  }
28  }
29  return nullptr;
30 }

◆ GraphHasNamedLayer()

bool GraphHasNamedLayer ( const armnn::Graph graph,
const std::string &  name 
)

Definition at line 8 of file GraphUtils.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

9 {
10  for (auto&& layer : graph)
11  {
12  if (layer->GetName() == name)
13  {
14  return true;
15  }
16  }
17  return false;
18 }

◆ IsConnected()

bool IsConnected ( armnn::Layer srcLayer,
armnn::Layer destLayer,
unsigned int  srcSlot,
unsigned int  destSlot,
const armnn::TensorInfo expectedTensorInfo 
)

Definition at line 42 of file GraphUtils.cpp.

References IOutputSlot::GetConnection(), Layer::GetNameStr(), IOutputSlot::GetNumConnections(), Layer::GetOutputSlot(), and IOutputSlot::GetTensorInfo().

Referenced by BOOST_FIXTURE_TEST_CASE().

45 {
46  const armnn::IOutputSlot& outputSlot = srcLayer->GetOutputSlot(srcSlot);
47  const armnn::TensorInfo& tensorInfo = outputSlot.GetTensorInfo();
48  if (expectedTensorInfo != tensorInfo)
49  {
50  return false;
51  }
52  const unsigned int numConnections = outputSlot.GetNumConnections();
53  for (unsigned int c = 0; c < numConnections; ++c)
54  {
55  auto inputSlot = boost::polymorphic_downcast<const armnn::InputSlot*>(outputSlot.GetConnection(c));
56  if (inputSlot->GetOwningLayer().GetNameStr() == destLayer->GetNameStr() &&
57  inputSlot->GetSlotIndex() == destSlot)
58  {
59  return true;
60  }
61  }
62  return false;
63 }
virtual const IInputSlot * GetConnection(unsigned int index) const =0
An output connection slot for a layer.
Definition: INetwork.hpp:37
const std::string & GetNameStr() const
Definition: Layer.hpp:216
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:312
virtual const TensorInfo & GetTensorInfo() const =0
virtual unsigned int GetNumConnections() const =0