blob: f47b487c91e26d4086a84c56226f6371849c0e46 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
2 * Copyright (c) 2016, 2017 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_NENONMAXIMASUPPRESSION3x3KERNEL_H__
25#define __ARM_COMPUTE_NENONMAXIMASUPPRESSION3x3KERNEL_H__
26
27#include "arm_compute/core/NEON/INEKernel.h"
28
29#include <cstdint>
30
31namespace arm_compute
32{
33class ITensor;
34
35/** Interface to perform Non-Maxima suppression over a 3x3 window using NEON
36 *
37 * @note Used by @ref NEFastCorners and @ref NEHarrisCorners
38 */
39class NENonMaximaSuppression3x3Kernel : public INEKernel
40{
41public:
42 /** Default constructor */
43 NENonMaximaSuppression3x3Kernel();
44 /** Prevent instances of this class from being copied (As this class contains pointers) */
45 NENonMaximaSuppression3x3Kernel(const NENonMaximaSuppression3x3Kernel &) = delete;
46 /** Prevent instances of this class from being copied (As this class contains pointers) */
47 NENonMaximaSuppression3x3Kernel &operator=(const NENonMaximaSuppression3x3Kernel &) = delete;
48 /** Allow instances of this class to be moved */
49 NENonMaximaSuppression3x3Kernel(NENonMaximaSuppression3x3Kernel &&) = default;
50 /** Allow instances of this class to be moved */
51 NENonMaximaSuppression3x3Kernel &operator=(NENonMaximaSuppression3x3Kernel &&) = default;
52 /** Default destructor */
53 ~NENonMaximaSuppression3x3Kernel() = default;
54
55 /** Initialise the kernel's sources, destinations and border mode.
56 *
57 * @param[in] input Source tensor. Data types supported: U8/F32
58 * @param[out] output Destination tensor. Data types supported: same as @p input
59 * @param[in] border_undefined True if the border mode is undefined. False if it's replicate or constant.
60 */
61 void configure(const ITensor *input, ITensor *output, bool border_undefined);
62
63 // Inherited methods overridden:
Moritz Pflanzerc186b572017-09-07 09:48:04 +010064 void run(const Window &window, const ThreadInfo &info) override;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010065 BorderSize border_size() const override;
66
67protected:
68 /** Common signature for all the specialised non-maxima suppression 3x3 functions
69 *
70 * @param[in] input_ptr Pointer to the input tensor.
71 * @param[out] output_ptr Pointer to the output tensor
72 * @param[in] input_stride Stride of the input tensor
73 */
74 using NonMaxSuppr3x3Function = void(const void *__restrict input_ptr, void *__restrict output_ptr, const uint32_t input_stride);
75
76 NonMaxSuppr3x3Function *_func; /**< Non-Maxima suppression function to use for the particular tensor types passed to configure() */
77 const ITensor *_input; /**< Source tensor */
78 ITensor *_output; /**< Destination tensor */
79};
80
Ioan-Cristian Szabo33fd07b2017-10-26 15:42:24 +010081#ifdef ARM_COMPUTE_AARCH64_V8_2
Anthony Barbier6ff3b192017-09-04 18:44:23 +010082/** NEON kernel to perform Non-Maxima suppression 3x3 with intermediate results in F16 if the input data type is F32
83 */
84class NENonMaximaSuppression3x3FP16Kernel : public NENonMaximaSuppression3x3Kernel
85{
86public:
87 /** Initialise the kernel's sources, destinations and border mode.
88 *
89 * @param[in] input Source tensor. Data types supported: U8/F32.
90 * @param[out] output Destination tensor. Data types supported: same as @p input
91 * @param[in] border_undefined True if the border mode is undefined. False if it's replicate or constant.
92 */
93 void configure(const ITensor *input, ITensor *output, bool border_undefined);
94};
Ioan-Cristian Szabo33fd07b2017-10-26 15:42:24 +010095#else /* ARM_COMPUTE_AARCH64_V8_2 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010096using NENonMaximaSuppression3x3FP16Kernel = NENonMaximaSuppression3x3Kernel;
Ioan-Cristian Szabo33fd07b2017-10-26 15:42:24 +010097#endif /* ARM_COMPUTE_AARCH64_V8_2 */
Gian Marco Iodice356f6432017-09-22 11:32:21 +010098} // namespace arm_compute
Anthony Barbier6ff3b192017-09-04 18:44:23 +010099#endif /* _ARM_COMPUTE_NENONMAXIMASUPPRESSION3x3KERNEL_H__ */