• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2016-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_NEGAUSSIANPYRAMID_H
25 #define ARM_COMPUTE_NEGAUSSIANPYRAMID_H
26 
27 #include "arm_compute/core/IPyramid.h"
28 #include "arm_compute/core/Types.h"
29 #include "arm_compute/runtime/IFunction.h"
30 #include "arm_compute/runtime/NEON/functions/NEGaussian5x5.h"
31 #include "arm_compute/runtime/NEON/functions/NEScale.h"
32 #include "arm_compute/runtime/Pyramid.h"
33 #include "arm_compute/runtime/Tensor.h"
34 
35 #include <cstdint>
36 #include <memory>
37 
38 namespace arm_compute
39 {
40 class ITensor;
41 class NEGaussianPyramidHorKernel;
42 class NEGaussianPyramidVertKernel;
43 class NEFillBorderKernel;
44 
45 /** 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  */
50 class NEGaussianPyramid : public IFunction
51 {
52 public:
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 
76 protected:
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  *
88  * @deprecated This function is deprecated and is intended to be removed in 21.05 release
89  *
90  *
91  */
92 class NEGaussianPyramidHalf : public NEGaussianPyramid
93 {
94 public:
95     /** Constructor */
96     NEGaussianPyramidHalf();
97     /** 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();
107 
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 
112 private:
113     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;
117 };
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  *
125  * @deprecated This function is deprecated and is intended to be removed in 21.05 release
126  *
127  *
128  */
129 class NEGaussianPyramidOrb : public NEGaussianPyramid
130 {
131 public:
132     /** Constructor */
133     NEGaussianPyramidOrb();
134     /** 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();
144 
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 
149 private:
150     std::vector<NEGaussian5x5> _gaus5x5;
151     std::vector<NEScale>       _scale_nearest;
152 };
153 } // namespace arm_compute
154 #endif /*ARM_COMPUTE_NEGAUSSIANPYRAMID_H */
155