Michalis Spyrou | 2709d61 | 2018-09-19 09:46:47 +0100 | [diff] [blame] | 1 | /* |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2019 ARM Limited. |
Michalis Spyrou | 2709d61 | 2018-09-19 09:46:47 +0100 | [diff] [blame] | 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 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_CPPBOXWITHNONMAXIMASUPPRESSIONLIMITKERNEL_H |
| 25 | #define ARM_COMPUTE_CPPBOXWITHNONMAXIMASUPPRESSIONLIMITKERNEL_H |
Michalis Spyrou | 2709d61 | 2018-09-19 09:46:47 +0100 | [diff] [blame] | 26 | |
| 27 | #include "arm_compute/core/IArray.h" |
| 28 | #include "arm_compute/core/IHOG.h" |
| 29 | #include "arm_compute/core/NEON/INEKernel.h" |
| 30 | #include "arm_compute/core/Types.h" |
| 31 | |
| 32 | namespace arm_compute |
| 33 | { |
| 34 | class ITensor; |
| 35 | |
| 36 | /** CPP kernel to perform computation of BoxWithNonMaximaSuppressionLimit */ |
| 37 | class CPPBoxWithNonMaximaSuppressionLimitKernel : public ICPPKernel |
| 38 | { |
| 39 | public: |
| 40 | const char *name() const override |
| 41 | { |
| 42 | return "CPPBoxWithNonMaximaSuppressionLimitKernel"; |
| 43 | } |
| 44 | /** Default constructor */ |
| 45 | CPPBoxWithNonMaximaSuppressionLimitKernel(); |
| 46 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 47 | CPPBoxWithNonMaximaSuppressionLimitKernel(const CPPBoxWithNonMaximaSuppressionLimitKernel &) = delete; |
| 48 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 49 | CPPBoxWithNonMaximaSuppressionLimitKernel &operator=(const CPPBoxWithNonMaximaSuppressionLimitKernel &) = delete; |
| 50 | /** Allow instances of this class to be moved */ |
| 51 | CPPBoxWithNonMaximaSuppressionLimitKernel(CPPBoxWithNonMaximaSuppressionLimitKernel &&) = default; |
| 52 | /** Allow instances of this class to be moved */ |
| 53 | CPPBoxWithNonMaximaSuppressionLimitKernel &operator=(CPPBoxWithNonMaximaSuppressionLimitKernel &&) = default; |
| 54 | /** Initialise the kernel's input and output tensors. |
| 55 | * |
| 56 | * @param[in] scores_in The scores input tensor of size [num_classes, count]. Data types supported: F16/F32 |
| 57 | * @param[in] boxes_in The boxes input tensor of size [num_classes * 4, count]. Data types supported: Same as @p scores_in |
| 58 | * @param[in] batch_splits_in The batch splits input tensor of size [batch_size]. Data types supported: Same as @p scores_in |
| 59 | * @note Can be a nullptr. If not a nullptr, @p scores_in and @p boxes_in have items from multiple images. |
| 60 | * @param[out] scores_out The scores output tensor of size [N]. Data types supported: Same as @p scores_in |
| 61 | * @param[out] boxes_out The boxes output tensor of size [4, N]. Data types supported: Same as @p scores_in |
| 62 | * @param[out] classes The classes output tensor of size [N]. Data types supported: Same as @p scores_in |
| 63 | * @param[out] batch_splits_out (Optional) The batch splits output tensor [batch_size]. Data types supported: Same as @p scores_in |
| 64 | * @param[out] keeps (Optional) The keeps output tensor of size [N]. Data types supported: Same as@p scores_in |
| 65 | * @param[out] keeps_size (Optional) Number of filtered indices per class tensor of size [num_classes]. Data types supported: Same as @p scores_in |
| 66 | * @param[in] info (Optional) BoxNMSLimitInfo information. |
| 67 | */ |
| 68 | void configure(const ITensor *scores_in, const ITensor *boxes_in, const ITensor *batch_splits_in, ITensor *scores_out, ITensor *boxes_out, ITensor *classes, |
| 69 | ITensor *batch_splits_out = nullptr, ITensor *keeps = nullptr, ITensor *keeps_size = nullptr, const BoxNMSLimitInfo info = BoxNMSLimitInfo()); |
| 70 | |
| 71 | // Inherited methods overridden: |
| 72 | void run(const Window &window, const ThreadInfo &info) override; |
| 73 | bool is_parallelisable() const override; |
| 74 | |
| 75 | template <typename T> |
| 76 | void run_nmslimit(); |
| 77 | |
| 78 | private: |
| 79 | const ITensor *_scores_in; |
| 80 | const ITensor *_boxes_in; |
| 81 | const ITensor *_batch_splits_in; |
| 82 | ITensor *_scores_out; |
| 83 | ITensor *_boxes_out; |
| 84 | ITensor *_classes; |
| 85 | ITensor *_batch_splits_out; |
| 86 | ITensor *_keeps; |
| 87 | ITensor *_keeps_size; |
| 88 | BoxNMSLimitInfo _info; |
| 89 | }; |
| 90 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 91 | #endif /* ARM_COMPUTE_CPPBOXWITHNONMAXIMASUPPRESSIONLIMITKERNEL_H */ |