Matteo Martincigh | f02e6cd | 2019-05-17 12:15:30 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "CommonTestUtils.hpp" |
| 7 | |
| 8 | #include <backendsCommon/IBackendInternal.hpp> |
| 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 | { |
| 15 | from->GetOutputSlot(fromIndex).Connect(to->GetInputSlot(toIndex)); |
| 16 | from->GetOutputSlot(fromIndex).SetTensorInfo(tensorInfo); |
| 17 | } |
| 18 | |
| 19 | SubgraphView::InputSlots CreateInputsFrom(const std::vector<Layer*>& layers) |
| 20 | { |
| 21 | SubgraphView::InputSlots result; |
| 22 | for (auto&& layer : layers) |
| 23 | { |
| 24 | for (auto&& it = layer->BeginInputSlots(); it != layer->EndInputSlots(); ++it) |
| 25 | { |
| 26 | result.push_back(&(*it)); |
| 27 | } |
| 28 | } |
| 29 | return result; |
| 30 | } |
| 31 | |
| 32 | SubgraphView::OutputSlots CreateOutputsFrom(const std::vector<Layer*>& layers) |
| 33 | { |
| 34 | SubgraphView::OutputSlots result; |
| 35 | for (auto && layer : layers) |
| 36 | { |
| 37 | for (auto&& it = layer->BeginOutputSlots(); it != layer->EndOutputSlots(); ++it) |
| 38 | { |
| 39 | result.push_back(&(*it)); |
| 40 | } |
| 41 | } |
| 42 | return result; |
| 43 | } |
| 44 | |
| 45 | SubgraphView::SubgraphViewPtr CreateSubgraphViewFrom(SubgraphView::InputSlots&& inputs, |
| 46 | SubgraphView::OutputSlots&& outputs, |
| 47 | SubgraphView::Layers&& layers) |
| 48 | { |
| 49 | return std::make_unique<SubgraphView>(std::move(inputs), std::move(outputs), std::move(layers)); |
| 50 | } |
| 51 | |
| 52 | armnn::IBackendInternalUniquePtr CreateBackendObject(const armnn::BackendId& backendId) |
| 53 | { |
| 54 | auto& backendRegistry = BackendRegistryInstance(); |
| 55 | auto backendFactory = backendRegistry.GetFactory(backendId); |
| 56 | auto backendObjPtr = backendFactory(); |
| 57 | |
| 58 | return backendObjPtr; |
| 59 | } |