Compute Library
 21.05
CPPBoxWithNonMaximaSuppressionLimitKernel.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020 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_CPPBOXWITHNONMAXIMASUPPRESSIONLIMITKERNEL_H
25 #define ARM_COMPUTE_CPPBOXWITHNONMAXIMASUPPRESSIONLIMITKERNEL_H
26 
28 #include "arm_compute/core/Types.h"
29 
30 namespace arm_compute
31 {
32 class ITensor;
33 
34 /** CPP kernel to perform computation of BoxWithNonMaximaSuppressionLimit */
36 {
37 public:
38  const char *name() const override
39  {
40  return "CPPBoxWithNonMaximaSuppressionLimitKernel";
41  }
42  /** Default constructor */
44  /** Prevent instances of this class from being copied (As this class contains pointers) */
46  /** Prevent instances of this class from being copied (As this class contains pointers) */
48  /** Allow instances of this class to be moved */
50  /** Allow instances of this class to be moved */
52  /** Initialise the kernel's input and output tensors.
53  *
54  * @param[in] scores_in The scores input tensor of size [num_classes, count]. Data types supported: F16/F32
55  * @param[in] boxes_in The boxes input tensor of size [num_classes * 4, count]. Data types supported: Same as @p scores_in
56  * @param[in] batch_splits_in The batch splits input tensor of size [batch_size]. Data types supported: Same as @p scores_in
57  * @note Can be a nullptr. If not a nullptr, @p scores_in and @p boxes_in have items from multiple images.
58  * @param[out] scores_out The scores output tensor of size [N]. Data types supported: Same as @p scores_in
59  * @param[out] boxes_out The boxes output tensor of size [4, N]. Data types supported: Same as @p scores_in
60  * @param[out] classes The classes output tensor of size [N]. Data types supported: Same as @p scores_in
61  * @param[out] batch_splits_out (Optional) The batch splits output tensor [batch_size]. Data types supported: Same as @p scores_in
62  * @param[out] keeps (Optional) The keeps output tensor of size [N]. Data types supported: Same as@p scores_in
63  * @param[out] keeps_size (Optional) Number of filtered indices per class tensor of size [num_classes]. Data types supported: U32
64  * @param[in] info (Optional) BoxNMSLimitInfo information.
65  */
66  void configure(const ITensor *scores_in, const ITensor *boxes_in, const ITensor *batch_splits_in, ITensor *scores_out, ITensor *boxes_out, ITensor *classes,
67  ITensor *batch_splits_out = nullptr, ITensor *keeps = nullptr, ITensor *keeps_size = nullptr, const BoxNMSLimitInfo info = BoxNMSLimitInfo());
68 
69  // Inherited methods overridden:
70  void run(const Window &window, const ThreadInfo &info) override;
71  bool is_parallelisable() const override;
72 
73  template <typename T>
74  void run_nmslimit();
75 
76 private:
77  const ITensor *_scores_in;
78  const ITensor *_boxes_in;
79  const ITensor *_batch_splits_in;
80  ITensor *_scores_out;
81  ITensor *_boxes_out;
82  ITensor *_classes;
83  ITensor *_batch_splits_out;
84  ITensor *_keeps;
85  ITensor *_keeps_size;
86  BoxNMSLimitInfo _info;
87 };
88 } // namespace arm_compute
89 #endif /* ARM_COMPUTE_CPPBOXWITHNONMAXIMASUPPRESSIONLIMITKERNEL_H */
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
void configure(const ITensor *scores_in, const ITensor *boxes_in, const ITensor *batch_splits_in, ITensor *scores_out, ITensor *boxes_out, ITensor *classes, ITensor *batch_splits_out=nullptr, ITensor *keeps=nullptr, ITensor *keeps_size=nullptr, const BoxNMSLimitInfo info=BoxNMSLimitInfo())
Initialise the kernel's input and output tensors.
CPP kernel to perform computation of BoxWithNonMaximaSuppressionLimit.
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
BoxWithNonMaximaSuppressionLimit Information class.
Definition: Types.h:554
bool is_parallelisable() const override
Indicates whether or not the kernel is parallelisable.
Interface for CPU tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2021 Arm Limited.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Information about executing thread and CPU.
Definition: CPPTypes.h:252
CPPBoxWithNonMaximaSuppressionLimitKernel & operator=(const CPPBoxWithNonMaximaSuppressionLimitKernel &)=delete
Prevent instances of this class from being copied (As this class contains pointers)
Describe a multidimensional execution window.
Definition: Window.h:39