Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2020 Arm Limited. |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +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_CLCOL2IMKERNEL_H |
| 25 | #define ARM_COMPUTE_CLCOL2IMKERNEL_H |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 26 | |
Sang-Hoon Park | bef7fa2 | 2020-10-21 15:58:54 +0100 | [diff] [blame] | 27 | #include "src/core/CL/ICLKernel.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 28 | |
| 29 | namespace arm_compute |
| 30 | { |
| 31 | class ICLTensor; |
| 32 | |
| 33 | /** Interface for the col2im reshaping kernel. |
| 34 | * |
| 35 | * Rearranges each matrix column into image blocks. It's the inverse operation of @ref CLIm2ColKernel. |
| 36 | * |
| 37 | * For example, a vector of 9 elements can be reshaped to a block(image) of 3x3: |
| 38 | * |
| 39 | * @f[ |
| 40 | * \left( \begin{array}{ccccccccc} |
| 41 | * a0 & a1 & a2 & a3 & a4 & a5 & a6 & a7 & a8 \\ |
| 42 | * \end{array} \right) |
| 43 | * \rightarrow |
| 44 | * \left( \begin{array}{ccc} |
| 45 | * a0 & a1 & a2 \\ |
| 46 | * a3 & a4 & a5 \\ |
| 47 | * a6 & a7 & a8 \\ |
| 48 | * \end{array} \right) |
| 49 | * @f] |
| 50 | */ |
| 51 | class CLCol2ImKernel : public ICLKernel |
| 52 | { |
| 53 | public: |
| 54 | /** Default constructor */ |
| 55 | CLCol2ImKernel(); |
| 56 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 57 | CLCol2ImKernel(const CLCol2ImKernel &) = delete; |
| 58 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 59 | CLCol2ImKernel &operator=(const CLCol2ImKernel &) = delete; |
| 60 | /** Allow instances of this class to be moved */ |
| 61 | CLCol2ImKernel(CLCol2ImKernel &&) = default; |
| 62 | /** Allow instances of this class to be moved */ |
| 63 | CLCol2ImKernel &operator=(CLCol2ImKernel &&) = default; |
| 64 | /** Default destructor */ |
| 65 | ~CLCol2ImKernel() = default; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 66 | /** Set the input and output of the kernel. |
| 67 | * |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 68 | * @param[in] input The input tensor to convert. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32 |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 69 | * @param[out] output The output tensor. 3 lower dimensions represent a single output [width, height, OFM], |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 70 | * while the rest represent batch of outputs. Data types supported: Same as @p input. Data layout: NCHW |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 71 | * @param[in] convolved_dims Output convolved dimensions. |
Michele Di Giorgio | 980002b | 2018-08-08 09:25:51 +0100 | [diff] [blame] | 72 | * @param[in] num_groups (Optional) Number of groups when performing a grouped convolution |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 73 | */ |
Giorgio Arena | 226e4b9 | 2018-08-23 12:00:02 +0100 | [diff] [blame] | 74 | void configure(const ICLTensor *input, ICLTensor *output, const Size2D &convolved_dims, unsigned int num_groups = 1); |
Manuel Bottini | 4c6bd51 | 2020-04-08 10:15:51 +0100 | [diff] [blame] | 75 | /** Set the input and output of the kernel. |
| 76 | * |
| 77 | * @param[in] compile_context The compile context to be used. |
| 78 | * @param[in] input The input tensor to convert. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32 |
| 79 | * @param[out] output The output tensor. 3 lower dimensions represent a single output [width, height, OFM], |
| 80 | * while the rest represent batch of outputs. Data types supported: Same as @p input. Data layout: NCHW |
| 81 | * @param[in] convolved_dims Output convolved dimensions. |
| 82 | * @param[in] num_groups (Optional) Number of groups when performing a grouped convolution |
| 83 | */ |
Manuel Bottini | 256c0b9 | 2020-04-21 13:29:30 +0100 | [diff] [blame] | 84 | void configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const Size2D &convolved_dims, unsigned int num_groups = 1); |
Georgios Pinitas | 78c0090 | 2018-01-09 17:33:11 +0000 | [diff] [blame] | 85 | /** Static function to check if given info will lead to a valid configuration of @ref CLCol2ImKernel |
| 86 | * |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 87 | * @param[in] input The input tensor to convert. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32 |
Georgios Pinitas | 78c0090 | 2018-01-09 17:33:11 +0000 | [diff] [blame] | 88 | * @param[in] output The output tensor. 3 lower dimensions represent a single output [width, height, OFM], |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 89 | * while the rest represent batch of outputs. Data types supported: Same as @p input. Data layout: NCHW |
Georgios Pinitas | 78c0090 | 2018-01-09 17:33:11 +0000 | [diff] [blame] | 90 | * @param[in] convolved_dims Output convolved dimensions. |
Michele Di Giorgio | 980002b | 2018-08-08 09:25:51 +0100 | [diff] [blame] | 91 | * @param[in] num_groups (Optional) Number of groups when performing a grouped convolution |
Georgios Pinitas | 78c0090 | 2018-01-09 17:33:11 +0000 | [diff] [blame] | 92 | * |
| 93 | * @return a status |
| 94 | */ |
Giorgio Arena | 226e4b9 | 2018-08-23 12:00:02 +0100 | [diff] [blame] | 95 | static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Size2D &convolved_dims, unsigned int num_groups = 1); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 96 | |
| 97 | // Inherited methods overridden: |
| 98 | void run(const Window &window, cl::CommandQueue &queue) override; |
| 99 | |
Georgios Pinitas | 17812ba | 2018-06-04 19:27:13 +0100 | [diff] [blame] | 100 | public: |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 101 | const ICLTensor *_input; |
| 102 | ICLTensor *_output; |
Giorgio Arena | 226e4b9 | 2018-08-23 12:00:02 +0100 | [diff] [blame] | 103 | Size2D _convolved_dims; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 104 | }; |
Gian Marco Iodice | f670a0a | 2017-09-18 12:20:45 +0100 | [diff] [blame] | 105 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 106 | #endif /*ARM_COMPUTE_CLCOL2IMKERNEL_H */ |