ArmNN
 22.05.01
OptimizationViews.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
9 
10 namespace armnn
11 {
12 
14 {
15 public:
16  OptimizationViews(NetworkOptions networkOptions = {}) : m_INetwork(INetwork::Create(networkOptions)) {}
17  OptimizationViews(const OptimizationViews&) = delete;
21 
23  {
24  /// Subgraph of Layers from the original graph which should be replaced
26 
27  /// A subgraph of new layers which will replace layers in m_SubstitutableSubgraph
29  };
30 
31  using Subgraphs = std::vector<SubgraphView>;
32  using Substitutions = std::vector<SubstitutionPair>;
33 
34  void AddSubstitution(SubstitutionPair&& substitution)
35  {
36  m_SuccesfulOptimizations.emplace_back(substitution);
37  }
38 
40  {
41  m_FailedOptimizations.emplace_back(subgraph);
42  }
43 
45  {
46  m_UntouchedSubgraphs.emplace_back(subgraph);
47  }
48 
49  const Substitutions& GetSubstitutions() const { return m_SuccesfulOptimizations; }
50  const Subgraphs& GetFailedSubgraphs() const { return m_FailedOptimizations; }
51  const Subgraphs& GetUntouchedSubgraphs() const { return m_UntouchedSubgraphs; }
52 
53  Substitutions& GetSubstitutions() { return m_SuccesfulOptimizations; }
54  Subgraphs& GetFailedSubgraphs() { return m_FailedOptimizations; }
55  Subgraphs& GetUntouchedSubgraphs() { return m_UntouchedSubgraphs; }
56 
57  bool Validate(const SubgraphView& originalSubgraph) const;
58 
59  ARMNN_DEPRECATED_MSG_REMOVAL_DATE("GetGraph is deprecated. Use GetINetwork instead.", "22.11")
60  Graph& GetGraph() { return m_Graph; }
61 
62  INetworkPtr& GetINetwork() { return m_INetwork; }
63 
64 private:
65  Substitutions m_SuccesfulOptimizations; ///< Proposed substitutions from successful optimizations
66  Subgraphs m_FailedOptimizations; ///< Subgraphs from the original subgraph which cannot be supported
67  Subgraphs m_UntouchedSubgraphs; ///< Subgraphs from the original subgraph which remain unmodified
68 
69  /// Graph object used only as a container for any layer generated by the optimization process
70  Graph m_Graph;
71 
72  /// INetworkPtr object used only as a container for any layer generated by the optimization process
73  /// Also, can use to AddPrecompiledLayer to the SubstitutionPair
74  /// Use in favour of m_Graph which depreciates 22.11
75  INetworkPtr m_INetwork = INetwork::Create();;
76 };
77 
78 } //namespace armnn
void AddSubstitution(SubstitutionPair &&substitution)
std::vector< BackendOptions > NetworkOptions
std::vector< SubgraphView > Subgraphs
OptimizationViews & operator=(const OptimizationViews &)=delete
std::vector< SubstitutionPair > Substitutions
Copyright (c) 2021 ARM Limited and Contributors.
SubgraphView m_SubstitutableSubgraph
Subgraph of Layers from the original graph which should be replaced.
OptimizationViews(NetworkOptions networkOptions={})
The SubgraphView class represents a subgraph of a Graph.
const Subgraphs & GetUntouchedSubgraphs() const
const Subgraphs & GetFailedSubgraphs() const
void AddFailedSubgraph(SubgraphView &&subgraph)
ARMNN_NO_DEPRECATE_WARN_BEGIN struct ARMNN_DEPRECATED_MSG_REMOVAL_DATE("ResizeBilinearQueueDescriptor is deprecated use ResizeQueueDescriptor instead", "22.08") ResizeBilinearQueueDescriptor
SubgraphView m_ReplacementSubgraph
A subgraph of new layers which will replace layers in m_SubstitutableSubgraph.
bool Validate(const SubgraphView &originalSubgraph) const
void AddUntouchedSubgraph(SubgraphView &&subgraph)
const Substitutions & GetSubstitutions() const
Substitutions & GetSubstitutions()
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:241
static INetworkPtr Create(NetworkOptions networkOptions={})
Definition: Network.cpp:476