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 | |
Teresa Charlin | 2b679db | 2022-02-16 12:57:19 +0000 | [diff] [blame] | 10 | #include "armnnTestUtils/Version.hpp" |
| 11 | |
Matteo Martincigh | bf0e722 | 2019-06-20 17:17:45 +0100 | [diff] [blame] | 12 | using namespace armnn; |
| 13 | |
| 14 | void Connect(armnn::IConnectableLayer* from, armnn::IConnectableLayer* to, const armnn::TensorInfo& tensorInfo, |
| 15 | unsigned int fromIndex, unsigned int toIndex) |
| 16 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 17 | ARMNN_ASSERT(from); |
| 18 | ARMNN_ASSERT(to); |
Matteo Martincigh | bf0e722 | 2019-06-20 17:17:45 +0100 | [diff] [blame] | 19 | |
Cathal Corbett | b8cc2b9 | 2021-10-08 14:43:11 +0100 | [diff] [blame] | 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 " |
| 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 Martincigh | bf0e722 | 2019-06-20 17:17:45 +0100 | [diff] [blame] | 43 | from->GetOutputSlot(fromIndex).SetTensorInfo(tensorInfo); |
| 44 | } |
Sadik Armagan | ea41b57 | 2020-03-19 18:16:46 +0000 | [diff] [blame] | 45 | |
| 46 | namespace armnn |
| 47 | { |
| 48 | |
Francis Murtagh | 3d2b4b2 | 2021-02-15 18:23:17 +0000 | [diff] [blame] | 49 | Graph& GetGraphForTesting(IOptimizedNetwork* optNet) |
| 50 | { |
| 51 | return optNet->pOptimizedNetworkImpl->GetGraph(); |
| 52 | } |
| 53 | |
| 54 | ModelOptions& GetModelOptionsForTesting(IOptimizedNetwork* optNet) |
| 55 | { |
| 56 | return optNet->pOptimizedNetworkImpl->GetModelOptions(); |
| 57 | } |
| 58 | |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 59 | arm::pipe::IProfilingService& GetProfilingService(armnn::RuntimeImpl* runtime) |
Sadik Armagan | ea41b57 | 2020-03-19 18:16:46 +0000 | [diff] [blame] | 60 | { |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 61 | return *(runtime->m_ProfilingService.get()); |
Sadik Armagan | ea41b57 | 2020-03-19 18:16:46 +0000 | [diff] [blame] | 62 | } |
| 63 | |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 64 | } |