From 9d74ba6e85a043e9603445e062315f5c4965fbd6 Mon Sep 17 00:00:00 2001 From: Francis Murtagh Date: Wed, 19 Jan 2022 16:31:58 +0000 Subject: IVGCVSW-6634 SubgraphView: Add method of returning a GetSubgraphWorkingCopy * Add pointer to SubgraphView allowing it to store a working copy implementation of its own representation of graph. * Make SubgraphView a friend of Graph to allow access to layers. * Add constructor to SubgraphView taking SubgraphViewWorkingCopyPtr * Rewrite Graph::SubstituteSubgraph for use on SubgraphView * Add GetWorkingCopy() method * Add tests for replacement of multiplication with DepthwiseConv2d * Check GetBackendHint() has value before passing to PrecompiledLayer * Add GetOwningIConnectableLayer to IInputSlot to allow traversing from IConnectableLayer->IOutputSlot->IInputSlot->IConnectableLayer Signed-off-by: Francis Murtagh Change-Id: Iaaef14448d8b73867eaee9d69f4f98d5d1bf171c --- include/armnn/backends/SubgraphView.hpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'include/armnn/backends/SubgraphView.hpp') diff --git a/include/armnn/backends/SubgraphView.hpp b/include/armnn/backends/SubgraphView.hpp index 33593319cf..dbf0544651 100644 --- a/include/armnn/backends/SubgraphView.hpp +++ b/include/armnn/backends/SubgraphView.hpp @@ -151,7 +151,27 @@ public: void Clear(); + /// This method returns a copy of the original SubgraphView provided by OptimizeSubgraphView with a separate + /// underlying graph from the main ArmNN graph. + /// Backend users should edit this working copy and then add it as a SubstitutionPair, along with original + /// SubgraphView, to the OptimizationViews returned by OptimizeSubgraphView. + /// ArmNN will then decide on whether or not to carry out Substitution of the two SubgraphViews. + SubgraphView GetWorkingCopy(); + + /// These methods should be called on a working copy subgraph created from GetWorkingCopy. + /// They take a SubgraphView pattern to replace and the substitute layer or subgraphView to substitute in. + void SubstituteSubgraph(SubgraphView&, IConnectableLayer*); + void SubstituteSubgraph(SubgraphView&, const SubgraphView&); + private: + struct SubgraphViewWorkingCopy; + + /// Constructs a sub-graph with the given arguments. + SubgraphView(IConnectableLayers&& layers, + IInputSlots&& inputs, + IOutputSlots&& outputs, + std::shared_ptr ptr); + void CheckSubgraph(); /// Arrange the order of layers topologically so that nodes can be visited in valid order @@ -168,5 +188,11 @@ private: /// The list of pointers to the layers of the parent graph. Layers m_Layers; IConnectableLayers m_IConnectableLayers; + + /// Pointer to internal graph implementation. This stores a working copy of a graph, separate from the main + /// ArmNN graph, for use by Backends so that they can edit it and add as a SubstitutionPair to OptimizationViews + /// along with the original SubgraphView. + /// ArmNN will then decide on whether or not to substitute in the provided SubgraphView working copy. + std::shared_ptr p_WorkingCopyImpl; }; } // namespace armnn -- cgit v1.2.1