diff options
author | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-05-09 12:46:16 +0100 |
---|---|---|
committer | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-05-10 10:51:04 +0000 |
commit | 8492433df5eac916c4b7e0695bce63e222a564d4 (patch) | |
tree | 426a56a23bc6b5b8bcfaa74c41919c7ef2e02af0 /src/armnn/Network.cpp | |
parent | f3d102114a6f837f40400c4de50915abc488f3a5 (diff) | |
download | armnn-8492433df5eac916c4b7e0695bce63e222a564d4.tar.gz |
IVGCVSW-3030 Refactor code and fix OptimizeSubgraphView
* Refactored the Optimizer code for readibility, in view of
upcoming changes
* Rename one of the ISubgraphViewConverter interface methods to
give it a more meaningful name
* Improved the OptimizationViews class, added comments and
useful funtion overloads
* Fixed an error in the default implementationof the new
OptimizeSubgraphView method in IBackendInternal
Change-Id: I683a56d562aa093bac06f0e83fb13e144ed81485
Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
Diffstat (limited to 'src/armnn/Network.cpp')
-rw-r--r-- | src/armnn/Network.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/armnn/Network.cpp b/src/armnn/Network.cpp index 1eb40d5ba0..c3f29d4f3b 100644 --- a/src/armnn/Network.cpp +++ b/src/armnn/Network.cpp @@ -365,25 +365,26 @@ OptimizationResult ApplyBackendOptimizations(OptimizedNetwork* optNetObjPtr, for (auto& subgraph : subgraphs) { // Try to optimize the current sub-graph - OptimizationViews optViews = backendObjPtr->OptimizeSubgraphView(*subgraph); - BOOST_ASSERT(optViews.Validate(*subgraph)); + OptimizationViews optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraph); + BOOST_ASSERT(optimizationViews.Validate(*subgraph)); // Optimization attempted, check the resulting optimized sub-graph - for (auto& substitution : optViews.GetSubstitutions()) + for (auto& substitution : optimizationViews.GetSubstitutions()) { // Sub-graph optimized, substitute the sub-graph with the new optimized one in the main optimized graph - SubgraphView& optSubgraph = substitution.m_ReplacementSubgraph; - optGraph.SubstituteSubgraph(substitution.m_SubstitutableSubgraph, optSubgraph); + SubgraphView& replacementSubgraph = substitution.m_ReplacementSubgraph; + SubgraphView& substitutableSubgraph = substitution.m_SubstitutableSubgraph; + optGraph.SubstituteSubgraph(substitutableSubgraph, replacementSubgraph); // Assign the current backend to the optimized sub-graph - std::for_each(optSubgraph.begin(), optSubgraph.end(), [&selectedBackend](Layer* l) + std::for_each(replacementSubgraph.begin(), replacementSubgraph.end(), [&selectedBackend](Layer* l) { BOOST_ASSERT(l); l->SetBackendId(selectedBackend); }); } - if (!optViews.GetFailedSubgraphs().empty()) + if (!optimizationViews.GetFailedSubgraphs().empty()) { std::stringstream warningMsg; warningMsg << "Some sub-graph(s) failed to optimized on " << backendObjPtr->GetId() << " backend."; @@ -398,7 +399,7 @@ OptimizationResult ApplyBackendOptimizations(OptimizedNetwork* optNetObjPtr, } int count=0; - for (auto& failedSubgraph : optViews.GetFailedSubgraphs()) + for (auto& failedSubgraph : optimizationViews.GetFailedSubgraphs()) { // An error occurred: the optimization was attempted but not performed, try different backends std::stringstream subgraphMsg; |