blob: a1c6f901eba056bc64735dc17245726bad03f9e6 [file] [log] [blame]
George Wort894066d2019-02-15 15:12:52 +00001/*
Manuel Bottini4c6bd512020-04-08 10:15:51 +01002 * Copyright (c) 2019-2020 ARM Limited.
George Wort894066d2019-02-15 15:12:52 +00003 *
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_CLCROPKERNEL_H
25#define ARM_COMPUTE_CLCROPKERNEL_H
George Wort894066d2019-02-15 15:12:52 +000026
27#include "arm_compute/core/CL/ICLKernel.h"
28#include "arm_compute/core/Types.h"
29
30namespace arm_compute
31{
32class ICLTensor;
33
34/** OpenCL kernel to perform a copy between two tensors */
35class CLCropKernel : public ICLKernel
36{
37public:
38 /** Default constructor */
39 CLCropKernel();
40 /** Prevent instances of this class from being copied (As this class contains pointers). */
41 CLCropKernel(const CLCropKernel &) = delete;
42 /** Prevent instances of this class from being copied (As this class contains pointers). */
43 CLCropKernel &operator=(const CLCropKernel &) = delete;
44 /** Allow instances of this class to be moved */
45 CLCropKernel(CLCropKernel &&) = default;
46 /** Allow instances of this class to be moved */
47 CLCropKernel &operator=(CLCropKernel &&) = default;
48 /** Configure kernel
49 *
50 * @note Supported tensor rank: up to 4
51 *
52 * @param[in] input Source tensor. Data type supported: U16/S16/U32/S32/F16/F32. Data layouts supported: NHWC.
53 * @param[out] output Destination tensor. Data type supported: F32
54 * @param[in] start Coordinates of where to start cropping the image.
55 * @param[in] end Coordinates of where to end cropping the image.
56 * @param[in] batch_index Fourth dimension index of the 3D image to crop in @p input.
57 * @param[in] extrapolation_value Value to be used for values outside of the image. Default is 0.
58 * @param[in] output_window Output window to be used in case cropped image is being copied into a tensor. Default is nullptr.
59 */
60 void configure(const ICLTensor *input, ICLTensor *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value = 0, Window *output_window = nullptr);
Manuel Bottini4c6bd512020-04-08 10:15:51 +010061 /** Configure kernel
62 *
63 * @note Supported tensor rank: up to 4
64 *
65 * @param[in] compile_context The compile context to be used.
66 * @param[in] input Source tensor. Data type supported: U16/S16/U32/S32/F16/F32. Data layouts supported: NHWC.
67 * @param[out] output Destination tensor. Data type supported: F32
68 * @param[in] start Coordinates of where to start cropping the image.
69 * @param[in] end Coordinates of where to end cropping the image.
70 * @param[in] batch_index Fourth dimension index of the 3D image to crop in @p input.
71 * @param[in] extrapolation_value Value to be used for values outside of the image. Default is 0.
72 * @param[in] output_window Output window to be used in case cropped image is being copied into a tensor. Default is nullptr.
73 */
Manuel Bottini256c0b92020-04-21 13:29:30 +010074 void configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value = 0,
Manuel Bottini4c6bd512020-04-08 10:15:51 +010075 Window *output_window = nullptr);
George Wort894066d2019-02-15 15:12:52 +000076
77 /** Static function to check if given info will lead to a valid configuration of @ref CLStridedSliceKernel
78 *
79 * @note Supported tensor rank: up to 4
80 *
81 * @param[in] input Source tensor info. Data type supported: U16/S16/U32/S32/F16/F32. Data layouts supported: NHWC.
82 * @param[in] output Destination tensor info. Data type supported: F32
83 * @param[in] start Coordinates of where to start cropping the image.
84 * @param[in] end Coordinates of where to end cropping the image.
85 * @param[in] batch_index Fourth dimension index of the 3D image to crop in @p input.
86 * @param[in] extrapolation_value Value to be used for values outside of the image. Default is 0.
87 * @param[in] output_window Output window to be used in case cropped image is being copied into a tensor. Default is nullptr.
88 */
89 static Status validate(const ITensorInfo *input, const ITensorInfo *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value = 0,
90 Window *output_window = nullptr);
91
92 // Inherited methods overridden:
93 void run(const Window &window, cl::CommandQueue &queue) override;
94
95private:
96 const ICLTensor *_input;
97 ICLTensor *_output;
98 Coordinates2D _start;
99 uint32_t _batch_index;
100 float _extrapolation_value;
101};
102} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000103#endif /*ARM_COMPUTE_CLCROPKERNEL_H */