Matteo Martincigh | bf0e722 | 2019-06-20 17:17:45 +0100 | [diff] [blame] | 1 | // |
Sadik Armagan | a097d2a | 2021-11-24 15:47:28 +0000 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
Matteo Martincigh | bf0e722 | 2019-06-20 17:17:45 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "TestUtils.hpp" |
| 7 | |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 8 | #include <armnn/utility/Assert.hpp> |
Matteo Martincigh | bf0e722 | 2019-06-20 17:17:45 +0100 | [diff] [blame] | 9 | |
| 10 | using namespace armnn; |
| 11 | |
| 12 | void Connect(armnn::IConnectableLayer* from, armnn::IConnectableLayer* to, const armnn::TensorInfo& tensorInfo, |
| 13 | unsigned int fromIndex, unsigned int toIndex) |
| 14 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 15 | ARMNN_ASSERT(from); |
| 16 | ARMNN_ASSERT(to); |
Matteo Martincigh | bf0e722 | 2019-06-20 17:17:45 +0100 | [diff] [blame] | 17 | |
Cathal Corbett | b8cc2b9 | 2021-10-08 14:43:11 +0100 | [diff] [blame] | 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 " |
| 34 | << GetLayerTypeAsCString(to->GetType()) |
| 35 | << " layer " |
| 36 | << std::quoted(to->GetName()) |
| 37 | << " as the slot does not exist or is unavailable"; |
| 38 | throw LayerValidationException(message.str()); |
| 39 | } |
| 40 | |
Matteo Martincigh | bf0e722 | 2019-06-20 17:17:45 +0100 | [diff] [blame] | 41 | from->GetOutputSlot(fromIndex).SetTensorInfo(tensorInfo); |
| 42 | } |
Sadik Armagan | ea41b57 | 2020-03-19 18:16:46 +0000 | [diff] [blame] | 43 | |
| 44 | namespace armnn |
| 45 | { |
| 46 | |
Francis Murtagh | 3d2b4b2 | 2021-02-15 18:23:17 +0000 | [diff] [blame] | 47 | Graph& GetGraphForTesting(IOptimizedNetwork* optNet) |
| 48 | { |
| 49 | return optNet->pOptimizedNetworkImpl->GetGraph(); |
| 50 | } |
| 51 | |
| 52 | ModelOptions& GetModelOptionsForTesting(IOptimizedNetwork* optNet) |
| 53 | { |
| 54 | return optNet->pOptimizedNetworkImpl->GetModelOptions(); |
| 55 | } |
| 56 | |
Kevin May | d92a6e4 | 2021-02-04 10:27:41 +0000 | [diff] [blame] | 57 | profiling::ProfilingService& GetProfilingService(armnn::RuntimeImpl* runtime) |
Sadik Armagan | ea41b57 | 2020-03-19 18:16:46 +0000 | [diff] [blame] | 58 | { |
| 59 | return runtime->m_ProfilingService; |
| 60 | } |
| 61 | |
| 62 | } |