blob: a67eecfd03b2e7733eeb01472a9b1a3e5467f4f3 [file] [log] [blame]
Matteo Martincighbf0e7222019-06-20 17:17:45 +01001//
Sadik Armagana097d2a2021-11-24 15:47:28 +00002// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
Matteo Martincighbf0e7222019-06-20 17:17:45 +01003// SPDX-License-Identifier: MIT
4//
5
6#include "TestUtils.hpp"
7
Narumol Prangnawaratac2770a2020-04-01 16:51:23 +01008#include <armnn/utility/Assert.hpp>
Matteo Martincighbf0e7222019-06-20 17:17:45 +01009
Teresa Charlin2b679db2022-02-16 12:57:19 +000010#include "armnnTestUtils/Version.hpp"
11
Matteo Martincighbf0e7222019-06-20 17:17:45 +010012using namespace armnn;
13
14void Connect(armnn::IConnectableLayer* from, armnn::IConnectableLayer* to, const armnn::TensorInfo& tensorInfo,
15 unsigned int fromIndex, unsigned int toIndex)
16{
Narumol Prangnawaratac2770a2020-04-01 16:51:23 +010017 ARMNN_ASSERT(from);
18 ARMNN_ASSERT(to);
Matteo Martincighbf0e7222019-06-20 17:17:45 +010019
Cathal Corbettb8cc2b92021-10-08 14:43:11 +010020 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 "
36 << GetLayerTypeAsCString(to->GetType())
37 << " layer "
38 << std::quoted(to->GetName())
39 << " as the slot does not exist or is unavailable";
40 throw LayerValidationException(message.str());
41 }
42
Matteo Martincighbf0e7222019-06-20 17:17:45 +010043 from->GetOutputSlot(fromIndex).SetTensorInfo(tensorInfo);
44}
Sadik Armaganea41b572020-03-19 18:16:46 +000045
46namespace armnn
47{
48
Francis Murtagh3d2b4b22021-02-15 18:23:17 +000049Graph& GetGraphForTesting(IOptimizedNetwork* optNet)
50{
51 return optNet->pOptimizedNetworkImpl->GetGraph();
52}
53
54ModelOptions& GetModelOptionsForTesting(IOptimizedNetwork* optNet)
55{
56 return optNet->pOptimizedNetworkImpl->GetModelOptions();
57}
58
Jim Flynnaf947722022-03-02 11:04:47 +000059arm::pipe::IProfilingService& GetProfilingService(armnn::RuntimeImpl* runtime)
Sadik Armaganea41b572020-03-19 18:16:46 +000060{
Jim Flynnaf947722022-03-02 11:04:47 +000061 return *(runtime->m_ProfilingService.get());
Sadik Armaganea41b572020-03-19 18:16:46 +000062}
63
Jim Flynnaf947722022-03-02 11:04:47 +000064}