ArmNN
 25.11
Loading...
Searching...
No Matches
OptimizationViews.hpp
Go to the documentation of this file.
1//
2// Copyright © 2017, 2019, 2021-2023 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
10#include <armnn/INetwork.hpp>
12#include <vector>
13
14namespace armnn
15{
16
18{
19public:
20 OptimizationViews(const NetworkOptions& networkOptions = {}) : m_INetwork(INetwork::Create(networkOptions)) {}
25
27 {
28 /// Subgraph of Layers from the original graph which should be replaced
30
31 /// A subgraph of new layers which will replace layers in m_SubstitutableSubgraph
33 };
34
35 using Subgraphs = std::vector<SubgraphView>;
36 using Substitutions = std::vector<SubstitutionPair>;
37
38 void AddSubstitution(SubstitutionPair&& substitution)
39 {
40 m_SuccesfulOptimizations.emplace_back(substitution);
41 }
42
44 {
45 m_FailedOptimizations.emplace_back(subgraph);
46 }
47
49 {
50 m_UntouchedSubgraphs.emplace_back(subgraph);
51 }
52
54 {
55 m_DeletedSubgraphs.emplace_back(subgraph);
56 }
57
58 const Substitutions& GetSubstitutions() const { return m_SuccesfulOptimizations; }
59 const Subgraphs& GetFailedSubgraphs() const { return m_FailedOptimizations; }
60 const Subgraphs& GetUntouchedSubgraphs() const { return m_UntouchedSubgraphs; }
61 const Subgraphs& GetDeletedSubgraphs() const { return m_DeletedSubgraphs; }
62
63 Substitutions& GetSubstitutions() { return m_SuccesfulOptimizations; }
64 Subgraphs& GetFailedSubgraphs() { return m_FailedOptimizations; }
65 Subgraphs& GetUntouchedSubgraphs() { return m_UntouchedSubgraphs; }
66
67 bool Validate(const SubgraphView& originalSubgraph) const;
68
69 INetwork* GetINetwork() { return m_INetwork.get(); }
70 INetwork& GetINetworkRef() { return *m_INetwork; }
71
72private:
73 Substitutions m_SuccesfulOptimizations; ///< Proposed substitutions from successful optimizations
74 Subgraphs m_FailedOptimizations; ///< Subgraphs from the original subgraph which cannot be supported
75 Subgraphs m_UntouchedSubgraphs; ///< Subgraphs from the original subgraph which remain unmodified
76 Subgraphs m_DeletedSubgraphs; ///< Subgraphs from the original subgraph which have been deleted
77
78 /// INetworkPtr object used only as a container for any layer generated by the optimization process
79 /// Also, can use to AddPrecompiledLayer to the SubstitutionPair
80 INetworkPtr m_INetwork = INetwork::Create();
81};
82
83} //namespace armnn
Main network class which provides the interface for building up a neural network.
Definition INetwork.hpp:348
static INetworkPtr Create(const NetworkOptions &networkOptions={})
Definition Network.cpp:682
const Subgraphs & GetUntouchedSubgraphs() const
OptimizationViews & operator=(OptimizationViews &&)=default
void AddFailedSubgraph(SubgraphView &&subgraph)
OptimizationViews(OptimizationViews &&)=default
void AddUntouchedSubgraph(SubgraphView &&subgraph)
void AddDeletedSubgraph(SubgraphView &&subgraph)
std::vector< SubgraphView > Subgraphs
void AddSubstitution(SubstitutionPair &&substitution)
std::vector< SubstitutionPair > Substitutions
bool Validate(const SubgraphView &originalSubgraph) const
const Subgraphs & GetDeletedSubgraphs() const
Substitutions & GetSubstitutions()
OptimizationViews(const OptimizationViews &)=delete
const Subgraphs & GetFailedSubgraphs() const
const Substitutions & GetSubstitutions() const
OptimizationViews & operator=(const OptimizationViews &)=delete
OptimizationViews(const NetworkOptions &networkOptions={})
The SubgraphView class represents a subgraph of a Graph.
Copyright (c) 2021 ARM Limited and Contributors.
std::vector< BackendOptions > NetworkOptions
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition INetwork.hpp:339
SubgraphView m_ReplacementSubgraph
A subgraph of new layers which will replace layers in m_SubstitutableSubgraph.
SubgraphView m_SubstitutableSubgraph
Subgraph of Layers from the original graph which should be replaced.