Compute Library
 20.02.1
CLMinMaxLocationKernel.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2019 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_CLMINMAXLOCATIONKERNEL_H
25 #define ARM_COMPUTE_CLMINMAXLOCATIONKERNEL_H
26 
29 
30 #include <array>
31 
32 namespace arm_compute
33 {
34 class ICLTensor;
35 using ICLImage = ICLTensor;
36 
37 /** Interface for the kernel to perform min max search on an image.
38  */
39 class CLMinMaxKernel : public ICLKernel
40 {
41 public:
42  /** Default constructor */
44  /** Prevent instances of this class from being copied (As this class contains pointers) */
45  CLMinMaxKernel(const CLMinMaxKernel &) = delete;
46  /** Prevent instances of this class from being copied (As this class contains pointers) */
47  CLMinMaxKernel &operator=(const CLMinMaxKernel &) = delete;
48  /** Allow instances of this class to be moved */
49  CLMinMaxKernel(CLMinMaxKernel &&) = default;
50  /** Allow instances of this class to be moved */
52  /** Initialise the kernel's input and output.
53  *
54  * @param[in] input Input Image. Data types supported: U8/S16/F32.
55  * @param[out] min_max Buffer of 2 elements to store the min value at position 0 and the max value at position 1. Data type supported: S32 if input type is U8/S16, F32 if input type is F32.
56  */
57  void configure(const ICLImage *input, cl::Buffer *min_max);
58 
59  // Inherited methods overridden:
60  void run(const Window &window, cl::CommandQueue &queue) override;
61 
62 private:
63  const ICLTensor *_input; /**< Input image. */
64  cl::Buffer *_min_max; /**< Minimum/maximum value. */
65  std::array<int, 2> _data_type_max_min; /**< Maximum and minimum data type value respectively. */
66 };
67 
68 /** Interface for the kernel to find min max locations of an image.
69  */
71 {
72 public:
73  /** Constructor */
75  /** Prevent instances of this class from being copied (As this class contains pointers) */
77  /** Prevent instances of this class from being copied (As this class contains pointers) */
79  /** Allow instances of this class to be moved */
81  /** Allow instances of this class to be moved */
83  /** Initialise the kernel's input and outputs.
84  *
85  * @note When locations of min and max occurrences are requested, the reported number of locations is limited to the given array size.
86  *
87  * @param[in] input Input image. Data types supported: U8/S16/F32.
88  * @param[out] min_max Buffer of 2 elements to store the min value at position 0 and the max value at position 1. Data type supported: S32 if input type is U8/S16, F32 if input type is F32.
89  * @param[out] min_max_count Buffer of 2 elements to store the min value occurrences at position 0 and the max value occurrences at position 1. Data type supported: S32
90  * @param[out] min_loc (Optional) Array of Coordinates2D used to store minimum value locations.
91  * @param[out] max_loc (Optional) Array of Coordinates2D used to store maximum value locations.
92  */
93  void configure(const ICLImage *input, cl::Buffer *min_max, cl::Buffer *min_max_count,
94  ICLCoordinates2DArray *min_loc = nullptr, ICLCoordinates2DArray *max_loc = nullptr);
95 
96  // Inherited methods overridden:
97  void run(const Window &window, cl::CommandQueue &queue) override;
98 
99 private:
100  const ICLImage *_input; /**< Input image. */
101  cl::Buffer *_min_max_count; /**< Minimum/maximum value occurrences. */
102 };
103 } // namespace arm_compute
104 #endif /*ARM_COMPUTE_CLMINMAXLOCATIONKERNEL_H */
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
void run(const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue.
ICLTensor ICLImage
Interface for OpenCL images.
Definition: ICLMultiImage.h:33
Interface for the kernel to find min max locations of an image.
Common interface for all the OpenCL kernels.
Definition: ICLKernel.h:43
Copyright (c) 2017-2020 ARM Limited.
Interface for OpenCL Array.
Definition: ICLArray.h:35
void configure(const ICLImage *input, cl::Buffer *min_max)
Initialise the kernel's input and output.
void configure(const ICLImage *input, cl::Buffer *min_max, cl::Buffer *min_max_count, ICLCoordinates2DArray *min_loc=nullptr, ICLCoordinates2DArray *max_loc=nullptr)
Initialise the kernel's input and outputs.
void run(const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue.
CLMinMaxKernel & operator=(const CLMinMaxKernel &)=delete
Prevent instances of this class from being copied (As this class contains pointers)
Interface for the kernel to perform min max search on an image.
Interface for OpenCL tensor.
Definition: ICLTensor.h:42
Describe a multidimensional execution window.
Definition: Window.h:39
CLMinMaxLocationKernel & operator=(const CLMinMaxLocationKernel &)=delete
Prevent instances of this class from being copied (As this class contains pointers)
CLMinMaxKernel()
Default constructor.