aboutsummaryrefslogtreecommitdiff
path: root/src/armnnDeserializer/Deserializer.cpp
diff options
context:
space:
mode:
authorConor Kennedy <conor.kennedy@arm.com>2019-02-26 08:29:54 +0000
committerderek.lamberti <derek.lamberti@arm.com>2019-02-26 14:29:20 +0000
commit762778817f6567f405d5d705f9c2131bab799e66 (patch)
tree06302ac5067404e61f7a66161fa6f30ec02682bc /src/armnnDeserializer/Deserializer.cpp
parentb3d481a25ee4e8b24f615627122ccb7a7a1028da (diff)
downloadarmnn-762778817f6567f405d5d705f9c2131bab799e66.tar.gz
IVGCVSW-2683 Add Serializer & Deserializer for Constant
Change-Id: Iad7d89dfa963d9015cbe044f67aecc8bf6634b10 Signed-off-by: Conor Kennedy <conor.kennedy@arm.com>
Diffstat (limited to 'src/armnnDeserializer/Deserializer.cpp')
-rw-r--r--src/armnnDeserializer/Deserializer.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/armnnDeserializer/Deserializer.cpp b/src/armnnDeserializer/Deserializer.cpp
index 09c0502886..b263c3a769 100644
--- a/src/armnnDeserializer/Deserializer.cpp
+++ b/src/armnnDeserializer/Deserializer.cpp
@@ -187,6 +187,7 @@ m_ParserFunctions(Layer_MAX+1, &Deserializer::ParseUnsupportedLayer)
// register supported layers
m_ParserFunctions[Layer_ActivationLayer] = &Deserializer::ParseActivation;
m_ParserFunctions[Layer_AdditionLayer] = &Deserializer::ParseAdd;
+ m_ParserFunctions[Layer_ConstantLayer] = &Deserializer::ParseConstant;
m_ParserFunctions[Layer_Convolution2dLayer] = &Deserializer::ParseConvolution2d;
m_ParserFunctions[Layer_DepthwiseConvolution2dLayer] = &Deserializer::ParseDepthwiseConvolution2d;
m_ParserFunctions[Layer_FullyConnectedLayer] = &Deserializer::ParseFullyConnected;
@@ -207,6 +208,8 @@ Deserializer::LayerBaseRawPtr Deserializer::GetBaseLayer(const GraphPtr& graphPt
return graphPtr->layers()->Get(layerIndex)->layer_as_ActivationLayer()->base();
case Layer::Layer_AdditionLayer:
return graphPtr->layers()->Get(layerIndex)->layer_as_AdditionLayer()->base();
+ case Layer::Layer_ConstantLayer:
+ return graphPtr->layers()->Get(layerIndex)->layer_as_ConstantLayer()->base();
case Layer::Layer_Convolution2dLayer:
return graphPtr->layers()->Get(layerIndex)->layer_as_Convolution2dLayer()->base();
case Layer::Layer_DepthwiseConvolution2dLayer:
@@ -772,6 +775,29 @@ void Deserializer::ParseAdd(GraphPtr graph, unsigned int layerIndex)
RegisterOutputSlots(graph, layerIndex, layer);
}
+void Deserializer::ParseConstant(GraphPtr graph, unsigned int layerIndex)
+{
+ CHECK_LAYERS(graph, 0, layerIndex);
+ CHECK_LOCATION();
+
+ auto outputs = GetOutputs(graph, layerIndex);
+ CHECK_VALID_SIZE(outputs.size(), 1);
+
+ auto layerName = GetLayerName(graph, layerIndex);
+
+ auto serializerLayer = graph->layers()->Get(layerIndex)->layer_as_ConstantLayer();
+ auto serializerInput = serializerLayer->input();
+
+ armnn::ConstTensor input = ToConstTensor(serializerInput);
+
+ IConnectableLayer* layer = m_Network->AddConstantLayer(input, layerName.c_str());
+
+ armnn::TensorInfo outputTensorInfo = ToTensorInfo(outputs[0]);
+ layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
+
+ RegisterOutputSlots(graph, layerIndex, layer);
+}
+
void Deserializer::ParseConvolution2d(GraphPtr graph, unsigned int layerIndex)
{
CHECK_LAYERS(graph, 0, layerIndex);