diff options
author | Narumol Prangnawarat <narumol.prangnawarat@arm.com> | 2019-01-25 10:46:40 +0000 |
---|---|---|
committer | Narumol Prangnawarat <narumol.prangnawarat@arm.com> | 2019-01-25 16:59:16 +0000 |
commit | a0d56c77a53f5f991565041927003ce7460730ce (patch) | |
tree | de08bfa6f95752ec8e7b5b58d0b689288f44b36a /src/armnn/layers | |
parent | 12055747d47657a89d60748a078897f6436e6aa0 (diff) | |
download | armnn-a0d56c77a53f5f991565041927003ce7460730ce.tar.gz |
IVGCVSW-2556 Add Layer implementation for Detection PostProcess
* Add DetectionPostProcessDescriptor.
* Add implementation for DetectionPostProcessLayer.
* Unit test to validate output.
Change-Id: If63e83eb2a2978c549071c7aeb272906e7c35fe9
Diffstat (limited to 'src/armnn/layers')
-rw-r--r-- | src/armnn/layers/DetectionPostProcessLayer.cpp | 34 | ||||
-rw-r--r-- | src/armnn/layers/DetectionPostProcessLayer.hpp | 9 |
2 files changed, 43 insertions, 0 deletions
diff --git a/src/armnn/layers/DetectionPostProcessLayer.cpp b/src/armnn/layers/DetectionPostProcessLayer.cpp index 78589229e6..3eea198f90 100644 --- a/src/armnn/layers/DetectionPostProcessLayer.cpp +++ b/src/armnn/layers/DetectionPostProcessLayer.cpp @@ -8,6 +8,7 @@ #include "LayerCloneBase.hpp" #include <armnn/TypesUtils.hpp> +#include <backendsCommon/CpuTensorHandle.hpp> #include <backendsCommon/WorkloadData.hpp> #include <backendsCommon/WorkloadFactory.hpp> @@ -34,6 +35,39 @@ DetectionPostProcessLayer* DetectionPostProcessLayer::Clone(Graph& graph) const void DetectionPostProcessLayer::ValidateTensorShapesFromInputs() { VerifyLayerConnections(2, CHECK_LOCATION()); + + // on this level constant data should not be released. + BOOST_ASSERT_MSG(m_Anchors != nullptr, "DetectionPostProcessLayer: Anchors data should not be null."); + + BOOST_ASSERT_MSG(GetNumOutputSlots() == 4, "DetectionPostProcessLayer: The layer should return 4 outputs."); + + unsigned int detectedBoxes = m_Param.m_MaxDetections * m_Param.m_MaxClassesPerDetection; + + const TensorShape& inferredDetectionBoxes = TensorShape({ 1, detectedBoxes, 4 }); + const TensorShape& inferredDetectionScores = TensorShape({ 1, detectedBoxes }); + const TensorShape& inferredNumberDetections = TensorShape({ 1 }); + + ConditionalThrowIfNotEqual<LayerValidationException>( + "DetectionPostProcessLayer: TensorShape set on OutputSlot[0] does not match the inferred shape.", + GetOutputSlot(0).GetTensorInfo().GetShape(), + inferredDetectionBoxes); + ConditionalThrowIfNotEqual<LayerValidationException>( + "DetectionPostProcessLayer: TensorShape set on OutputSlot[1] does not match the inferred shape.", + GetOutputSlot(1).GetTensorInfo().GetShape(), + inferredDetectionScores); + ConditionalThrowIfNotEqual<LayerValidationException>( + "DetectionPostProcessLayer: TensorShape set on OutputSlot[2] does not match the inferred shape.", + GetOutputSlot(2).GetTensorInfo().GetShape(), + inferredDetectionScores); + ConditionalThrowIfNotEqual<LayerValidationException>( + "DetectionPostProcessLayer: TensorShape set on OutputSlot[3] does not match the inferred shape.", + GetOutputSlot(3).GetTensorInfo().GetShape(), + inferredNumberDetections); +} + +Layer::ConstantTensors DetectionPostProcessLayer::GetConstantTensorsByRef() +{ + return { m_Anchors }; } void DetectionPostProcessLayer::Accept(ILayerVisitor& visitor) const diff --git a/src/armnn/layers/DetectionPostProcessLayer.hpp b/src/armnn/layers/DetectionPostProcessLayer.hpp index 629e3864b3..a1c499e793 100644 --- a/src/armnn/layers/DetectionPostProcessLayer.hpp +++ b/src/armnn/layers/DetectionPostProcessLayer.hpp @@ -10,10 +10,15 @@ namespace armnn { +class ScopedCpuTensorHandle; + /// This layer represents a detection postprocess operator. class DetectionPostProcessLayer : public LayerWithParameters<DetectionPostProcessDescriptor> { public: + /// A unique pointer to store Anchor values. + std::unique_ptr<ScopedCpuTensorHandle> m_Anchors; + /// Makes a workload for the DetectionPostProcess type. /// @param [in] graph The graph where this layer can be found. /// @param [in] factory The workload factory which will create the workload. @@ -39,6 +44,10 @@ protected: /// Default destructor ~DetectionPostProcessLayer() = default; + + /// Retrieve the handles to the constant values stored by the layer. + /// @return A vector of the constant tensors stored by this layer. + ConstantTensors GetConstantTensorsByRef() override; }; } // namespace armnn |