ArmNN
 21.11
TestUtils.cpp File Reference

Go to the source code of this file.

Namespaces

 armnn
 Copyright (c) 2021 ARM Limited and Contributors.
 

Functions

void Connect (armnn::IConnectableLayer *from, armnn::IConnectableLayer *to, const armnn::TensorInfo &tensorInfo, unsigned int fromIndex, unsigned int toIndex)
 
GraphGetGraphForTesting (IOptimizedNetwork *optNet)
 
ModelOptionsGetModelOptionsForTesting (IOptimizedNetwork *optNet)
 
profiling::ProfilingServiceGetProfilingService (armnn::RuntimeImpl *runtime)
 

Function Documentation

◆ Connect()

void Connect ( armnn::IConnectableLayer from,
armnn::IConnectableLayer to,
const armnn::TensorInfo tensorInfo,
unsigned int  fromIndex,
unsigned int  toIndex 
)

Definition at line 12 of file TestUtils.cpp.

References ARMNN_ASSERT, IOutputSlot::Connect(), armnn::FullyConnected, IConnectableLayer::GetInputSlot(), armnn::GetLayerTypeAsCString(), IConnectableLayer::GetName(), IConnectableLayer::GetOutputSlot(), IConnectableLayer::GetType(), and IOutputSlot::SetTensorInfo().

Referenced by OutputSlot::Connect(), CreatePreluLayerHelper(), CreateStackLayerHelper(), armnn::experimental::CreateStridedSliceNetwork(), OutputSlot::GetOutputHandler(), QLstmEndToEnd(), and TEST_SUITE().

14 {
15  ARMNN_ASSERT(from);
16  ARMNN_ASSERT(to);
17 
18  try
19  {
20  from->GetOutputSlot(fromIndex).Connect(to->GetInputSlot(toIndex));
21  }
22  catch (const std::out_of_range& exc)
23  {
24  std::ostringstream message;
25 
26  if (to->GetType() == armnn::LayerType::FullyConnected && toIndex == 2)
27  {
28  message << "Tried to connect bias to FullyConnected layer when bias is not enabled: ";
29  }
30 
31  message << "Failed to connect to input slot "
32  << toIndex
33  << " on "
35  << " layer "
36  << std::quoted(to->GetName())
37  << " as the slot does not exist or is unavailable";
38  throw LayerValidationException(message.str());
39  }
40 
41  from->GetOutputSlot(fromIndex).SetTensorInfo(tensorInfo);
42 }
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
virtual const char * GetName() const =0
Returns the name of the layer.
virtual int Connect(IInputSlot &destination)=0
const char * GetLayerTypeAsCString(LayerType type)