diff options
author | Aron Virginas-Tar <Aron.Virginas-Tar@arm.com> | 2019-10-03 11:15:39 +0100 |
---|---|---|
committer | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-10-03 12:35:20 +0000 |
commit | 781ced9d1472486f86314e320a00d62329dcd363 (patch) | |
tree | 727c7081c84c023b4004202eeee025f0451ae904 /src/armnnDeserializer | |
parent | ce5045a00485f8a8c35814c0781ccbcca5678e5c (diff) | |
download | armnn-781ced9d1472486f86314e320a00d62329dcd363.tar.gz |
IVGCVSW-3934 Add serialization support for INSTANCE_NORMALIZATION
Signed-off-by: Aron Virginas-Tar <Aron.Virginas-Tar@arm.com>
Change-Id: If9b4d30cbd625206ec1c7d37dd8b449983442147
Diffstat (limited to 'src/armnnDeserializer')
-rw-r--r-- | src/armnnDeserializer/Deserializer.cpp | 32 | ||||
-rw-r--r-- | src/armnnDeserializer/Deserializer.hpp | 1 | ||||
-rw-r--r-- | src/armnnDeserializer/DeserializerSupport.md | 1 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/armnnDeserializer/Deserializer.cpp b/src/armnnDeserializer/Deserializer.cpp index c85282f418..960d300fa5 100644 --- a/src/armnnDeserializer/Deserializer.cpp +++ b/src/armnnDeserializer/Deserializer.cpp @@ -204,6 +204,7 @@ m_ParserFunctions(Layer_MAX+1, &Deserializer::ParseUnsupportedLayer) m_ParserFunctions[Layer_FloorLayer] = &Deserializer::ParseFloor; m_ParserFunctions[Layer_GatherLayer] = &Deserializer::ParseGather; m_ParserFunctions[Layer_GreaterLayer] = &Deserializer::ParseGreater; + m_ParserFunctions[Layer_InstanceNormalizationLayer] = &Deserializer::ParseInstanceNormalization; m_ParserFunctions[Layer_L2NormalizationLayer] = &Deserializer::ParseL2Normalization; m_ParserFunctions[Layer_LstmLayer] = &Deserializer::ParseLstm; m_ParserFunctions[Layer_MaximumLayer] = &Deserializer::ParseMaximum; @@ -281,6 +282,8 @@ Deserializer::LayerBaseRawPtr Deserializer::GetBaseLayer(const GraphPtr& graphPt return graphPtr->layers()->Get(layerIndex)->layer_as_GreaterLayer()->base(); case Layer::Layer_InputLayer: return graphPtr->layers()->Get(layerIndex)->layer_as_InputLayer()->base()->base(); + case Layer::Layer_InstanceNormalizationLayer: + return graphPtr->layers()->Get(layerIndex)->layer_as_InstanceNormalizationLayer()->base(); case Layer::Layer_L2NormalizationLayer: return graphPtr->layers()->Get(layerIndex)->layer_as_L2NormalizationLayer()->base(); case Layer::Layer_LstmLayer: @@ -1293,6 +1296,35 @@ void Deserializer::ParseGreater(GraphPtr graph, unsigned int layerIndex) RegisterOutputSlots(graph, layerIndex, layer); } +void Deserializer::ParseInstanceNormalization(GraphPtr graph, unsigned int layerIndex) +{ + CHECK_LAYERS(graph, 0, layerIndex); + + auto inputs = GetInputs(graph, layerIndex); + CHECK_VALID_SIZE(inputs.size(), 1); + + auto outputs = GetOutputs(graph, layerIndex); + CHECK_VALID_SIZE(outputs.size(), 1); + + auto fbLayer = graph->layers()->Get(layerIndex)->layer_as_InstanceNormalizationLayer(); + auto fbDescriptor = fbLayer->descriptor(); + + armnn::InstanceNormalizationDescriptor descriptor; + descriptor.m_Gamma = fbDescriptor->gamma(); + descriptor.m_Beta = fbDescriptor->beta(); + descriptor.m_Eps = fbDescriptor->eps(); + descriptor.m_DataLayout = ToDataLayout(fbDescriptor->dataLayout()); + + const std::string layerName = GetLayerName(graph, layerIndex); + const armnn::TensorInfo outputInfo = ToTensorInfo(outputs[0]); + + IConnectableLayer* layer = m_Network->AddInstanceNormalizationLayer(descriptor, layerName.c_str()); + layer->GetOutputSlot(0).SetTensorInfo(outputInfo); + + RegisterInputSlots(graph, layerIndex, layer); + RegisterOutputSlots(graph, layerIndex, layer); +} + void Deserializer::ParseL2Normalization(GraphPtr graph, unsigned int layerIndex) { CHECK_LAYERS(graph, 0, layerIndex); diff --git a/src/armnnDeserializer/Deserializer.hpp b/src/armnnDeserializer/Deserializer.hpp index 0e2a34fc80..b5de6a76d0 100644 --- a/src/armnnDeserializer/Deserializer.hpp +++ b/src/armnnDeserializer/Deserializer.hpp @@ -96,6 +96,7 @@ private: void ParseFullyConnected(GraphPtr graph, unsigned int layerIndex); void ParseGather(GraphPtr graph, unsigned int layerIndex); void ParseGreater(GraphPtr graph, unsigned int layerIndex); + void ParseInstanceNormalization(GraphPtr graph, unsigned int layerIndex); void ParseL2Normalization(GraphPtr graph, unsigned int layerIndex); void ParseMaximum(GraphPtr graph, unsigned int layerIndex); void ParseMean(GraphPtr graph, unsigned int layerIndex); diff --git a/src/armnnDeserializer/DeserializerSupport.md b/src/armnnDeserializer/DeserializerSupport.md index cbc3eb97fd..31b975f458 100644 --- a/src/armnnDeserializer/DeserializerSupport.md +++ b/src/armnnDeserializer/DeserializerSupport.md @@ -26,6 +26,7 @@ The Arm NN SDK Deserialize parser currently supports the following layers: * Gather * Greater * Input +* InstanceNormalization * L2Normalization * Lstm * Maximum |