blob: ff4b13f86510f015450321a2e2fecaf6352e7c03 [file] [log] [blame]
George Wort894066d2019-02-15 15:12:52 +00001/*
2 * Copyright (c) 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_CLCROPKERNEL_H__
25#define __ARM_COMPUTE_CLCROPKERNEL_H__
26
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);
61
62 /** Static function to check if given info will lead to a valid configuration of @ref CLStridedSliceKernel
63 *
64 * @note Supported tensor rank: up to 4
65 *
66 * @param[in] input Source tensor info. Data type supported: U16/S16/U32/S32/F16/F32. Data layouts supported: NHWC.
67 * @param[in] output Destination tensor info. 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 */
74 static Status validate(const ITensorInfo *input, const ITensorInfo *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value = 0,
75 Window *output_window = nullptr);
76
77 // Inherited methods overridden:
78 void run(const Window &window, cl::CommandQueue &queue) override;
79
80private:
81 const ICLTensor *_input;
82 ICLTensor *_output;
83 Coordinates2D _start;
84 uint32_t _batch_index;
85 float _extrapolation_value;
86};
87} // namespace arm_compute
88#endif /*__ARM_COMPUTE_CLCROPKERNEL_H__ */