From af000a907d16a330ca336044fadf13e3f73c35b8 Mon Sep 17 00:00:00 2001 From: Nattapat Chaimanowong Date: Thu, 16 May 2019 16:32:35 +0100 Subject: IVGCVSW-2964 Fix issue with Deserializer creating ciruclar graph *Issue was caused by using layer index with respect to flatbuffer layers vector in place of the index property on each layer base (and vice versa). These are not necessarily the same. Signed-off-by: Nattapat Chaimanowong Change-Id: Ide3e33c77f394cd1b6850c7c61e4bee2dede76d3 --- src/armnnDeserializer/Deserializer.hpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/armnnDeserializer/Deserializer.hpp') diff --git a/src/armnnDeserializer/Deserializer.hpp b/src/armnnDeserializer/Deserializer.hpp index c647ac3639..38a6b602fc 100644 --- a/src/armnnDeserializer/Deserializer.hpp +++ b/src/armnnDeserializer/Deserializer.hpp @@ -51,8 +51,6 @@ public: static GraphPtr LoadGraphFromBinary(const uint8_t* binaryContent, size_t len); static TensorRawPtrVector GetInputs(const GraphPtr& graph, unsigned int layerIndex); static TensorRawPtrVector GetOutputs(const GraphPtr& graph, unsigned int layerIndex); - static LayerBaseRawPtrVector GetGraphInputs(const GraphPtr& graphPtr); - static LayerBaseRawPtrVector GetGraphOutputs(const GraphPtr& graphPtr); static LayerBaseRawPtr GetBaseLayer(const GraphPtr& graphPtr, unsigned int layerIndex); static int32_t GetBindingLayerInfo(const GraphPtr& graphPtr, unsigned int layerIndex); static std::string GetLayerName(const GraphPtr& graph, unsigned int index); @@ -116,17 +114,23 @@ private: void ParseSubtraction(GraphPtr graph, unsigned int layerIndex); void ParseSwitch(GraphPtr graph, unsigned int layerIndex); - void RegisterOutputSlotOfConnection(uint32_t sourceLayerIndex, armnn::IOutputSlot* slot); - void RegisterInputSlotOfConnection(uint32_t sourceLayerIndex, uint32_t outputSlotIndex, armnn::IInputSlot* slot); void RegisterInputSlots(GraphPtr graph, uint32_t layerIndex, armnn::IConnectableLayer* layer); void RegisterOutputSlots(GraphPtr graph, uint32_t layerIndex, armnn::IConnectableLayer* layer); + + // NOTE index here must be from flatbuffer object index property + void RegisterOutputSlotOfConnection(uint32_t sourceLayerIndex, uint32_t outputSlotIndex, armnn::IOutputSlot* slot); + void RegisterInputSlotOfConnection(uint32_t sourceLayerIndex, uint32_t outputSlotIndex, armnn::IInputSlot* slot); + void ResetParser(); void SetupInputLayers(GraphPtr graphPtr); void SetupOutputLayers(GraphPtr graphPtr); + /// Helper to get the index of the layer in the flatbuffer vector from its index property + unsigned int GetLayerIndexInVector(GraphPtr graph, unsigned int index); + /// The network we're building. Gets cleared after it is passed to the user armnn::INetworkPtr m_Network; std::vector m_ParserFunctions; @@ -135,15 +139,18 @@ private: std::vector m_InputBindings; std::vector m_OutputBindings; - /// A mapping of an output slot to each of the input slots it should be connected to - struct SlotsMap + /// This struct describe connections for each layer + struct Connections { - std::vector outputSlots; + // Maps output slot index (property in flatbuffer object) to IOutputSlot pointer + std::unordered_map outputSlots; + + // Maps output slot index to IInputSlot pointer the output slot should be connected to std::unordered_map> inputSlots; }; - typedef std::vector Connections; - std::vector m_GraphConnections; + /// Maps layer index (index property in flatbuffer object) to Connections for each layer + std::unordered_map m_GraphConnections; }; } //namespace armnnDeserializer -- cgit v1.2.1