Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 1 | /* |
Teresa Charlin | 6268742 | 2021-04-28 10:58:49 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018-2021 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 |
| 70 | */ |
| 71 | void configure(const ICLTensor *input, const ICLTensor *block_shape, ICLTensor *output); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 72 | /** Set the input and output tensors. |
| 73 | * |
| 74 | * @param[in] compile_context The compile context to be used. |
| 75 | * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: All. |
| 76 | * @param[in] block_shape 1-D tensor with shape [M]. Data types supported: S32 |
| 77 | * @param[out] output Tensor output. Data types supported: same as @p input |
| 78 | */ |
| 79 | 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] | 80 | /** Set the input and output tensors. (Static block shape). |
| 81 | * |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 82 | * @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] | 83 | * @param[in] block_shape_x Block shape x value. |
| 84 | * @param[in] block_shape_y Block shape y value. |
| 85 | * @param[out] output Tensor output. Data types supported: same as @p input |
| 86 | */ |
| 87 | void configure(const ICLTensor *input, int32_t block_shape_x, int32_t block_shape_y, ICLTensor *output); |
Manuel Bottini | 2b84be5 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 88 | /** Set the input and output tensors. (Static block shape). |
| 89 | * |
| 90 | * @param[in] compile_context The compile context to be used. |
| 91 | * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: All. |
| 92 | * @param[in] block_shape_x Block shape x value. |
| 93 | * @param[in] block_shape_y Block shape y value. |
| 94 | * @param[out] output Tensor output. Data types supported: same as @p input |
| 95 | */ |
| 96 | void configure(const CLCompileContext &compile_context, const ICLTensor *input, int32_t block_shape_x, int32_t block_shape_y, ICLTensor *output); |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 97 | /** Static function to check if given info will lead to a valid configuration of @ref CLBatchToSpaceLayer |
| 98 | * |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 99 | * @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] | 100 | * @param[in] block_shape block shape tensor info with shape [M]. Data types supported: S32 |
| 101 | * @param[out] output Tensor output info. Data types supported: same as @p input |
| 102 | * |
| 103 | * @return a status |
| 104 | */ |
| 105 | static Status validate(const ITensorInfo *input, const ITensorInfo *block_shape, const ITensorInfo *output); |
| 106 | /** Static function to check if given info will lead to a valid configuration of @ref CLBatchToSpaceLayer (Static block shape). |
| 107 | * |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 108 | * @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] | 109 | * @param[in] block_shape_x Block shape x value. |
| 110 | * @param[in] block_shape_y Block shape y value. |
| 111 | * @param[out] output Tensor output info. Data types supported: same as @p input |
| 112 | * |
| 113 | * @return a status |
| 114 | */ |
| 115 | static Status validate(const ITensorInfo *input, int32_t block_shape_x, int32_t block_shape_y, const ITensorInfo *output); |
| 116 | |
| 117 | // Inherited methods overridden: |
| 118 | void run() override; |
| 119 | |
| 120 | private: |
Sang-Hoon Park | bef7fa2 | 2020-10-21 15:58:54 +0100 | [diff] [blame] | 121 | std::unique_ptr<CLBatchToSpaceLayerKernel> _batch_to_space_kernel; /**< CLBatchToSpaceLayerKernel to run */ |
Michalis Spyrou | 6a8d3b6 | 2018-08-31 10:07:09 +0100 | [diff] [blame] | 122 | }; |
Sang-Hoon Park | bef7fa2 | 2020-10-21 15:58:54 +0100 | [diff] [blame] | 123 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 124 | #endif /* ARM_COMPUTE_CLBATCHTOSPACELAYER_H */ |