blob: 34194aba01b447a032396c40308e3849b607e3c4 [file] [log] [blame]
Manuel Bottini7b237322021-07-14 17:07:23 +01001/*
2 * Copyright (c) 2017-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_CL_COL2IM_KERNEL_H
25#define ARM_COMPUTE_CL_COL2IM_KERNEL_H
26
27#include "arm_compute/core/Size2D.h"
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010028
Manuel Bottini7b237322021-07-14 17:07:23 +010029#include "src/core/common/Macros.h"
Georgios Pinitas7891a732021-08-20 21:39:25 +010030#include "src/gpu/cl/ClCompileContext.h"
31#include "src/gpu/cl/IClKernel.h"
Manuel Bottini7b237322021-07-14 17:07:23 +010032
33namespace arm_compute
34{
35namespace opencl
36{
37namespace kernels
38{
39/** Interface for the col2im reshaping kernel.
40 *
Manuel Bottinid844c082021-07-14 12:58:54 +010041 * Rearranges each matrix column into image blocks. It's the inverse operation of @ref opencl::kernels::ClIm2ColKernel.
Manuel Bottini7b237322021-07-14 17:07:23 +010042 *
43 * For example, a vector of 9 elements can be reshaped to a block(image) of 3x3:
44 *
45 * @f[
46 * \left( \begin{array}{ccccccccc}
47 * a0 & a1 & a2 & a3 & a4 & a5 & a6 & a7 & a8 \\
48 * \end{array} \right)
49 * \rightarrow
50 * \left( \begin{array}{ccc}
51 * a0 & a1 & a2 \\
52 * a3 & a4 & a5 \\
53 * a6 & a7 & a8 \\
54 * \end{array} \right)
55 * @f]
56 */
57class ClCol2ImKernel : public IClKernel
58{
59public:
60 /** Default constructor */
61 ClCol2ImKernel();
62 ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(ClCol2ImKernel);
63 /** Set the input and output of the kernel.
64 *
65 * @param[in] compile_context The compile context to be used.
66 * @param[in] src The input tensor info to convert. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32
67 * @param[out] dst The output tensor info. 3 lower dimensions represent a single output [width, height, OFM],
68 * while the rest represent batch of outputs. Data types supported: Same as @p input. Data layout: NCHW
69 * @param[in] convolved_dims Output convolved dimensions.
70 * @param[in] num_groups (Optional) Number of groups when performing a grouped convolution
71 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010072 void configure(const CLCompileContext &compile_context,
73 ITensorInfo *src,
74 ITensorInfo *dst,
75 const Size2D &convolved_dims,
76 unsigned int num_groups = 1);
Manuel Bottini7b237322021-07-14 17:07:23 +010077 /** Static function to check if given info will lead to a valid configuration
78 *
79 * Similar to ClCol2ImKernel::configure()
80 *
81 * @return a status
82 */
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010083 static Status
84 validate(const ITensorInfo *src, const ITensorInfo *dst, const Size2D &convolved_dims, unsigned int num_groups = 1);
Manuel Bottini7b237322021-07-14 17:07:23 +010085
86 // Inherited methods overridden:
87 void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue) override;
88
89public:
90 Size2D _convolved_dims;
91};
92} // namespace kernels
93} // namespace opencl
94} // namespace arm_compute
95#endif /*ARM_COMPUTE_CL_COL2IM_KERNEL_H */