blob: b9d3e66fe2383fe83c4d576c55e4ba16b906e069 [file] [log] [blame]
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +01001/*
Omar Al Khatibfff9a4c2023-03-28 11:14:29 +01002 * Copyright (c) 2018-2021, 2023 Arm Limited.
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +01003 *
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_CLBATCHTOSPACELAYERKERNEL_H
25#define ARM_COMPUTE_CLBATCHTOSPACELAYERKERNEL_H
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010026
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010027#include "arm_compute/core/Types.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010028
Sang-Hoon Parkbef7fa22020-10-21 15:58:54 +010029#include "src/core/CL/ICLKernel.h"
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010030
31namespace arm_compute
32{
33class ICLTensor;
34
35/** Interface for the batch to space kernel */
36class CLBatchToSpaceLayerKernel : public ICLKernel
37{
38public:
39 /** Default constructor */
40 CLBatchToSpaceLayerKernel();
41 /** Prevent instances of this class from being copied (As this class contains pointers) */
42 CLBatchToSpaceLayerKernel(const CLBatchToSpaceLayerKernel &) = delete;
43 /** Prevent instances of this class from being copied (As this class contains pointers) */
44 CLBatchToSpaceLayerKernel &operator=(const CLBatchToSpaceLayerKernel &) = delete;
45 /** Allow instances of this class to be moved */
46 CLBatchToSpaceLayerKernel(CLBatchToSpaceLayerKernel &&) = default;
47 /** Allow instances of this class to be moved */
48 CLBatchToSpaceLayerKernel &operator=(CLBatchToSpaceLayerKernel &&) = default;
49 /** Default destructor */
50 ~CLBatchToSpaceLayerKernel() = default;
51 /** Initialise the kernel's inputs and output.
52 *
Manuel Bottini8481d832019-12-10 15:28:40 +000053 * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: All.
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010054 * @param[in] block_shape 1-D tensor with shape [M]. Data types supported: S32
55 * @param[out] output Tensor output. Data types supported: same as @p input
Omar Al Khatibfff9a4c2023-03-28 11:14:29 +010056 *
57 * @deprecated This method for dynamic block shape is not fully mature and will be removed in 23.08 release
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010058 */
59 void configure(const ICLTensor *input, const ICLTensor *block_shape, ICLTensor *output);
Manuel Bottini4c6bd512020-04-08 10:15:51 +010060 /** Initialise the kernel's inputs and output.
61 *
62 * @param[in] compile_context The compile context to be used.
63 * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: All.
64 * @param[in] block_shape 1-D tensor with shape [M]. Data types supported: S32
65 * @param[out] output Tensor output. Data types supported: same as @p input
Omar Al Khatibfff9a4c2023-03-28 11:14:29 +010066 *
67 * @deprecated This method for dynamic block shape is not fully mature and will be removed in 23.08 release
Manuel Bottini4c6bd512020-04-08 10:15:51 +010068 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010069 void configure(const CLCompileContext &compile_context,
70 const ICLTensor *input,
71 const ICLTensor *block_shape,
72 ICLTensor *output);
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010073 /** Initialise the kernel's inputs and output (Static block shape).
74 *
Manuel Bottini8481d832019-12-10 15:28:40 +000075 * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: All.
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010076 * @param[in] block_shape_x Block shape x value.
77 * @param[in] block_shape_y Block shape y value.
78 * @param[out] output Tensor output. Data types supported: same as @p input
Omar Al Khatibfff9a4c2023-03-28 11:14:29 +010079 * @param[in] crop_info Specifies how the output shape is cropped after batch to space is performed
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +010080 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010081 void configure(const ICLTensor *input,
82 const int32_t block_shape_x,
83 const int32_t block_shape_y,
84 ICLTensor *output,
85 const CropInfo &crop_info);
Manuel Bottini4c6bd512020-04-08 10:15:51 +010086 /** Initialise the kernel's inputs and output (Static block shape).
87 *
88 * @param[in] compile_context The compile context to be used.
89 * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: All.
90 * @param[in] block_shape_x Block shape x value.
91 * @param[in] block_shape_y Block shape y value.
92 * @param[out] output Tensor output. Data types supported: same as @p input
Omar Al Khatibfff9a4c2023-03-28 11:14:29 +010093 * @param[in] crop_info Specifies how the output shape is cropped after batch to space is performed
Manuel Bottini4c6bd512020-04-08 10:15:51 +010094 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010095 void configure(const CLCompileContext &compile_context,
96 const ICLTensor *input,
97 const int32_t block_shape_x,
98 const int32_t block_shape_y,
99 ICLTensor *output,
100 const CropInfo &crop_info);
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +0100101 /** Static function to check if given info will lead to a valid configuration of @ref CLBatchToSpaceLayerKernel
102 *
Manuel Bottini8481d832019-12-10 15:28:40 +0000103 * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: All.
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +0100104 * @param[in] block_shape 1-D tensor with shape [M]. Data types supported: S32
105 * @param[in] output Tensor output. Data types supported: same as @p input
106 *
107 * @return a status
Omar Al Khatibfff9a4c2023-03-28 11:14:29 +0100108 *
109 * @deprecated This method for dynamic block shape is not fully mature and will be removed in 23.08 release
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +0100110 */
111 static Status validate(const ITensorInfo *input, const ITensorInfo *block_shape, const ITensorInfo *output);
112 /** Static function to check if given info will lead to a valid configuration of @ref CLBatchToSpaceLayerKernel (Static block shape).
113 *
Manuel Bottini8481d832019-12-10 15:28:40 +0000114 * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: All.
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +0100115 * @param[in] block_shape_x Block shape x value.
116 * @param[in] block_shape_y Block shape y value.
117 * @param[in] output Tensor output. Data types supported: same as @p input
Omar Al Khatibfff9a4c2023-03-28 11:14:29 +0100118 * @param[in] crop_info Specifies how the output shape is cropped after batch to space is performed
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +0100119 *
120 * @return a status
121 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +0100122 static Status validate(const ITensorInfo *input,
123 const int32_t block_shape_x,
124 const int32_t block_shape_y,
125 const ITensorInfo *output,
126 const CropInfo &crop_info);
Michalis Spyrou6a8d3b62018-08-31 10:07:09 +0100127
128 // Inherited methods overridden:
129 void run(const Window &window, cl::CommandQueue &queue) override;
130
131private:
132 const ICLTensor *_input; /**< Source tensor */
133 const ICLTensor *_block_shape; /**< Block shape tensor */
134 ICLTensor *_output; /**< Destination tensor */
135};
136} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000137#endif /* ARM_COMPUTE_CLBATCHTOSPACELAYERKERNEL_H */