NNXSW-1697 Remove use of SubgraphView that may become invalid.
authorRob Hughes <robert.hughes@arm.com>
Tue, 23 Jul 2019 14:33:39 +0000 (15:33 +0100)
committerRob Hughes <robert.hughes@arm.com>
Tue, 23 Jul 2019 14:58:18 +0000 (15:58 +0100)
The mainSubgraph variable held references to layers in the optimised
graph that become invalid when a graph substitution is made.

The fix is to always use the optimised graph itself rather than a
view of it. The view served no purpose anyway.

Change-Id: Iad75f5829597ec43a774cfd7f2e5e7dede09dfa4

src/armnn/Network.cpp

index 6707cc7..a438008 100644 (file)
@@ -346,9 +346,6 @@ OptimizationResult ApplyBackendOptimizations(OptimizedNetwork* optNetObjPtr,
     // Get the optimized graph
     Graph& optGraph = optNetObjPtr->GetGraph();
 
-    // Get the entire graph as a sub-graph
-    SubgraphView mainSubgraph(optGraph);
-
     // Run backend specific optimizations
     for (auto&& selectedBackend : backendSettings.m_SelectedBackends)
     {
@@ -357,7 +354,7 @@ OptimizationResult ApplyBackendOptimizations(OptimizedNetwork* optNetObjPtr,
 
         // Select sub-graphs based on backend
         SubgraphViewSelector::Subgraphs subgraphs =
-                SubgraphViewSelector::SelectSubgraphs(mainSubgraph,
+                SubgraphViewSelector::SelectSubgraphs(optGraph,
                                                       // Select layers assigned to the requested backend
                                                       [&backendObjPtr](const Layer& layer)
                                                       {