blob: dd91595ea67a8f65401ebaf0523e88570df504cf [file] [log] [blame]
Michalis Spyrou2709d612018-09-19 09:46:47 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2018-2020 Arm Limited.
Michalis Spyrou2709d612018-09-19 09:46:47 +01003 *
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 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_CPPBOXWITHNONMAXIMASUPPRESSIONLIMITKERNEL_H
25#define ARM_COMPUTE_CPPBOXWITHNONMAXIMASUPPRESSIONLIMITKERNEL_H
Michalis Spyrou2709d612018-09-19 09:46:47 +010026
Michalis Spyrouebcebf12020-10-21 00:04:14 +010027#include "arm_compute/core/CPP/ICPPKernel.h"
Michalis Spyrou2709d612018-09-19 09:46:47 +010028#include "arm_compute/core/Types.h"
29
30namespace arm_compute
31{
32class ITensor;
33
34/** CPP kernel to perform computation of BoxWithNonMaximaSuppressionLimit */
35class CPPBoxWithNonMaximaSuppressionLimitKernel : public ICPPKernel
36{
37public:
38 const char *name() const override
39 {
40 return "CPPBoxWithNonMaximaSuppressionLimitKernel";
41 }
42 /** Default constructor */
43 CPPBoxWithNonMaximaSuppressionLimitKernel();
44 /** Prevent instances of this class from being copied (As this class contains pointers) */
45 CPPBoxWithNonMaximaSuppressionLimitKernel(const CPPBoxWithNonMaximaSuppressionLimitKernel &) = delete;
46 /** Prevent instances of this class from being copied (As this class contains pointers) */
47 CPPBoxWithNonMaximaSuppressionLimitKernel &operator=(const CPPBoxWithNonMaximaSuppressionLimitKernel &) = delete;
48 /** Allow instances of this class to be moved */
49 CPPBoxWithNonMaximaSuppressionLimitKernel(CPPBoxWithNonMaximaSuppressionLimitKernel &&) = default;
50 /** Allow instances of this class to be moved */
51 CPPBoxWithNonMaximaSuppressionLimitKernel &operator=(CPPBoxWithNonMaximaSuppressionLimitKernel &&) = default;
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
Michele Di Giorgiof22f6722020-07-03 16:29:24 +010063 * @param[out] keeps_size (Optional) Number of filtered indices per class tensor of size [num_classes]. Data types supported: U32
Michalis Spyrou2709d612018-09-19 09:46:47 +010064 * @param[in] info (Optional) BoxNMSLimitInfo information.
65 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010066 void configure(const ITensor *scores_in,
67 const ITensor *boxes_in,
68 const ITensor *batch_splits_in,
69 ITensor *scores_out,
70 ITensor *boxes_out,
71 ITensor *classes,
72 ITensor *batch_splits_out = nullptr,
73 ITensor *keeps = nullptr,
74 ITensor *keeps_size = nullptr,
75 const BoxNMSLimitInfo info = BoxNMSLimitInfo());
Michalis Spyrou2709d612018-09-19 09:46:47 +010076
77 // Inherited methods overridden:
78 void run(const Window &window, const ThreadInfo &info) override;
79 bool is_parallelisable() const override;
80
81 template <typename T>
82 void run_nmslimit();
83
84private:
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010085 const ITensor *_scores_in;
86 const ITensor *_boxes_in;
87 const ITensor *_batch_splits_in;
Michalis Spyrou2709d612018-09-19 09:46:47 +010088 ITensor *_scores_out;
89 ITensor *_boxes_out;
90 ITensor *_classes;
91 ITensor *_batch_splits_out;
92 ITensor *_keeps;
93 ITensor *_keeps_size;
94 BoxNMSLimitInfo _info;
95};
96} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +000097#endif /* ARM_COMPUTE_CPPBOXWITHNONMAXIMASUPPRESSIONLIMITKERNEL_H */