blob: f5a1272b53e908bb28e07cfda73e345cc1a0334f [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Michalis Spyrouebcebf12020-10-21 00:04:14 +01002 * Copyright (c) 2016-2020 Arm Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +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_NEGAUSSIANPYRAMID_H
25#define ARM_COMPUTE_NEGAUSSIANPYRAMID_H
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
27#include "arm_compute/core/IPyramid.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028#include "arm_compute/core/Types.h"
29#include "arm_compute/runtime/IFunction.h"
30#include "arm_compute/runtime/NEON/functions/NEGaussian5x5.h"
Georgios Pinitas3021edf2017-09-18 17:55:22 +010031#include "arm_compute/runtime/NEON/functions/NEScale.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010032#include "arm_compute/runtime/Pyramid.h"
33#include "arm_compute/runtime/Tensor.h"
34
35#include <cstdint>
36#include <memory>
37
38namespace arm_compute
39{
40class ITensor;
Michalis Spyrouebcebf12020-10-21 00:04:14 +010041class NEGaussianPyramidHorKernel;
42class NEGaussianPyramidVertKernel;
43class NEFillBorderKernel;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010044
morgolock0c862652020-11-06 08:59:45 +000045/** Common interface for all Gaussian pyramid functions
46 *
47 * @deprecated This function is deprecated and is intended to be removed in 21.05 release
48 *
49 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010050class NEGaussianPyramid : public IFunction
51{
52public:
53 /** Default constructor */
54 NEGaussianPyramid();
55 /** Prevent instances of this class from being copied (As this class contains pointers) */
56 NEGaussianPyramid(const NEGaussianPyramid &) = delete;
57 /** Prevent instances of this class from being copied (As this class contains pointers) */
58 NEGaussianPyramid &operator=(const NEGaussianPyramid &) = delete;
59 /** Allow instances of this class to be moved */
60 NEGaussianPyramid(NEGaussianPyramid &&) = default;
61 /** Allow instances of this class to be moved */
62 NEGaussianPyramid &operator=(NEGaussianPyramid &&) = default;
63 /** Default destructor */
64 virtual ~NEGaussianPyramid() = default;
65
66 /** Initialise the function's source, destinations and border mode.
67 *
68 * @param[in] input Source tensor. Data type supported: U8.
69 * @param[out] pyramid Destination pyramid tensors, Data type supported at each level: U8.
70 * @param[in] border_mode Border mode to use.
71 * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT.
72 *
73 */
74 virtual void configure(const ITensor *input, IPyramid *pyramid, BorderMode border_mode, uint8_t constant_border_value) = 0;
75
76protected:
77 const ITensor *_input;
78 IPyramid *_pyramid;
79 Pyramid _tmp;
80};
81
82/** Basic function to execute gaussian pyramid with HALF scale factor. This function calls the following NEON kernels:
83 *
84 * -# @ref NEFillBorderKernel (executed if border_mode == CONSTANT or border_mode == REPLICATE)
85 * -# @ref NEGaussianPyramidHorKernel
86 * -# @ref NEGaussianPyramidVertKernel
87 *
morgolock0c862652020-11-06 08:59:45 +000088 * @deprecated This function is deprecated and is intended to be removed in 21.05 release
89 *
90 *
Anthony Barbier6ff3b192017-09-04 18:44:23 +010091 */
92class NEGaussianPyramidHalf : public NEGaussianPyramid
93{
94public:
95 /** Constructor */
96 NEGaussianPyramidHalf();
Michalis Spyrouebcebf12020-10-21 00:04:14 +010097 /** Prevent instances of this class from being copied (As this class contains pointers) */
98 NEGaussianPyramidHalf(const NEGaussianPyramidHalf &) = delete;
99 /** Prevent instances of this class from being copied (As this class contains pointers) */
100 NEGaussianPyramidHalf &operator=(const NEGaussianPyramidHalf &) = delete;
101 /** Allow instances of this class to be moved */
102 NEGaussianPyramidHalf(NEGaussianPyramidHalf &&) = default;
103 /** Allow instances of this class to be moved */
104 NEGaussianPyramidHalf &operator=(NEGaussianPyramidHalf &&) = default;
105 /** Default destructor */
106 ~NEGaussianPyramidHalf();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100107
108 // Inherited methods overridden:
109 void configure(const ITensor *input, IPyramid *pyramid, BorderMode border_mode, uint8_t constant_border_value) override;
110 void run() override;
111
112private:
Michalis Spyrouebcebf12020-10-21 00:04:14 +0100113 std::vector<std::unique_ptr<NEFillBorderKernel>> _horizontal_border_handler;
114 std::vector<std::unique_ptr<NEFillBorderKernel>> _vertical_border_handler;
115 std::vector<std::unique_ptr<NEGaussianPyramidHorKernel>> _horizontal_reduction;
116 std::vector<std::unique_ptr<NEGaussianPyramidVertKernel>> _vertical_reduction;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100117};
118
119/** Basic function to execute gaussian pyramid with ORB scale factor. This function calls the following NEON kernels and functions:
120 *
121 * -# @ref NEFillBorderKernel (executed if border_mode == CONSTANT or border_mode == REPLICATE)
122 * -# @ref NEGaussian5x5
123 * -# @ref NEScaleKernel
124 *
morgolock0c862652020-11-06 08:59:45 +0000125 * @deprecated This function is deprecated and is intended to be removed in 21.05 release
126 *
127 *
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100128 */
129class NEGaussianPyramidOrb : public NEGaussianPyramid
130{
131public:
132 /** Constructor */
133 NEGaussianPyramidOrb();
Michalis Spyrouebcebf12020-10-21 00:04:14 +0100134 /** Prevent instances of this class from being copied (As this class contains pointers) */
135 NEGaussianPyramidOrb(const NEGaussianPyramidOrb &) = delete;
136 /** Prevent instances of this class from being copied (As this class contains pointers) */
137 NEGaussianPyramidOrb &operator=(const NEGaussianPyramidOrb &) = delete;
138 /** Allow instances of this class to be moved */
139 NEGaussianPyramidOrb(NEGaussianPyramidOrb &&) = default;
140 /** Allow instances of this class to be moved */
141 NEGaussianPyramidOrb &operator=(NEGaussianPyramidOrb &&) = default;
142 /** Default destructor */
143 ~NEGaussianPyramidOrb();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100144
145 // Inherited methods overridden:
146 void configure(const ITensor *input, IPyramid *pyramid, BorderMode border_mode, uint8_t constant_border_value) override;
147 void run() override;
148
149private:
Georgios Pinitas725b1732019-05-20 19:40:47 +0100150 std::vector<NEGaussian5x5> _gaus5x5;
151 std::vector<NEScale> _scale_nearest;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100152};
Georgios Pinitas725b1732019-05-20 19:40:47 +0100153} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000154#endif /*ARM_COMPUTE_NEGAUSSIANPYRAMID_H */