Sadik Armagan | a097d2a | 2021-11-24 15:47:28 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | #include <armnn/INetwork.hpp> |
| 9 | #include <Graph.hpp> |
| 10 | #include <Runtime.hpp> |
| 11 | |
| 12 | void Connect(armnn::IConnectableLayer* from, armnn::IConnectableLayer* to, const armnn::TensorInfo& tensorInfo, |
| 13 | unsigned int fromIndex = 0, unsigned int toIndex = 0); |
| 14 | |
| 15 | template <typename LayerT> |
| 16 | bool IsLayerOfType(const armnn::Layer* const layer) |
| 17 | { |
| 18 | return (layer->GetType() == armnn::LayerEnumOf<LayerT>()); |
| 19 | } |
| 20 | |
| 21 | inline bool CheckSequence(const armnn::Graph::ConstIterator first, const armnn::Graph::ConstIterator last) |
| 22 | { |
| 23 | return (first == last); |
| 24 | } |
| 25 | |
| 26 | /// Checks each unary function in Us evaluates true for each correspondent layer in the sequence [first, last). |
| 27 | template <typename U, typename... Us> |
| 28 | bool CheckSequence(const armnn::Graph::ConstIterator first, const armnn::Graph::ConstIterator last, U&& u, Us&&... us) |
| 29 | { |
| 30 | return u(*first) && CheckSequence(std::next(first), last, us...); |
| 31 | } |
| 32 | |
| 33 | template <typename LayerT> |
| 34 | bool CheckRelatedLayers(armnn::Graph& graph, const std::list<std::string>& testRelatedLayers) |
| 35 | { |
| 36 | for (auto& layer : graph) |
| 37 | { |
| 38 | if (layer->GetType() == armnn::LayerEnumOf<LayerT>()) |
| 39 | { |
| 40 | auto& relatedLayers = layer->GetRelatedLayerNames(); |
| 41 | if (!std::equal(relatedLayers.begin(), relatedLayers.end(), testRelatedLayers.begin(), |
| 42 | testRelatedLayers.end())) |
| 43 | { |
| 44 | return false; |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | namespace armnn |
| 53 | { |
| 54 | Graph& GetGraphForTesting(IOptimizedNetwork* optNetPtr); |
| 55 | ModelOptions& GetModelOptionsForTesting(IOptimizedNetwork* optNetPtr); |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 56 | arm::pipe::IProfilingService& GetProfilingService(RuntimeImpl* runtime); |
Sadik Armagan | a097d2a | 2021-11-24 15:47:28 +0000 | [diff] [blame] | 57 | |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 58 | } // namespace armnn |