Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 1 | /* |
SiCong Li | 4ceb453 | 2023-03-13 15:02:23 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2021, 2023 Arm Limited. |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [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 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_CLBATCHTOSPACELAYER_H |
| 25 | #define ARM_COMPUTE_CLBATCHTOSPACELAYER_H |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 26 | |
| 27 | #include "arm_compute/runtime/IFunction.h" |
| 28 | |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 29 | #include "arm_compute/core/Types.h" |
| 30 | |
Sang-Hoon Park | bef7fa2 | 2020-10-21 15:58:54 +0100 | [diff] [blame] | 31 | #include <memory> |
| 32 | |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 33 | namespace arm_compute |
| 34 | { |
Sang-Hoon Park | bef7fa2 | 2020-10-21 15:58:54 +0100 | [diff] [blame] | 35 | class CLCompileContext; |
| 36 | class ITensorInfo; |
| 37 | class CLBatchToSpaceLayerKernel; |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 38 | class ICLTensor; |
| 39 | |
| 40 | /** Basic function to run @ref CLBatchToSpaceLayerKernel. */ |
| 41 | class CLBatchToSpaceLayer : public IFunction |
| 42 | { |
| 43 | public: |
| 44 | /** Default constructor */ |
| 45 | CLBatchToSpaceLayer(); |
Sang-Hoon Park | bef7fa2 | 2020-10-21 15:58:54 +0100 | [diff] [blame] | 46 | /** Prevent instances of this class from being copied */ |
| 47 | CLBatchToSpaceLayer(const CLBatchToSpaceLayer &) = delete; |
| 48 | /** Prevent instances of this class from being copied */ |
| 49 | CLBatchToSpaceLayer &operator=(const CLBatchToSpaceLayer &) = delete; |
| 50 | /** Prevent instances of this class to be moved */ |
| 51 | CLBatchToSpaceLayer(CLBatchToSpaceLayer &&) = delete; |
| 52 | /** Prevent instances of this class to be moved */ |
| 53 | CLBatchToSpaceLayer &operator=(CLBatchToSpaceLayer &&) = delete; |
| 54 | /** Default destructor */ |
| 55 | ~CLBatchToSpaceLayer(); |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 56 | /** Set the input and output tensors. |
| 57 | * |
Teresa Charlin | 6268742 | 2021-04-28 10:58:49 +0100 | [diff] [blame] | 58 | * Valid data layouts: |
| 59 | * - NHWC |
| 60 | * - NCHW |
| 61 | * |
| 62 | * Valid data type configurations: |
| 63 | * |src0 |src1 |dst | |
| 64 | * |:---------|:---------|:----------| |
| 65 | * |All |s32 |All | |
| 66 | * |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 67 | * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: All. |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 68 | * @param[in] block_shape 1-D tensor with shape [M]. Data types supported: S32 |
| 69 | * @param[out] output Tensor output. Data types supported: same as @p input |
Omar Al Khatib | fff9a4c | 2023-03-28 11:14:29 +0100 | [diff] [blame] | 70 | * |
| 71 | * @deprecated This method for dynamic block shape is not fully mature and will be removed in 23.08 release |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 72 | */ |
Omar Al Khatib | fff9a4c | 2023-03-28 11:14:29 +0100 | [diff] [blame] | 73 | ARM_COMPUTE_DEPRECATED_REL(23.05) |
| 74 | void configure(const ICLTensor *input, const ICLTensor *block_shape, ICLTensor *output); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 75 | /** Set the input and output tensors. |
| 76 | * |
| 77 | * @param[in] compile_context The compile context to be used. |
| 78 | * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: All. |
| 79 | * @param[in] block_shape 1-D tensor with shape [M]. Data types supported: S32 |
| 80 | * @param[out] output Tensor output. Data types supported: same as @p input |
Omar Al Khatib | fff9a4c | 2023-03-28 11:14:29 +0100 | [diff] [blame] | 81 | * |
| 82 | * @deprecated This method for dynamic block shape is not fully mature and will be removed in 23.08 release |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 83 | */ |
Omar Al Khatib | fff9a4c | 2023-03-28 11:14:29 +0100 | [diff] [blame] | 84 | ARM_COMPUTE_DEPRECATED_REL(23.05) |
| 85 | void configure(const CLCompileContext &compile_context, const ICLTensor *input, const ICLTensor *block_shape, ICLTensor *output); |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 86 | /** Set the input and output tensors. (Static block shape). |
| 87 | * |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 88 | * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: All. |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 89 | * @param[in] block_shape_x Block shape x value. |
| 90 | * @param[in] block_shape_y Block shape y value. |
| 91 | * @param[out] output Tensor output. Data types supported: same as @p input |
SiCong Li | 4ceb453 | 2023-03-13 15:02:23 +0000 | [diff] [blame] | 92 | * @param[in] crop_info Information about how the output shape is cropped after batch to space is performed |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 93 | */ |
SiCong Li | 4ceb453 | 2023-03-13 15:02:23 +0000 | [diff] [blame] | 94 | void configure(const ICLTensor *input, int32_t block_shape_x, int32_t block_shape_y, ICLTensor *output, const CropInfo &crop_info = CropInfo{}); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 95 | /** Set the input and output tensors. (Static block shape). |
| 96 | * |
| 97 | * @param[in] compile_context The compile context to be used. |
| 98 | * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: All. |
| 99 | * @param[in] block_shape_x Block shape x value. |
| 100 | * @param[in] block_shape_y Block shape y value. |
| 101 | * @param[out] output Tensor output. Data types supported: same as @p input |
SiCong Li | 4ceb453 | 2023-03-13 15:02:23 +0000 | [diff] [blame] | 102 | * @param[in] crop_info Information about how the output shape is cropped after batch to space is performed |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 103 | */ |
SiCong Li | 4ceb453 | 2023-03-13 15:02:23 +0000 | [diff] [blame] | 104 | void configure(const CLCompileContext &compile_context, const ICLTensor *input, int32_t block_shape_x, int32_t block_shape_y, ICLTensor *output, const CropInfo &crop_info = CropInfo{}); |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 105 | /** Static function to check if given info will lead to a valid configuration of @ref CLBatchToSpaceLayer |
| 106 | * |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 107 | * @param[in] input Tensor input info. Supported tensor rank: 4. Data types supported: All. |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 108 | * @param[in] block_shape block shape tensor info with shape [M]. Data types supported: S32 |
| 109 | * @param[out] output Tensor output info. Data types supported: same as @p input |
| 110 | * |
| 111 | * @return a status |
Omar Al Khatib | fff9a4c | 2023-03-28 11:14:29 +0100 | [diff] [blame] | 112 | * |
| 113 | * @deprecated This method for dynamic block shape is not fully mature and will be removed in 23.08 release |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 114 | */ |
Omar Al Khatib | fff9a4c | 2023-03-28 11:14:29 +0100 | [diff] [blame] | 115 | ARM_COMPUTE_DEPRECATED_REL(23.05) |
| 116 | static Status validate(const ITensorInfo *input, const ITensorInfo *block_shape, const ITensorInfo *output); |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 117 | /** Static function to check if given info will lead to a valid configuration of @ref CLBatchToSpaceLayer (Static block shape). |
| 118 | * |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 119 | * @param[in] input Tensor input info. Supported tensor rank: 4. Data types supported: All. |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 120 | * @param[in] block_shape_x Block shape x value. |
| 121 | * @param[in] block_shape_y Block shape y value. |
| 122 | * @param[out] output Tensor output info. Data types supported: same as @p input |
SiCong Li | 4ceb453 | 2023-03-13 15:02:23 +0000 | [diff] [blame] | 123 | * @param[in] crop_info Information about how the output shape is cropped after batch to space is performed |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 124 | * |
| 125 | * @return a status |
| 126 | */ |
SiCong Li | 4ceb453 | 2023-03-13 15:02:23 +0000 | [diff] [blame] | 127 | static Status validate(const ITensorInfo *input, int32_t block_shape_x, int32_t block_shape_y, const ITensorInfo *output, const CropInfo &crop_info = CropInfo{}); |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 128 | |
| 129 | // Inherited methods overridden: |
| 130 | void run() override; |
| 131 | |
| 132 | private: |
Sang-Hoon Park | bef7fa2 | 2020-10-21 15:58:54 +0100 | [diff] [blame] | 133 | std::unique_ptr<CLBatchToSpaceLayerKernel> _batch_to_space_kernel; /**< CLBatchToSpaceLayerKernel to run */ |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 134 | }; |
Sang-Hoon Park | bef7fa2 | 2020-10-21 15:58:54 +0100 | [diff] [blame] | 135 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 136 | #endif /* ARM_COMPUTE_CLBATCHTOSPACELAYER_H */ |