aboutsummaryrefslogtreecommitdiff
path: root/src/armnnDeserializer/Deserializer.cpp
diff options
context:
space:
mode:
authorNattapat Chaimanowong <nattapat.chaimanowong@arm.com>2019-03-18 12:37:06 +0000
committerNattapat Chaimanowong <nattapat.chaimanowong@arm.com>2019-03-18 12:37:06 +0000
commit3e14a9d2033530df49546ab0da63ad4b6470f551 (patch)
tree030433752c31b42eeecc1ed094c39c2c508dd57f /src/armnnDeserializer/Deserializer.cpp
parent65d30965eef7e8534fc16ea4ded413c42a81c362 (diff)
downloadarmnn-3e14a9d2033530df49546ab0da63ad4b6470f551.tar.gz
IVGCVSW-2686 Add Serializer and Deserializer for DetectionPostProcess
Change-Id: Ife48db5fdb005ebca0a6f21862b0ce971ccf58b7 Signed-off-by: Nattapat Chaimanowong <nattapat.chaimanowong@arm.com>
Diffstat (limited to 'src/armnnDeserializer/Deserializer.cpp')
-rw-r--r--src/armnnDeserializer/Deserializer.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/armnnDeserializer/Deserializer.cpp b/src/armnnDeserializer/Deserializer.cpp
index ba12c37ed8..fc84462abc 100644
--- a/src/armnnDeserializer/Deserializer.cpp
+++ b/src/armnnDeserializer/Deserializer.cpp
@@ -193,6 +193,7 @@ m_ParserFunctions(Layer_MAX+1, &Deserializer::ParseUnsupportedLayer)
m_ParserFunctions[Layer_ConstantLayer] = &Deserializer::ParseConstant;
m_ParserFunctions[Layer_Convolution2dLayer] = &Deserializer::ParseConvolution2d;
m_ParserFunctions[Layer_DepthwiseConvolution2dLayer] = &Deserializer::ParseDepthwiseConvolution2d;
+ m_ParserFunctions[Layer_DetectionPostProcessLayer] = &Deserializer::ParseDetectionPostProcess;
m_ParserFunctions[Layer_DivisionLayer] = &Deserializer::ParseDivision;
m_ParserFunctions[Layer_EqualLayer] = &Deserializer::ParseEqual;
m_ParserFunctions[Layer_FullyConnectedLayer] = &Deserializer::ParseFullyConnected;
@@ -239,6 +240,8 @@ Deserializer::LayerBaseRawPtr Deserializer::GetBaseLayer(const GraphPtr& graphPt
return graphPtr->layers()->Get(layerIndex)->layer_as_Convolution2dLayer()->base();
case Layer::Layer_DepthwiseConvolution2dLayer:
return graphPtr->layers()->Get(layerIndex)->layer_as_DepthwiseConvolution2dLayer()->base();
+ case Layer::Layer_DetectionPostProcessLayer:
+ return graphPtr->layers()->Get(layerIndex)->layer_as_DetectionPostProcessLayer()->base();
case Layer::Layer_DivisionLayer:
return graphPtr->layers()->Get(layerIndex)->layer_as_DivisionLayer()->base();
case Layer::Layer_EqualLayer:
@@ -1021,6 +1024,48 @@ void Deserializer::ParseDepthwiseConvolution2d(GraphPtr graph, unsigned int laye
RegisterOutputSlots(graph, layerIndex, layer);
}
+void Deserializer::ParseDetectionPostProcess(GraphPtr graph, unsigned int layerIndex)
+{
+ CHECK_LAYERS(graph, 0, layerIndex);
+ auto inputs = GetInputs(graph, layerIndex);
+ CHECK_LOCATION();
+ CHECK_VALID_SIZE(inputs.size(), 2);
+
+ auto outputs = GetOutputs(graph, layerIndex);
+ CHECK_VALID_SIZE(outputs.size(), 4);
+
+ auto flatBufferLayer = graph->layers()->Get(layerIndex)->layer_as_DetectionPostProcessLayer();
+ auto layerName = GetLayerName(graph, layerIndex);
+ auto flatBufferDescriptor = flatBufferLayer->descriptor();
+
+ armnn::DetectionPostProcessDescriptor descriptor;
+ descriptor.m_MaxDetections = flatBufferDescriptor->maxDetections();
+ descriptor.m_MaxClassesPerDetection = flatBufferDescriptor->maxClassesPerDetection();
+ descriptor.m_DetectionsPerClass = flatBufferDescriptor->detectionsPerClass();
+ descriptor.m_NmsScoreThreshold = flatBufferDescriptor->nmsScoreThreshold();
+ descriptor.m_NmsIouThreshold = flatBufferDescriptor->nmsIouThreshold();
+ descriptor.m_NumClasses = flatBufferDescriptor->numClasses();
+ descriptor.m_UseRegularNms = flatBufferDescriptor->useRegularNms();
+ descriptor.m_ScaleX = flatBufferDescriptor->scaleX();
+ descriptor.m_ScaleY = flatBufferDescriptor->scaleY();
+ descriptor.m_ScaleW = flatBufferDescriptor->scaleW();
+ descriptor.m_ScaleH = flatBufferDescriptor->scaleH();
+
+ armnn::ConstTensor anchors = ToConstTensor(flatBufferLayer->anchors());
+
+ IConnectableLayer* layer = m_Network->AddDetectionPostProcessLayer(descriptor,
+ anchors,
+ layerName.c_str());
+
+ for (unsigned int i = 0; i < 4; i++)
+ {
+ layer->GetOutputSlot(i).SetTensorInfo(ToTensorInfo(outputs[i]));
+ }
+
+ RegisterInputSlots(graph, layerIndex, layer);
+ RegisterOutputSlots(graph, layerIndex, layer);
+}
+
void Deserializer::ParseDivision(GraphPtr graph, unsigned int layerIndex)
{
CHECK_LAYERS(graph, 0, layerIndex);