aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/SubgraphViewSelector.cpp
diff options
context:
space:
mode:
authorRob Hughes <robert.hughes@arm.com>2022-09-13 11:47:04 +0100
committerRob Hughes <robert.hughes@arm.com>2022-09-15 07:59:05 +0000
commit1b56b46fee47a44e0fd019e0a10e93612f1dba36 (patch)
treeac8fa425e559a1a6ec4ea69e6c8010f7caeddb27 /src/armnn/SubgraphViewSelector.cpp
parentdb96e6998024ab6b378e9df53287a62006ce1c96 (diff)
downloadarmnn-1b56b46fee47a44e0fd019e0a10e93612f1dba36.tar.gz
Make SubgraphViewSelector give deterministic results
The subgraphs produced by SubgraphViewSelector were not produced in a deterministic order, as the order was determined by the pointer values of some objects, which are not guaranteed to be the same for each execution. This patch adds a post-processing sorting step based on the GUIDs of the layers and the slot indices so that the results will be the same for each execution. This makes debugging the optimised graph much easier as subsequent stages can also be deterministic. It also simplifies some unit tests. Change-Id: I64f552706b7fb1bf82c19d85a448e054277917bc Signed-off-by: Rob Hughes <robert.hughes@arm.com>
Diffstat (limited to 'src/armnn/SubgraphViewSelector.cpp')
-rw-r--r--src/armnn/SubgraphViewSelector.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/armnn/SubgraphViewSelector.cpp b/src/armnn/SubgraphViewSelector.cpp
index e2c5f911a0..b632149924 100644
--- a/src/armnn/SubgraphViewSelector.cpp
+++ b/src/armnn/SubgraphViewSelector.cpp
@@ -521,6 +521,14 @@ SubgraphViewSelector::SelectSubgraphs(SubgraphView& subgraph, const LayerSelecto
std::move(outputs)));
}
+ // Sort subgraphs list into deterministic order, not relying on pointer values which may be different on each
+ // execution. This makes debugging the optimised graph much easier as subsequent stages can also be
+ // deterministic.
+ std::sort(result.begin(), result.end(), [](const SubgraphViewPtr& a, const SubgraphViewPtr& b)
+ {
+ return a->GetIConnectableLayers().front()->GetGuid() < b->GetIConnectableLayers().front()->GetGuid();
+ });
+
return result;
}