ArmNN
 22.02
TestUtils.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "TestUtils.hpp"
7 
9 
10 using namespace armnn;
11 
13  unsigned int fromIndex, unsigned int toIndex)
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 }
43 
44 namespace armnn
45 {
46 
48 {
49  return optNet->pOptimizedNetworkImpl->GetGraph();
50 }
51 
53 {
54  return optNet->pOptimizedNetworkImpl->GetModelOptions();
55 }
56 
58 {
59  return runtime->m_ProfilingService;
60 }
61 
62 }
profiling::ProfilingService & GetProfilingService(armnn::RuntimeImpl *runtime)
Definition: TestUtils.cpp:57
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:66
std::vector< BackendOptions > ModelOptions
Copyright (c) 2021 ARM Limited and Contributors.
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
std::unique_ptr< OptimizedNetworkImpl > pOptimizedNetworkImpl
Definition: INetwork.hpp:828
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
Graph & GetGraphForTesting(IOptimizedNetwork *optNet)
Definition: TestUtils.cpp:47
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
ModelOptions & GetModelOptionsForTesting(IOptimizedNetwork *optNet)
Definition: TestUtils.cpp:52
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.
void Connect(armnn::IConnectableLayer *from, armnn::IConnectableLayer *to, const armnn::TensorInfo &tensorInfo, unsigned int fromIndex, unsigned int toIndex)
Definition: TestUtils.cpp:12
virtual int Connect(IInputSlot &destination)=0
const char * GetLayerTypeAsCString(LayerType type)