Compute Library
 21.11
CPPNonMaximumSuppressionKernel.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #ifndef ARM_COMPUTE_CPP_NONMAXIMUMSUPPRESSIONKERNEL_LAYER_H
25 #define ARM_COMPUTE_CPP_NONMAXIMUMSUPPRESSIONKERNEL_LAYER_H
26 
28 
29 #include "arm_compute/core/Types.h"
30 
31 namespace arm_compute
32 {
33 class ITensor;
34 
35 /** CPP Function to perform non maximum suppression on the bounding boxes and scores
36  *
37  */
39 {
40 public:
41  const char *name() const override
42  {
43  return "CPPNonMaximumSuppressionKernel";
44  }
45  /** Default constructor */
47  /** Prevent instances of this class from being copied (As this class contains pointers) */
49  /** Prevent instances of this class from being copied (As this class contains pointers) */
51  /** Allow instances of this class to be moved */
53  /** Allow instances of this class to be moved */
55  /** Default destructor */
57 
58  /** Configure the kernel to perform non maximal suppression
59  *
60  * @param[in] input_bboxes The input bounding boxes. Data types supported: F32.
61  * @param[in] input_scores The corresponding input confidence. Same as @p input_bboxes.
62  * @param[out] output_indices The kept indices of bboxes after nms. Data types supported: S32.
63  * @param[in] max_output_size An integer tensor representing the maximum number of boxes to be selected by non max suppression.
64  * @param[in] score_threshold The threshold used to filter detection results.
65  * @param[in] iou_threshold The threshold used in non maximum suppression.
66  *
67  */
68  void configure(const ITensor *input_bboxes, const ITensor *input_scores, ITensor *output_indices, unsigned int max_output_size, const float score_threshold, const float iou_threshold);
69 
70  /** Static function to check if given arguments will lead to a valid configuration of @ref CPPNonMaximumSuppressionKernel
71  *
72  * @param[in] input_bboxes The input bounding boxes tensor info. Data types supported: F32.
73  * @param[in] input_scores The corresponding input confidence tensor info. Same as @p input_bboxes.
74  * @param[out] output_indices The kept indices of bboxes after nms tensor info. Data types supported: S32.
75  * @param[in] max_output_size An integer tensor representing the maximum number of boxes to be selected by non max suppression.
76  * @param[in] score_threshold The threshold used to filter detection results.
77  * @param[in] iou_threshold The threshold used in non maximum suppression.
78  *
79  */
80  static Status validate(const ITensorInfo *input_bboxes, const ITensorInfo *input_scores, const ITensorInfo *output_indices, unsigned int max_output_size,
81  const float score_threshold, const float iou_threshold);
82 
83  // Inherited methods overridden:
84  void run(const Window &window, const ThreadInfo &info) override;
85 
86 private:
87  const ITensor *_input_bboxes;
88  const ITensor *_input_scores;
89  ITensor *_output_indices;
90  unsigned int _max_output_size;
91  float _score_threshold;
92  float _iou_threshold;
93 
94  unsigned int _num_boxes;
95 };
96 } // namespace arm_compute
97 #endif /* ARM_COMPUTE_CPP_NONMAXIMUMSUPPRESSIONKERNEL_LAYER_H */
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
Common interface for all kernels implemented in C++.
Definition: ICPPKernel.h:38
static Status validate(const ITensorInfo *input_bboxes, const ITensorInfo *input_scores, const ITensorInfo *output_indices, unsigned int max_output_size, const float score_threshold, const float iou_threshold)
Static function to check if given arguments will lead to a valid configuration of CPPNonMaximumSuppre...
CPPNonMaximumSuppressionKernel & operator=(const CPPNonMaximumSuppressionKernel &)=delete
Prevent instances of this class from being copied (As this class contains pointers) ...
Store the tensor's metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
Interface for CPU tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2021 Arm Limited.
~CPPNonMaximumSuppressionKernel()=default
Default destructor.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Information about executing thread and CPU.
Definition: CPPTypes.h:158
void configure(const ITensor *input_bboxes, const ITensor *input_scores, ITensor *output_indices, unsigned int max_output_size, const float score_threshold, const float iou_threshold)
Configure the kernel to perform non maximal suppression.
CPP Function to perform non maximum suppression on the bounding boxes and scores. ...
const char * name() const override
Name of the kernel.
Describe a multidimensional execution window.
Definition: Window.h:39