Compute Library
 22.05
CLBatchToSpaceLayer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2021 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_CLBATCHTOSPACELAYER_H
25 #define ARM_COMPUTE_CLBATCHTOSPACELAYER_H
26 
28 
29 #include "arm_compute/core/Types.h"
30 
31 #include <memory>
32 
33 namespace arm_compute
34 {
35 class CLCompileContext;
36 class ITensorInfo;
37 class CLBatchToSpaceLayerKernel;
38 class ICLTensor;
39 
40 /** Basic function to run @ref CLBatchToSpaceLayerKernel. */
42 {
43 public:
44  /** Default constructor */
46  /** Prevent instances of this class from being copied */
47  CLBatchToSpaceLayer(const CLBatchToSpaceLayer &) = delete;
48  /** Prevent instances of this class from being copied */
50  /** Prevent instances of this class to be moved */
52  /** Prevent instances of this class to be moved */
54  /** Default destructor */
56  /** Set the input and output tensors.
57  *
58  * Valid data layouts:
59  * - NHWC
60  * - NCHW
61  *
62  * Valid data type configurations:
63  * |src0 |src1 |dst |
64  * |:---------|:---------|:----------|
65  * |All |s32 |All |
66  *
67  * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: All.
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);
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);
80  /** Set the input and output tensors. (Static block shape).
81  *
82  * @param[in] input Tensor input. Supported tensor rank: 4. Data types supported: All.
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);
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);
97  /** Static function to check if given info will lead to a valid configuration of @ref CLBatchToSpaceLayer
98  *
99  * @param[in] input Tensor input info. Supported tensor rank: 4. Data types supported: All.
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  *
108  * @param[in] input Tensor input info. Supported tensor rank: 4. Data types supported: All.
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:
121  std::unique_ptr<CLBatchToSpaceLayerKernel> _batch_to_space_kernel; /**< CLBatchToSpaceLayerKernel to run */
122 };
123 } // namespace arm_compute
124 #endif /* ARM_COMPUTE_CLBATCHTOSPACELAYER_H */
Base class for all functions.
Definition: IFunction.h:30
void run() override
Run the kernels contained in the function.
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
Copyright (c) 2017-2022 Arm Limited.
static Status validate(const ITensorInfo *input, const ITensorInfo *block_shape, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of CLBatchToSpaceLayer.
void configure(const ICLTensor *input, const ICLTensor *block_shape, ICLTensor *output)
Set the input and output tensors.
CLBatchToSpaceLayer()
Default constructor.
CLCompileContext class.
Interface for OpenCL tensor.
Definition: ICLTensor.h:42
CLBatchToSpaceLayer & operator=(const CLBatchToSpaceLayer &)=delete
Prevent instances of this class from being copied.
~CLBatchToSpaceLayer()
Default destructor.
Basic function to run CLBatchToSpaceLayerKernel.