aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/armnn/Graph.cpp4
-rw-r--r--src/armnn/Graph.hpp2
-rw-r--r--src/armnn/SubGraph.hpp7
-rw-r--r--src/armnn/SubGraphSelector.cpp2
4 files changed, 12 insertions, 3 deletions
diff --git a/src/armnn/Graph.cpp b/src/armnn/Graph.cpp
index 1bd4fbd85a..be0dd5f2ce 100644
--- a/src/armnn/Graph.cpp
+++ b/src/armnn/Graph.cpp
@@ -318,9 +318,9 @@ void Graph::SubstituteSubGraph(std::unique_ptr<SubGraph> subGraph, const SubGrap
void Graph::ReplaceSubGraphConnections(const SubGraph& subGraph, IConnectableLayer* substituteLayer)
{
BOOST_ASSERT(substituteLayer != nullptr);
- BOOST_ASSERT_MSG(std::find(m_Layers.begin(), m_Layers.end(), substituteLayer) != m_Layers.end(),
- "Substitute layer is not a member of graph");
+ // Create a new sub-graph with only the given layer, using
+ // the given sub-graph as a reference of which parent graph to use
SubGraph substituteSubGraph(subGraph, substituteLayer);
ReplaceSubGraphConnections(subGraph, substituteSubGraph);
}
diff --git a/src/armnn/Graph.hpp b/src/armnn/Graph.hpp
index 8046977411..dd6a825f57 100644
--- a/src/armnn/Graph.hpp
+++ b/src/armnn/Graph.hpp
@@ -161,6 +161,8 @@ public:
/// and relinking them via an intermediary copy layers.
void AddCopyLayers();
+ /// Substitutes the given sub-graph with either a new layer or a new sub-graph.
+ /// In either case, the given layer or all the layers in the given sub-graph must belong to this graph.
void SubstituteSubGraph(std::unique_ptr<SubGraph> subGraph, IConnectableLayer* substituteLayer);
void SubstituteSubGraph(std::unique_ptr<SubGraph> subGraph, const SubGraph& substituteSubGraph);
diff --git a/src/armnn/SubGraph.hpp b/src/armnn/SubGraph.hpp
index 81166f1285..cb44f8ce3d 100644
--- a/src/armnn/SubGraph.hpp
+++ b/src/armnn/SubGraph.hpp
@@ -56,7 +56,7 @@ public:
/// Updates this sub-graph with the contents of the whole given graph.
void Update(Graph& graph);
- /// Adds a new layer, of type LayerType, to the graph this sub-graph is a view of.
+ /// Adds a new layer, of type LayerType, to the parent graph of this sub-graph.
template <typename LayerT, typename... Args>
LayerT* AddLayer(Args&&... args) const;
@@ -85,8 +85,13 @@ public:
private:
void CheckSubGraph();
+ /// The list of pointers to the input slots of the parent graph.
InputSlots m_InputSlots;
+
+ /// The list of pointers to the output slots of the parent graph.
OutputSlots m_OutputSlots;
+
+ /// The list of pointers to the layers of the parent graph.
Layers m_Layers;
/// Pointer to the graph this sub-graph is a view of.
diff --git a/src/armnn/SubGraphSelector.cpp b/src/armnn/SubGraphSelector.cpp
index 4abf01c88f..4b3f79921f 100644
--- a/src/armnn/SubGraphSelector.cpp
+++ b/src/armnn/SubGraphSelector.cpp
@@ -174,6 +174,8 @@ SubGraphSelector::SelectSubGraphs(SubGraph& subGraph, const LayerSelectorFunctio
infoPtr->CollectNonSelectedOutputSlots(outputs, selector);
layers.push_back(infoPtr->m_Layer);
}
+ // Create a new sub-graph with the new lists of input/output slots and layer, using
+ // the given sub-graph as a reference of which parent graph to use
result.emplace_back(std::make_unique<SubGraph>(subGraph,
std::move(inputs),
std::move(outputs),