Derek Lamberti | c2fe5fb | 2019-05-08 10:23:08 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | #include <SubgraphView.hpp> |
| 8 | |
| 9 | namespace armnn |
| 10 | { |
| 11 | class OptimizationViews |
| 12 | { |
| 13 | public: |
| 14 | OptimizationViews() = default; |
| 15 | |
| 16 | struct SubstitutionPair |
| 17 | { |
| 18 | /// Subgraph of Layers from the original graph which should be replaced |
| 19 | SubgraphView m_SubstitutableSubgraph; |
| 20 | |
| 21 | /// A subgraph of new layers which will replace layers in m_SubstitutableSubgraph |
| 22 | SubgraphView m_ReplacementSubgraph; |
| 23 | }; |
| 24 | |
| 25 | using Subgraphs = std::vector<SubgraphView>; |
| 26 | using Substitutions = std::vector<SubstitutionPair>; |
| 27 | |
| 28 | void AddSubstituion(SubstitutionPair&& substitution) |
| 29 | { |
| 30 | m_SuccesfulOptimizations.emplace_back(substitution); |
| 31 | } |
| 32 | |
| 33 | void AddFailedSubgraph(SubgraphView&& subgraph) |
| 34 | { |
| 35 | m_FailedOptimizations.emplace_back(subgraph); |
| 36 | } |
| 37 | |
| 38 | void AddUntouchedSubgraph(SubgraphView&& subgraph) |
| 39 | { |
| 40 | m_UntouchedSubgraphs.emplace_back(subgraph); |
| 41 | } |
| 42 | |
| 43 | Substitutions GetSubstitutions() const { return m_SuccesfulOptimizations; } |
| 44 | Subgraphs GetFailedSubgraphs() const { return m_FailedOptimizations; } |
| 45 | Subgraphs GetUntouchedSubgraphs() const { return m_UntouchedSubgraphs; } |
| 46 | bool Validate(const SubgraphView& originalSubgraph) const; |
| 47 | |
Derek Lamberti | 8106b7c | 2019-05-07 21:33:30 +0100 | [diff] [blame^] | 48 | Graph& GetGraph() { return m_Graph; }; |
| 49 | |
Derek Lamberti | c2fe5fb | 2019-05-08 10:23:08 +0100 | [diff] [blame] | 50 | private: |
| 51 | Substitutions m_SuccesfulOptimizations; ///< Proposed substitutions from successful optimizations |
| 52 | Subgraphs m_FailedOptimizations; ///< Subgraphs from the original subgraph which cannot be supported |
| 53 | Subgraphs m_UntouchedSubgraphs; ///< Subgraphs from the original subgraph which remain unmodified |
Derek Lamberti | 8106b7c | 2019-05-07 21:33:30 +0100 | [diff] [blame^] | 54 | |
| 55 | Graph m_Graph; |
Derek Lamberti | c2fe5fb | 2019-05-08 10:23:08 +0100 | [diff] [blame] | 56 | }; |
| 57 | } //namespace armnn |