blob: eee2fa36bc143743253818a2613cbf579d48249e [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2017-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_CLHOGDESCRIPTORKERNEL_H
25#define ARM_COMPUTE_CLHOGDESCRIPTORKERNEL_H
Anthony Barbier6ff3b192017-09-04 18:44:23 +010026
Anthony Barbier6ff3b192017-09-04 18:44:23 +010027#include "arm_compute/core/IHOG.h"
28#include "arm_compute/core/Size2D.h"
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010029#include "src/core/CL/ICLKernel.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010030
31namespace arm_compute
32{
33class ITensor;
34
35/** OpenCL kernel to perform HOG Orientation Binning */
36class CLHOGOrientationBinningKernel : public ICLKernel
37{
38public:
39 /** Default constructor */
40 CLHOGOrientationBinningKernel();
41 /** Prevent instances of this class from being copied (As this class contains pointers) */
42 CLHOGOrientationBinningKernel(const CLHOGOrientationBinningKernel &) = delete;
43 /** Prevent instances of this class from being copied (As this class contains pointers) */
44 CLHOGOrientationBinningKernel &operator=(const CLHOGOrientationBinningKernel &) = delete;
45 /** Allow instances of this class to be moved */
46 CLHOGOrientationBinningKernel(CLHOGOrientationBinningKernel &&) = default;
47 /** Allow instances of this class to be moved */
48 CLHOGOrientationBinningKernel &operator=(CLHOGOrientationBinningKernel &&) = default;
49 /** Default destructor */
50 ~CLHOGOrientationBinningKernel() = default;
51
52 /** Initialise the kernel's inputs, output and HOG's metadata
53 *
54 * @param[in] input_magnitude Input tensor which stores the magnitude of the gradient for each pixel. Data type supported: S16.
55 * @param[in] input_phase Input tensor which stores the phase of the gradient for each pixel. Data type supported: U8
56 * @param[out] output Output tensor which stores the local HOG for each cell. DataType supported: F32. Number of channels supported: equal to the number of histogram bins per cell
57 * @param[in] hog_info HOG's metadata
58 */
59 void configure(const ICLTensor *input_magnitude, const ICLTensor *input_phase, ICLTensor *output, const HOGInfo *hog_info);
Manuel Bottini4c6bd512020-04-08 10:15:51 +010060 /** Initialise the kernel's inputs, output and HOG's metadata
61 *
62 * @param[in] compile_context The compile context to be used.
63 * @param[in] input_magnitude Input tensor which stores the magnitude of the gradient for each pixel. Data type supported: S16.
64 * @param[in] input_phase Input tensor which stores the phase of the gradient for each pixel. Data type supported: U8
65 * @param[out] output Output tensor which stores the local HOG for each cell. DataType supported: F32. Number of channels supported: equal to the number of histogram bins per cell
66 * @param[in] hog_info HOG's metadata
67 */
Manuel Bottini679fc962020-04-21 16:08:53 +010068 void configure(const CLCompileContext &compile_context, const ICLTensor *input_magnitude, const ICLTensor *input_phase, ICLTensor *output, const HOGInfo *hog_info);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010069
70 // Inherited methods overridden:
71 void run(const Window &window, cl::CommandQueue &queue) override;
72
73private:
74 const ICLTensor *_input_magnitude;
75 const ICLTensor *_input_phase;
76 ICLTensor *_output;
77 Size2D _cell_size;
78};
79
80/** OpenCL kernel to perform HOG block normalization */
81class CLHOGBlockNormalizationKernel : public ICLKernel
82{
83public:
84 /** Default constructor */
85 CLHOGBlockNormalizationKernel();
86 /** Prevent instances of this class from being copied (As this class contains pointers) */
87 CLHOGBlockNormalizationKernel(const CLHOGBlockNormalizationKernel &) = delete;
88 /** Prevent instances of this class from being copied (As this class contains pointers) */
89 CLHOGBlockNormalizationKernel &operator=(const CLHOGBlockNormalizationKernel &) = delete;
90 /** Allow instances of this class to be moved */
91 CLHOGBlockNormalizationKernel(CLHOGBlockNormalizationKernel &&) = default;
92 /** Allow instances of this class to be moved */
93 CLHOGBlockNormalizationKernel &operator=(CLHOGBlockNormalizationKernel &&) = default;
94 /** Default destructor */
95 ~CLHOGBlockNormalizationKernel() = default;
96
97 /** Initialise the kernel's input, output and HOG's metadata
98 *
99 * @param[in] input Input tensor which stores the local HOG for each cell. Data type supported: F32. Number of channels supported: equal to the number of histogram bins per cell
100 * @param[out] output Output tensor which stores the normalised blocks. Data type supported: F32. Number of channels supported: equal to the number of histogram bins per block
101 * @param[in] hog_info HOG's metadata
102 */
103 void configure(const ICLTensor *input, ICLTensor *output, const HOGInfo *hog_info);
Manuel Bottini4c6bd512020-04-08 10:15:51 +0100104 /** Initialise the kernel's input, output and HOG's metadata
105 *
106 * @param[in] compile_context The compile context to be used.
107 * @param[in] input Input tensor which stores the local HOG for each cell. Data type supported: F32. Number of channels supported: equal to the number of histogram bins per cell
108 * @param[out] output Output tensor which stores the normalised blocks. Data type supported: F32. Number of channels supported: equal to the number of histogram bins per block
109 * @param[in] hog_info HOG's metadata
110 */
Manuel Bottini679fc962020-04-21 16:08:53 +0100111 void configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const HOGInfo *hog_info);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100112
113 // Inherited methods overridden:
114 void run(const Window &window, cl::CommandQueue &queue) override;
115
116private:
117 const ICLTensor *_input;
118 ICLTensor *_output;
119 Size2D _num_cells_per_block_stride;
120};
Gian Marco Iodicef670a0a2017-09-18 12:20:45 +0100121} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000122#endif /* ARM_COMPUTE_CLHOGDESCRIPTORKERNEL_H */