From 1b56b46fee47a44e0fd019e0a10e93612f1dba36 Mon Sep 17 00:00:00 2001 From: Rob Hughes Date: Tue, 13 Sep 2022 11:47:04 +0100 Subject: 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 --- src/armnn/SubgraphViewSelector.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/armnn/SubgraphViewSelector.cpp') 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; } -- cgit v1.2.1