ArmNN
 24.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 #include "armnnTestUtils/Version.hpp"
11 
12 using namespace armnn;
13 
15  unsigned int fromIndex, unsigned int toIndex)
16 {
17  ARMNN_ASSERT(from);
18  ARMNN_ASSERT(to);
19 
20  try
21  {
22  from->GetOutputSlot(fromIndex).Connect(to->GetInputSlot(toIndex));
23  }
24  catch (const std::out_of_range& exc)
25  {
26  std::ostringstream message;
27 
28  if (to->GetType() == armnn::LayerType::FullyConnected && toIndex == 2)
29  {
30  message << "Tried to connect bias to FullyConnected layer when bias is not enabled: ";
31  }
32 
33  message << "Failed to connect to input slot "
34  << toIndex
35  << " on "
37  << " layer "
38  << std::quoted(to->GetName())
39  << " as the slot does not exist or is unavailable";
40  throw LayerValidationException(message.str());
41  }
42 
43  from->GetOutputSlot(fromIndex).SetTensorInfo(tensorInfo);
44 }
45 
46 namespace armnn
47 {
48 
50 {
51  return optNet->pOptimizedNetworkImpl->GetGraph();
52 }
53 
55 {
56  return optNet->pOptimizedNetworkImpl->GetModelOptions();
57 }
58 
59 arm::pipe::IProfilingService& GetProfilingService(armnn::RuntimeImpl* runtime)
60 {
61  return *(runtime->m_ProfilingService.get());
62 }
63 
64 }
ARMNN_ASSERT
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
armnn::GetLayerTypeAsCString
const char * GetLayerTypeAsCString(LayerType type)
Definition: InternalTypes.cpp:13
armnn::IConnectableLayer::GetName
virtual const char * GetName() const =0
Returns the name of the layer.
armnn::TensorInfo
Definition: Tensor.hpp:152
armnn::IOptimizedNetwork
Definition: INetwork.hpp:901
Assert.hpp
armnn::GetProfilingService
arm::pipe::IProfilingService & GetProfilingService(armnn::RuntimeImpl *runtime)
Definition: TestUtils.cpp:59
armnn::IOutputSlot::SetTensorInfo
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
armnn::LayerValidationException
Definition: Exceptions.hpp:105
TestUtils.hpp
armnn::IConnectableLayer::GetType
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
armnn::LayerType::FullyConnected
@ FullyConnected
armnn::IOutputSlot::Connect
virtual int Connect(IInputSlot &destination)=0
armnn::RuntimeImpl
Definition: Runtime.hpp:30
armnn::IConnectableLayer::GetOutputSlot
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::IConnectableLayer::GetInputSlot
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
armnn::GetGraphForTesting
Graph & GetGraphForTesting(IOptimizedNetwork *optNet)
Definition: TestUtils.cpp:49
armnn::IConnectableLayer
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:80
armnn::ModelOptions
std::vector< BackendOptions > ModelOptions
Definition: BackendOptions.hpp:18
armnn::GetModelOptionsForTesting
ModelOptions & GetModelOptionsForTesting(IOptimizedNetwork *optNet)
Definition: TestUtils.cpp:54
armnn::Graph
Definition: Graph.hpp:30
Connect
void Connect(armnn::IConnectableLayer *from, armnn::IConnectableLayer *to, const armnn::TensorInfo &tensorInfo, unsigned int fromIndex, unsigned int toIndex)
Definition: TestUtils.cpp:14
armnn::IOptimizedNetwork::pOptimizedNetworkImpl
std::unique_ptr< OptimizedNetworkImpl > pOptimizedNetworkImpl
Definition: INetwork.hpp:946