aboutsummaryrefslogtreecommitdiff
path: root/arm_compute
diff options
context:
space:
mode:
authorgiuros01 <giuseppe.rossini@arm.com>2018-10-03 12:44:35 +0100
committerAnthony Barbier <Anthony.barbier@arm.com>2018-11-15 09:13:14 +0000
commitcd96a26f67bfbb9b0efe6e0e2b229d0b46b4e3e6 (patch)
treebe95114ff6f5a8a17dace8734be6239312631cea /arm_compute
parent1c32bf396eb690a54fd94487e3f258b2c7d31753 (diff)
downloadComputeLibrary-cd96a26f67bfbb9b0efe6e0e2b229d0b46b4e3e6.tar.gz
COMPMID-1329: Add support for GenerateProposals operator in CL
Change-Id: Ib0798cc17496b7817f5b5769b25d98913a33a69d
Diffstat (limited to 'arm_compute')
-rw-r--r--arm_compute/core/CL/CLKernels.h1
-rw-r--r--arm_compute/core/CL/kernels/CLGenerateProposalsLayerKernel.h76
-rw-r--r--arm_compute/core/Types.h163
-rw-r--r--arm_compute/runtime/CL/CLFunctions.h2
-rw-r--r--arm_compute/runtime/CL/functions/CLComputeAllAnchors.h62
-rw-r--r--arm_compute/runtime/CL/functions/CLGenerateProposalsLayer.h146
6 files changed, 448 insertions, 2 deletions
diff --git a/arm_compute/core/CL/CLKernels.h b/arm_compute/core/CL/CLKernels.h
index 12700192e6..cc76231345 100644
--- a/arm_compute/core/CL/CLKernels.h
+++ b/arm_compute/core/CL/CLKernels.h
@@ -83,6 +83,7 @@
#include "arm_compute/core/CL/kernels/CLGaussian3x3Kernel.h"
#include "arm_compute/core/CL/kernels/CLGaussian5x5Kernel.h"
#include "arm_compute/core/CL/kernels/CLGaussianPyramidKernel.h"
+#include "arm_compute/core/CL/kernels/CLGenerateProposalsLayerKernel.h"
#include "arm_compute/core/CL/kernels/CLHOGDescriptorKernel.h"
#include "arm_compute/core/CL/kernels/CLHOGDetectorKernel.h"
#include "arm_compute/core/CL/kernels/CLHarrisCornersKernel.h"
diff --git a/arm_compute/core/CL/kernels/CLGenerateProposalsLayerKernel.h b/arm_compute/core/CL/kernels/CLGenerateProposalsLayerKernel.h
new file mode 100644
index 0000000000..6c883348a5
--- /dev/null
+++ b/arm_compute/core/CL/kernels/CLGenerateProposalsLayerKernel.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_CLGENERATEPROPOSALSLAYERKERNEL_H__
+#define __ARM_COMPUTE_CLGENERATEPROPOSALSLAYERKERNEL_H__
+
+#include "arm_compute/core/CL/ICLKernel.h"
+namespace arm_compute
+{
+class ICLTensor;
+
+/** Interface for Compute All Anchors kernel */
+class CLComputeAllAnchorsKernel : public ICLKernel
+{
+public:
+ /** Default constructor */
+ CLComputeAllAnchorsKernel();
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLComputeAllAnchorsKernel(const CLComputeAllAnchorsKernel &) = delete;
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLComputeAllAnchorsKernel &operator=(const CLComputeAllAnchorsKernel &) = delete;
+ /** Allow instances of this class to be moved */
+ CLComputeAllAnchorsKernel(CLComputeAllAnchorsKernel &&) = default;
+ /** Allow instances of this class to be moved */
+ CLComputeAllAnchorsKernel &operator=(CLComputeAllAnchorsKernel &&) = default;
+ /** Default destructor */
+ ~CLComputeAllAnchorsKernel() = default;
+
+ /** Set the input and output tensors.
+ *
+ * @param[in] anchors Source tensor. Original set of anchors of size (4, A), where A is the number of anchors. Data types supported: F16/F32
+ * @param[out] all_anchors Destination tensor. Destination anchors of size (4, H*W*A) where H and W are the height and width of the feature map and A is the number of anchors. Data types supported: Same as @p input
+ * @param[in] info Contains Compute Anchors operation information described in @ref ComputeAnchorsInfo
+ *
+ */
+ void configure(const ICLTensor *anchors, ICLTensor *all_anchors, const ComputeAnchorsInfo &info);
+
+ /** Static function to check if given info will lead to a valid configuration of @ref CLComputeAllAnchorsKernel
+ *
+ * @param[in] anchors Source tensor info. Original set of anchors of size (4, A), where A is the number of anchors. Data types supported: F16/F32
+ * @param[in] all_anchors Destination tensor info. Destination anchors of size (4, H*W*A) where H and W are the height and width of the feature map and A is the number of anchors. Data types supported: Same as @p input
+ * @param[in] info Contains Compute Anchors operation information described in @ref ComputeAnchorsInfo
+ *
+ * @return a Status
+ */
+ static Status validate(const ITensorInfo *anchors, const ITensorInfo *all_anchors, const ComputeAnchorsInfo &info);
+
+ // Inherited methods overridden:
+ void run(const Window &window, cl::CommandQueue &queue) override;
+
+private:
+ const ICLTensor *_anchors;
+ ICLTensor *_all_anchors;
+};
+} // arm_compute
+#endif // __ARM_COMPUTE_CLGENERATEPROSPOSALSLAYERKERNEL_H__
diff --git a/arm_compute/core/Types.h b/arm_compute/core/Types.h
index 03f195f7da..1c9571463b 100644
--- a/arm_compute/core/Types.h
+++ b/arm_compute/core/Types.h
@@ -595,13 +595,17 @@ public:
* @param[in] soft_nms_method (Optional) Soft NMS method
* @param[in] soft_nms_sigma (Optional) Soft NMS sigma value
* @param[in] soft_nms_min_score_thres (Optional) Soft NMS minimum score threshold
+ * @param[in] suppress_size (Optional) Filter out boxes based on their size. Defaults to false
+ * @param[in] min_size (Optional) Smaller boxes than min_size will be filtered out. Defaults to 1
+ * @param[in] im_width (Optional) Boxes whose centers (on the x axis) is beyond im_width will be filtered. Defaults to 1
+ * @param[in] im_height (Optional) Boxes whose centers (on the y axis) is beyond im_height will be filtered. Defaults to 1
*/
BoxNMSLimitInfo(float score_thresh = 0.05f, float nms = 0.3f,
int detections = 100, bool soft_nms_enabled = false,
NMSType soft_nms_method = NMSType::LINEAR,
- float soft_nms_sigma = 0.5f, float soft_nms_min_score_thres = 0.001f)
+ float soft_nms_sigma = 0.5f, float soft_nms_min_score_thres = 0.001f, bool suppress_size = false, float min_size = 1.0f, float im_width = 1.0f, float im_height = 1.0f)
: _score_thresh(score_thresh), _nms(nms), _detections_per_im(detections), _soft_nms_enabled(soft_nms_enabled), _soft_nms_method(soft_nms_method), _soft_nms_sigma(soft_nms_sigma),
- _soft_nms_min_score_thres(soft_nms_min_score_thres)
+ _soft_nms_min_score_thres(soft_nms_min_score_thres), _suppress_size(suppress_size), _min_size(min_size), _im_width(im_width), _im_height(im_height)
{
}
/** Get the score threshold */
@@ -639,6 +643,26 @@ public:
{
return _soft_nms_min_score_thres;
}
+ /** Get if NMS will suppress boxes based on their size/position */
+ bool suppress_size() const
+ {
+ return _suppress_size;
+ }
+ /** Get size suppression threshold */
+ float min_size() const
+ {
+ return _min_size;
+ }
+ /** Get image width (NMS may suppress boxes whose center sits beyond the image width) */
+ float im_width() const
+ {
+ return _im_width;
+ }
+ /** Get image height (NMS may suppress boxes whose center sits beyond the image height) */
+ float im_height() const
+ {
+ return _im_height;
+ }
private:
float _score_thresh;
@@ -648,6 +672,10 @@ private:
NMSType _soft_nms_method;
float _soft_nms_sigma;
float _soft_nms_min_score_thres;
+ bool _suppress_size;
+ float _min_size;
+ float _im_width;
+ float _im_height;
};
/** Padding and stride information class */
@@ -1049,6 +1077,137 @@ private:
unsigned int _sampling_ratio;
};
+/** Generate Proposals Information class */
+class GenerateProposalsInfo
+{
+public:
+ /** Constructor
+ *
+ * @param[in] im_width Width of the original image
+ * @param[in] im_height Height of the original image
+ * @param[in] im_scale Scale applied to the original image
+ * @param[in] spatial_scale (Optional)Scale applied to the feature map. Defaults to 1.0
+ * @param[in] pre_nms_topN (Optional)Number of the best scores to be selected from the transformations. Defaults to 6000.
+ * @param[in] post_nms_topN (Optional)Number of the best scores to be selected from the NMS operation. Defaults to 300.
+ * @param[in] nms_thres (Optional)NMS overlap threshold. Defaults to 0.7.
+ * @param[in] min_size (Optional)Size used to validate the anchors produced. Defaults to 16.
+ * @param[in] values_per_roi (Optional)Values used to represent a ROI(Region of interest). Defaults to 4.
+ */
+ GenerateProposalsInfo(float im_width, float im_height, float im_scale, float spatial_scale = 1.0, int pre_nms_topN = 6000, int post_nms_topN = 300, float nms_thres = 0.7, float min_size = 16.0,
+ size_t values_per_roi = 4)
+ : _im_height(im_height), _im_width(im_width), _im_scale(im_scale), _spatial_scale(spatial_scale), _pre_nms_topN(pre_nms_topN), _post_nms_topN(post_nms_topN), _nms_thres(nms_thres),
+ _min_size(min_size), _values_per_roi(values_per_roi)
+ {
+ }
+
+ /* Get the original height */
+ float im_height() const
+ {
+ return _im_height;
+ }
+ /* Get the original width */
+ float im_width() const
+ {
+ return _im_width;
+ }
+ /* Get the image scale */
+ float im_scale() const
+ {
+ return _im_scale;
+ }
+ /* Get the value of how many best scores to select (before NMS) */
+ int pre_nms_topN() const
+ {
+ return _pre_nms_topN;
+ }
+ /* Get the value of how many best scores to select (after NMS) */
+ int post_nms_topN() const
+ {
+ return _post_nms_topN;
+ }
+ /* Get the NMS overlap threshold */
+ float nms_thres() const
+ {
+ return _nms_thres;
+ }
+ /* Get the minimal size */
+ float min_size() const
+ {
+ return _min_size;
+ }
+ /* Get the spatial scale to be applied to the feature maps */
+ float spatial_scale() const
+ {
+ return _spatial_scale;
+ }
+ /* Get the values used to represent a ROI(Region of interest)*/
+ size_t values_per_roi() const
+ {
+ return _values_per_roi;
+ }
+
+private:
+ float _im_height;
+ float _im_width;
+ float _im_scale;
+ float _spatial_scale;
+ int _pre_nms_topN;
+ int _post_nms_topN;
+ float _nms_thres;
+ float _min_size;
+ size_t _values_per_roi;
+};
+
+/** ComputeAnchors information class */
+class ComputeAnchorsInfo
+{
+public:
+ /** Constructor
+ *
+ * @param[in] feat_width Feature map width
+ * @param[in] feat_height Feature map height
+ * @param[in] spatial_scale Feature map scale
+ * @param[in] values_per_roi (Optional)Values used to represent a ROI(Region Of Interest). Defaults to 4
+ */
+ ComputeAnchorsInfo(float feat_width, float feat_height, float spatial_scale, size_t values_per_roi = 4)
+ : _feat_height(feat_height),
+ _feat_width(feat_width),
+ _spatial_scale(spatial_scale),
+ _values_per_roi(values_per_roi)
+ {
+ }
+
+ /* Get the height of the feature map */
+ float feat_height() const
+ {
+ return _feat_height;
+ }
+
+ /* Get the width of the feature map */
+ float feat_width() const
+ {
+ return _feat_width;
+ }
+
+ /* Get the scale of the feature map */
+ float spatial_scale() const
+ {
+ return _spatial_scale;
+ }
+
+ /* Get the values used to represent a ROI(Region Of Interest)*/
+ size_t values_per_roi() const
+ {
+ return _values_per_roi;
+ }
+
+private:
+ float _feat_height;
+ float _feat_width;
+ float _spatial_scale;
+ size_t _values_per_roi;
+};
+
/** Bounding Box Transform information class */
class BoundingBoxTransformInfo
{
diff --git a/arm_compute/runtime/CL/CLFunctions.h b/arm_compute/runtime/CL/CLFunctions.h
index 694e818788..9d4aa5b6a2 100644
--- a/arm_compute/runtime/CL/CLFunctions.h
+++ b/arm_compute/runtime/CL/CLFunctions.h
@@ -44,6 +44,7 @@
#include "arm_compute/runtime/CL/functions/CLChannelExtract.h"
#include "arm_compute/runtime/CL/functions/CLChannelShuffleLayer.h"
#include "arm_compute/runtime/CL/functions/CLColorConvert.h"
+#include "arm_compute/runtime/CL/functions/CLComputeAllAnchors.h"
#include "arm_compute/runtime/CL/functions/CLConcatenateLayer.h"
#include "arm_compute/runtime/CL/functions/CLConvertFullyConnectedWeights.h"
#include "arm_compute/runtime/CL/functions/CLConvolution.h"
@@ -76,6 +77,7 @@
#include "arm_compute/runtime/CL/functions/CLGaussian3x3.h"
#include "arm_compute/runtime/CL/functions/CLGaussian5x5.h"
#include "arm_compute/runtime/CL/functions/CLGaussianPyramid.h"
+#include "arm_compute/runtime/CL/functions/CLGenerateProposalsLayer.h"
#include "arm_compute/runtime/CL/functions/CLHOGDescriptor.h"
#include "arm_compute/runtime/CL/functions/CLHOGDetector.h"
#include "arm_compute/runtime/CL/functions/CLHOGGradient.h"
diff --git a/arm_compute/runtime/CL/functions/CLComputeAllAnchors.h b/arm_compute/runtime/CL/functions/CLComputeAllAnchors.h
new file mode 100644
index 0000000000..6c6da791a1
--- /dev/null
+++ b/arm_compute/runtime/CL/functions/CLComputeAllAnchors.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_CLCOMPUTEALLANCHORS_H__
+#define __ARM_COMPUTE_CLCOMPUTEALLANCHORS_H__
+
+#include "arm_compute/core/CL/kernels/CLGenerateProposalsLayerKernel.h"
+#include "arm_compute/runtime/CL/ICLSimpleFunction.h"
+
+namespace arm_compute
+{
+class ICLTensor;
+
+/** Basic function to run @ref CLComputeAllAnchorsKernel.
+ *
+ * This function calls the following OpenCL kernels:
+ * -# @ref CLComputeAllAnchorsKernel
+ */
+class CLComputeAllAnchors : public ICLSimpleFunction
+{
+public:
+ /** Set the input and output tensors.
+ *
+ * @param[in] anchors Source tensor. Original set of anchors of size (4, A) where A is the number of anchors. Data types supported: F16/F32
+ * @param[out] all_anchors Destination tensor. Destination anchors of size (4, H*W*A) where H and W are the height and width of the feature map and A is the number of anchors. Data types supported: Same as @p input
+ * @param[in] info Contains Compute Anchors operation information described in @ref ComputeAnchorsInfo
+ *
+ */
+ void configure(const ICLTensor *anchors, ICLTensor *all_anchors, const ComputeAnchorsInfo &info);
+
+ /** Static function to check if given info will lead to a valid configuration of @ref CLComputeAllAnchorsKernel
+ *
+ * @param[in] anchors Source tensor info. Original set of anchors of size (4, A) where A is the number of anchors. Data types supported: F16/F32
+ * @param[in] all_anchors Destination tensor info. Destination anchors of size (4, H*W*A) where H and W are the height and width of the feature map and A is the number of anchors. Data types supported: Same as @p input
+ * @param[in] info Contains Compute Anchors operation information described in @ref ComputeAnchorsInfo
+ *
+ * @return a Status
+ */
+ static Status validate(const ITensorInfo *anchors, const ITensorInfo *all_anchors, const ComputeAnchorsInfo &info);
+};
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_CLCOMPUTEALLANCOHORS_H__ */
diff --git a/arm_compute/runtime/CL/functions/CLGenerateProposalsLayer.h b/arm_compute/runtime/CL/functions/CLGenerateProposalsLayer.h
new file mode 100644
index 0000000000..343229fe10
--- /dev/null
+++ b/arm_compute/runtime/CL/functions/CLGenerateProposalsLayer.h
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2018 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_CLGENERATEPROPOSALSLAYER_H__
+#define __ARM_COMPUTE_CLGENERATEPROPOSALSLAYER_H__
+#include "arm_compute/core/CL/kernels/CLBoundingBoxTransformKernel.h"
+#include "arm_compute/core/CL/kernels/CLCopyKernel.h"
+#include "arm_compute/core/CL/kernels/CLGenerateProposalsLayerKernel.h"
+#include "arm_compute/core/CL/kernels/CLMemsetKernel.h"
+#include "arm_compute/core/CL/kernels/CLPermuteKernel.h"
+#include "arm_compute/core/CL/kernels/CLReshapeLayerKernel.h"
+#include "arm_compute/core/CL/kernels/CLStridedSliceKernel.h"
+#include "arm_compute/core/CPP/kernels/CPPBoxWithNonMaximaSuppressionLimitKernel.h"
+#include "arm_compute/core/Types.h"
+#include "arm_compute/runtime/CL/CLMemoryGroup.h"
+#include "arm_compute/runtime/CL/CLScheduler.h"
+#include "arm_compute/runtime/CL/CLTensor.h"
+#include "arm_compute/runtime/CPP/CPPScheduler.h"
+#include "arm_compute/runtime/IFunction.h"
+
+namespace arm_compute
+{
+class ICLTensor;
+
+/** Basic function to generate proposals for a RPN (Region Proposal Network)
+ *
+ * This function calls the following OpenCL kernels:
+ * -# @ref CLComputeAllAnchors
+ * -# @ref CLPermute x 2
+ * -# @ref CLReshapeLayer x 2
+ * -# @ref CLStridedSlice x 3
+ * -# @ref CLBoundingBoxTransform
+ * -# @ref CLCopyKernel
+ * -# @ref CLMemsetKernel
+ * And the following CPP kernels:
+ * -# @ref CPPBoxWithNonMaximaSuppressionLimit
+ */
+class CLGenerateProposalsLayer : public IFunction
+{
+public:
+ /** Default constructor
+ *
+ * @param[in] memory_manager (Optional) Memory manager.
+ */
+ CLGenerateProposalsLayer(std::shared_ptr<IMemoryManager> memory_manager = nullptr);
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLGenerateProposalsLayer(const CLGenerateProposalsLayer &) = delete;
+ /** Default move constructor */
+ CLGenerateProposalsLayer(CLGenerateProposalsLayer &&) = default;
+ /** Prevent instances of this class from being copied (As this class contains pointers) */
+ CLGenerateProposalsLayer &operator=(const CLGenerateProposalsLayer &) = delete;
+ /** Default move assignment operator */
+ CLGenerateProposalsLayer &operator=(CLGenerateProposalsLayer &&) = default;
+
+ /** Set the input and output tensors.
+ *
+ * @param[in] scores Scores from convolution layer of size (W, H, A), where H and W are the height and width of the feature map, and A is the number of anchors. Data types supported: F16/F32
+ * @param[in] deltas Bounding box deltas from convolution layer of size (W, H, 4*A). Data types supported: Same as @p scores
+ * @param[in] anchors Anchors tensor of size (4, A). Data types supported: Same as @p input
+ * @param[out] proposals Box proposals output tensor of size (5, W*H*A). Data types supported: Same as @p input
+ * @param[out] scores_out Box scores output tensor of size (W*H*A). Data types supported: Same as @p input
+ * @param[out] num_valid_proposals Scalar output tensor which says which of the first proposals are valid. Data types supported: U32
+ * @param[in] info Contains GenerateProposals operation information described in @ref GenerateProposalsInfo
+ *
+ * @note Only single image prediction is supported. Height and Width (and scale) of the image will be contained in the @ref GenerateProposalsInfo struct.
+ * @note Proposals contains all the proposals. Of those, only the first num_valid_proposals are valid.
+ */
+ void configure(const ICLTensor *scores, const ICLTensor *deltas, const ICLTensor *anchors, ICLTensor *proposals, ICLTensor *scores_out, ICLTensor *num_valid_proposals,
+ const GenerateProposalsInfo &info);
+
+ /** Static function to check if given info will lead to a valid configuration of @ref CLGenerateProposalsLayer
+ *
+ * @param[in] scores Scores info from convolution layer of size (W, H, A), where H and W are the height and width of the feature map, and A is the number of anchors. Data types supported: F16/F32
+ * @param[in] deltas Bounding box deltas info from convolution layer of size (W, H, 4*A). Data types supported: Same as @p scores
+ * @param[in] anchors Anchors tensor info of size (4, A). Data types supported: Same as @p input
+ * @param[in] proposals Box proposals info output tensor of size (5, W*H*A). Data types supported: Data types supported: U32
+ * @param[in] scores_out Box scores output tensor info of size (W*H*A). Data types supported: Same as @p input
+ * @param[in] num_valid_proposals Scalar output tensor info which says which of the first proposals are valid. Data types supported: Same as @p input
+ * @param[in] info Contains GenerateProposals operation information described in @ref GenerateProposalsInfo
+ *
+ * @return a Status
+ */
+ static Status validate(const ITensorInfo *scores, const ITensorInfo *deltas, const ITensorInfo *anchors, const ITensorInfo *proposals, const ITensorInfo *scores_out,
+ const ITensorInfo *num_valid_proposals,
+ const GenerateProposalsInfo &info);
+
+ // Inherited methods overridden:
+ void run() override;
+
+private:
+ // Memory group manager
+ CLMemoryGroup _memory_group;
+
+ // OpenCL kernels
+ CLPermuteKernel _permute_deltas_kernel;
+ CLReshapeLayerKernel _flatten_deltas_kernel;
+ CLPermuteKernel _permute_scores_kernel;
+ CLReshapeLayerKernel _flatten_scores_kernel;
+ CLComputeAllAnchorsKernel _compute_anchors_kernel;
+ CLBoundingBoxTransformKernel _bounding_box_kernel;
+ CLMemsetKernel _memset_kernel;
+ CLCopyKernel _padded_copy_kernel;
+
+ // CPP kernels
+ CPPBoxWithNonMaximaSuppressionLimitKernel _cpp_nms_kernel;
+
+ // Temporary tensors
+ CLTensor _deltas_permuted;
+ CLTensor _deltas_flattened;
+ CLTensor _scores_permuted;
+ CLTensor _scores_flattened;
+ CLTensor _all_anchors;
+ CLTensor _all_proposals;
+ CLTensor _keeps_nms_unused;
+ CLTensor _classes_nms_unused;
+ CLTensor _proposals_4_roi_values;
+
+ // Output tensor pointers
+ ICLTensor *_num_valid_proposals;
+ ICLTensor *_scores_out;
+
+ /** Internal function to run the CPP BoxWithNMS kernel */
+ void run_cpp_nms_kernel();
+};
+} // namespace arm_compute
+#endif /* __ARM_COMPUTE_CLGENERATEPROPOSALSLAYER_H__ */