From aa949514c2fd72b61c9546c64da364e5ad0ff8b5 Mon Sep 17 00:00:00 2001 From: Derek Lamberti Date: Wed, 29 May 2019 15:24:52 +0100 Subject: Don't add redundant copies Change-Id: I117698ef6f96d250d55f0d9996319d45450e0c9b Signed-off-by: Derek Lamberti --- src/armnn/Graph.cpp | 5 ++++- src/armnn/test/GraphTests.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/armnn/Graph.cpp b/src/armnn/Graph.cpp index be792a63a5..a5c85092b0 100644 --- a/src/armnn/Graph.cpp +++ b/src/armnn/Graph.cpp @@ -263,7 +263,10 @@ void Graph::AddCopyLayers() // All layers should have been associated with a valid compute device at this point. BOOST_ASSERT(layer.GetBackendId() != Compute::Undefined); // Does not need another copy layer if a copy layer is already present. - return layer.GetType() != LayerType::MemCopy; + return layer.GetType() != LayerType::MemCopy && + // Input and Output layers can perform their own copies internally. + layer.GetType() != LayerType::Input && + layer.GetType() != LayerType::Output; }; for (auto&& srcLayer : m_Layers) diff --git a/src/armnn/test/GraphTests.cpp b/src/armnn/test/GraphTests.cpp index 0777d98d3a..44cfa2eaec 100644 --- a/src/armnn/test/GraphTests.cpp +++ b/src/armnn/test/GraphTests.cpp @@ -545,7 +545,7 @@ BOOST_AUTO_TEST_CASE(CopyLayersAddedBetweenSameLayersHaveDifferentNames) graph.AddCopyLayers(); std::vector edges = GetEdgeList(graph); - BOOST_CHECK(edges.size() == 7u); + BOOST_CHECK(edges.size() == 6u); std::sort(edges.begin(), edges.end()); auto last = std::unique(edges.begin(), edges.end()); BOOST_CHECK_MESSAGE(last == edges.end(), "Found duplicated edges after AddCopyLayers()"); -- cgit v1.2.1