George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 1 | /* |
Sheri Zhang | 7e20e29 | 2021-02-02 11:49:34 +0000 | [diff] [blame] | 2 | * Copyright (c) 2021 Arm Limited. |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 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 | */ |
Georgios Pinitas | 2eb5d16 | 2021-07-02 09:01:49 +0100 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_CLCROP_H |
| 25 | #define ARM_COMPUTE_CLCROP_H |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 26 | |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 27 | #include "arm_compute/core/Types.h" |
Sheri Zhang | 7e20e29 | 2021-02-02 11:49:34 +0000 | [diff] [blame] | 28 | #include "arm_compute/core/Window.h" |
| 29 | #include "arm_compute/runtime/IFunction.h" |
| 30 | #include <memory> |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 31 | |
| 32 | namespace arm_compute |
| 33 | { |
Sheri Zhang | 7e20e29 | 2021-02-02 11:49:34 +0000 | [diff] [blame] | 34 | class CLCompileContext; |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 35 | class ICLTensor; |
Sheri Zhang | 7e20e29 | 2021-02-02 11:49:34 +0000 | [diff] [blame] | 36 | class ITensorInfo; |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 37 | |
Sheri Zhang | 7e20e29 | 2021-02-02 11:49:34 +0000 | [diff] [blame] | 38 | /** Basic function to run @ref opencl::kernels::ClCropKernel */ |
| 39 | class CLCrop : public IFunction |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 40 | { |
| 41 | public: |
Sheri Zhang | 7e20e29 | 2021-02-02 11:49:34 +0000 | [diff] [blame] | 42 | /** Constructor */ |
| 43 | CLCrop(); |
| 44 | /** Destructor */ |
| 45 | ~CLCrop(); |
| 46 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 47 | CLCrop(const CLCrop &) = delete; |
| 48 | /** Default move constructor */ |
| 49 | CLCrop(CLCrop &&); |
| 50 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 51 | CLCrop &operator=(const CLCrop &) = delete; |
| 52 | /** Default move assignment operator */ |
| 53 | CLCrop &operator=(CLCrop &&); |
| 54 | /** Configure function |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 55 | * |
| 56 | * @note Supported tensor rank: up to 4 |
| 57 | * |
Sheri Zhang | 6124ce6 | 2021-05-04 14:03:13 +0100 | [diff] [blame] | 58 | * Valid data layouts: |
| 59 | * - NHWC |
| 60 | * |
| 61 | * Valid data type configurations: |
| 62 | * |src |dst | |
| 63 | * |:--------------|:--------------| |
| 64 | * |All |F32 | |
| 65 | * |
Michele Di Giorgio | 7d6b577 | 2020-06-01 13:39:52 +0100 | [diff] [blame] | 66 | * @param[in] input Source tensor. Data type supported: All. Data layouts supported: NHWC. |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 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 | */ |
| 74 | void configure(const ICLTensor *input, ICLTensor *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value = 0, Window *output_window = nullptr); |
Sheri Zhang | 7e20e29 | 2021-02-02 11:49:34 +0000 | [diff] [blame] | 75 | /** Configure function |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 76 | * |
| 77 | * @note Supported tensor rank: up to 4 |
| 78 | * |
| 79 | * @param[in] compile_context The compile context to be used. |
Michele Di Giorgio | 7d6b577 | 2020-06-01 13:39:52 +0100 | [diff] [blame] | 80 | * @param[in] input Source tensor. Data type supported: All. Data layouts supported: NHWC. |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 81 | * @param[out] output Destination tensor. Data type supported: F32 |
| 82 | * @param[in] start Coordinates of where to start cropping the image. |
| 83 | * @param[in] end Coordinates of where to end cropping the image. |
| 84 | * @param[in] batch_index Fourth dimension index of the 3D image to crop in @p input. |
| 85 | * @param[in] extrapolation_value Value to be used for values outside of the image. Default is 0. |
| 86 | * @param[in] output_window Output window to be used in case cropped image is being copied into a tensor. Default is nullptr. |
| 87 | */ |
Manuel Bottini | 256c0b9 | 2020-04-21 13:29:30 +0100 | [diff] [blame] | 88 | void configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value = 0, |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 89 | Window *output_window = nullptr); |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 90 | |
| 91 | /** Static function to check if given info will lead to a valid configuration of @ref CLStridedSliceKernel |
| 92 | * |
| 93 | * @note Supported tensor rank: up to 4 |
| 94 | * |
Michele Di Giorgio | 7d6b577 | 2020-06-01 13:39:52 +0100 | [diff] [blame] | 95 | * @param[in] input Source tensor info. Data type supported: All. Data layouts supported: NHWC. |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 96 | * @param[in] output Destination tensor info. Data type supported: F32 |
| 97 | * @param[in] start Coordinates of where to start cropping the image. |
| 98 | * @param[in] end Coordinates of where to end cropping the image. |
| 99 | * @param[in] batch_index Fourth dimension index of the 3D image to crop in @p input. |
| 100 | * @param[in] extrapolation_value Value to be used for values outside of the image. Default is 0. |
| 101 | * @param[in] output_window Output window to be used in case cropped image is being copied into a tensor. Default is nullptr. |
| 102 | */ |
| 103 | static Status validate(const ITensorInfo *input, const ITensorInfo *output, Coordinates2D start, Coordinates2D end, uint32_t batch_index, float extrapolation_value = 0, |
| 104 | Window *output_window = nullptr); |
| 105 | |
| 106 | // Inherited methods overridden: |
Sheri Zhang | 7e20e29 | 2021-02-02 11:49:34 +0000 | [diff] [blame] | 107 | void run() override; |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 108 | |
| 109 | private: |
Sheri Zhang | 7e20e29 | 2021-02-02 11:49:34 +0000 | [diff] [blame] | 110 | struct Impl; |
| 111 | std::unique_ptr<Impl> _impl; |
George Wort | 894066d | 2019-02-15 15:12:52 +0000 | [diff] [blame] | 112 | }; |
| 113 | } // namespace arm_compute |
Georgios Pinitas | 2eb5d16 | 2021-07-02 09:01:49 +0100 | [diff] [blame] | 114 | #endif /*ARM_COMPUTE_CLCROP_H */ |