Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | ebc3a90 | 2018-11-16 16:04:25 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2019 ARM Limited. |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [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 | */ |
| 24 | #ifndef __ARM_COMPUTE_CLGEMMCONVOLUTIONLAYER_H__ |
| 25 | #define __ARM_COMPUTE_CLGEMMCONVOLUTIONLAYER_H__ |
| 26 | |
| 27 | #include "arm_compute/runtime/IFunction.h" |
| 28 | |
| 29 | #include "arm_compute/core/CL/kernels/CLCol2ImKernel.h" |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 30 | #include "arm_compute/core/CL/kernels/CLElementwiseOperationKernel.h" |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 31 | #include "arm_compute/core/CL/kernels/CLGEMMMatrixMultiplyKernel.h" |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 32 | #include "arm_compute/core/CL/kernels/CLIm2ColKernel.h" |
| 33 | #include "arm_compute/core/CL/kernels/CLWeightsReshapeKernel.h" |
| 34 | #include "arm_compute/core/Types.h" |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 35 | #include "arm_compute/runtime/CL/CLTensor.h" |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 36 | #include "arm_compute/runtime/CL/functions/CLActivationLayer.h" |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 37 | #include "arm_compute/runtime/CL/functions/CLGEMM.h" |
| 38 | #include "arm_compute/runtime/CL/functions/CLGEMMLowpMatrixMultiplyCore.h" |
| 39 | #include "arm_compute/runtime/CL/functions/CLGEMMLowpOutputStage.h" |
Gian Marco Iodice | dff601d | 2018-08-09 13:28:41 +0100 | [diff] [blame] | 40 | #include "arm_compute/runtime/CL/functions/CLReshapeLayer.h" |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 41 | #include "arm_compute/runtime/IMemoryManager.h" |
Michalis Spyrou | b27e13a | 2019-09-27 11:04:27 +0100 | [diff] [blame] | 42 | #include "arm_compute/runtime/ITransformWeights.h" |
| 43 | #include "arm_compute/runtime/IWeightsManager.h" |
Georgios Pinitas | 26014cf | 2019-09-09 19:00:57 +0100 | [diff] [blame] | 44 | #include "arm_compute/runtime/MemoryGroup.h" |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 45 | |
| 46 | #include <memory> |
| 47 | |
| 48 | namespace arm_compute |
| 49 | { |
| 50 | class ICLTensor; |
| 51 | |
| 52 | /** Function to reshape and transpose the weights. This function calls the following kernels: |
| 53 | * -# @ref CLWeightsReshapeKernel |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 54 | */ |
| 55 | class CLConvolutionLayerReshapeWeights : public IFunction |
| 56 | { |
| 57 | public: |
| 58 | /** Constructor */ |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 59 | CLConvolutionLayerReshapeWeights(); |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 60 | /** Set the input and output tensors. |
| 61 | * |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 62 | * @param[in] weights Weights tensor. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame^] | 63 | * Data type supported: QASYMM8/QSYMM8_PER_CHANNEL/F16/F32. |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 64 | * @param[in] biases Biases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. Data type supported: Same as @p weights. |
| 65 | * @param[out] output Destination tensor. Data types supported: Same as @p weights. |
| 66 | * @param[in] num_groups (Optional) Number of groups when performing a grouped convolution. num_groups != 1 is only supported for NCHW data layout |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 67 | */ |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 68 | void configure(const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, unsigned int num_groups = 1); |
Georgios Pinitas | 78c0090 | 2018-01-09 17:33:11 +0000 | [diff] [blame] | 69 | /** Static function to check if given info will lead to a valid configuration of @ref CLConvolutionLayerReshapeWeights |
| 70 | * |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 71 | * @param[in] weights Weights tensor. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame^] | 72 | * Data type supported: QASYMM8/QSYMM8_PER_CHANNEL/F16/F32. |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 73 | * @param[in] biases Biases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. Data type supported: Same as @p weights. |
| 74 | * @param[in] output Destination tensor. Data types supported: Same as @p weights. |
| 75 | * @param[in] num_groups (Optional) Number of groups when performing a grouped convolution. num_groups != 1 is only supported for NCHW data layout |
Georgios Pinitas | 78c0090 | 2018-01-09 17:33:11 +0000 | [diff] [blame] | 76 | * |
| 77 | * @return a status |
| 78 | */ |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 79 | static Status validate(const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, unsigned int num_groups = 1); |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 80 | // Inherited methods overridden: |
| 81 | void run() override; |
| 82 | |
| 83 | private: |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 84 | CLWeightsReshapeKernel _weights_reshape_kernel; |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 85 | }; |
| 86 | |
Michalis Spyrou | b27e13a | 2019-09-27 11:04:27 +0100 | [diff] [blame] | 87 | namespace weights_transformations |
| 88 | { |
| 89 | /** Basic function to manage the reshape weights generated from @ref CLConvolutionLayerReshapeWeights */ |
| 90 | class CLConvolutionLayerReshapeWeightsTransform : public ITransformWeights |
| 91 | { |
| 92 | public: |
| 93 | /** Configures the @ref CLConvolutionLayerReshapeWeights function |
| 94 | * |
| 95 | * @param[in] input Input tensor. Data type supported: QASYMM8/F16/F32. |
| 96 | * @param[in] biases Biases tensor. Data type supported: Same as @p input. |
| 97 | * @param[in] num_groups Number of groups when performing a grouped convolution. |
| 98 | */ |
| 99 | void configure(const ICLTensor *input, const ICLTensor *biases, unsigned int num_groups) |
| 100 | { |
| 101 | _bias_bit = (biases != nullptr) ? 1 : 0; |
| 102 | _num_groups = num_groups; |
| 103 | _func.configure(input, biases, &_output, num_groups); |
| 104 | } |
| 105 | |
| 106 | //Inherited method override |
| 107 | void run() override |
| 108 | { |
| 109 | _output.allocator()->allocate(); |
| 110 | _func.run(); |
| 111 | _reshape_run = true; |
| 112 | } |
| 113 | |
| 114 | //Inherited method override |
| 115 | ICLTensor *get_weights() override |
| 116 | { |
| 117 | return &_output; |
| 118 | } |
| 119 | |
| 120 | //Inherited method override |
| 121 | void release() override |
| 122 | { |
| 123 | _output.allocator()->free(); |
| 124 | } |
| 125 | |
| 126 | //Inherited method override |
| 127 | uint32_t uid() override |
| 128 | { |
| 129 | return ((0x9) | (_bias_bit << 7) | (_num_groups << 8)); |
| 130 | } |
| 131 | |
| 132 | private: |
| 133 | CLTensor _output{}; |
| 134 | CLConvolutionLayerReshapeWeights _func{}; |
| 135 | int32_t _bias_bit{ 0 }; |
| 136 | unsigned int _num_groups{ 0 }; |
| 137 | }; |
| 138 | } // namespace weights_transformations |
| 139 | |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 140 | /** Basic function to compute the convolution layer. This function calls the following OpenCL kernels/functions: |
| 141 | * |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 142 | * -# @ref CLIm2ColKernel |
Gian Marco Iodice | 68a3f56 | 2018-07-26 11:44:03 +0100 | [diff] [blame] | 143 | * -# @ref CLGEMM (if the data type is FP32 or FP16) |
| 144 | * -# @ref CLGEMMLowpMatrixMultiplyCore (if the data type is QASYMM8) |
| 145 | * -# @ref CLGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPoint (if the data type is QASYMM8) |
giuros01 | 164a272 | 2018-11-20 18:34:46 +0000 | [diff] [blame] | 146 | * -# @ref CLElementwiseOperationKernel for addition (if biases != nullptr and we have a 1x1 convolution with the NHWC data layout) |
Georgios Pinitas | 932491f | 2018-09-21 16:33:15 +0100 | [diff] [blame] | 147 | * -# @ref CLCol2ImKernel (if NCHW data layout) |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 148 | */ |
| 149 | class CLGEMMConvolutionLayer : public IFunction |
| 150 | { |
| 151 | public: |
Michalis Spyrou | 1a569a3 | 2019-09-10 17:20:34 +0100 | [diff] [blame] | 152 | /** Constructor |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 153 | * |
Michalis Spyrou | b27e13a | 2019-09-27 11:04:27 +0100 | [diff] [blame] | 154 | * @param[in] memory_manager (Optional) Memory manager. |
| 155 | * @param[in] weights_manager (Optional) Weights manager. |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 156 | */ |
Michalis Spyrou | b27e13a | 2019-09-27 11:04:27 +0100 | [diff] [blame] | 157 | CLGEMMConvolutionLayer(std::shared_ptr<IMemoryManager> memory_manager = nullptr, IWeightsManager *weights_manager = nullptr); |
Georgios Pinitas | 1562be3 | 2018-03-08 19:09:19 +0000 | [diff] [blame] | 158 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 159 | CLGEMMConvolutionLayer(const CLGEMMConvolutionLayer &) = delete; |
| 160 | /** Default move constructor */ |
| 161 | CLGEMMConvolutionLayer(CLGEMMConvolutionLayer &&) = default; |
| 162 | /** Prevent instances of this class from being copied (As this class contains pointers) */ |
| 163 | CLGEMMConvolutionLayer &operator=(const CLGEMMConvolutionLayer &) = delete; |
| 164 | /** Default move assignment operator */ |
| 165 | CLGEMMConvolutionLayer &operator=(CLGEMMConvolutionLayer &&) = default; |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 166 | /** Set the input and output tensors. |
| 167 | * |
| 168 | * @param[in] input Source tensor. 3 lower dimensions represent a single input [width, height, IFM], |
| 169 | * while every optional dimension from 4 and above represent a batch of inputs. |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 170 | * Data types supported: QASYMM8/F16/F32. |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame^] | 171 | * @param[in] weights Weights tensor. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. |
| 172 | * Data type supported: Same as @p input or QASYMM8/QSYMM8_PER_CHANNEL when @p input is QASYMM8. |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 173 | * @param[in] biases Biases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. |
| 174 | * Data type supported: Should match @p input data type, except for input of QASYMM8 type where biases should be of S32 type. |
| 175 | * @param[out] output Destination tensor. 3 lower dimensions represent a single output [width, height, OFM], while the rest represent batch of outputs. |
| 176 | * Data types supported: Same as @p input. |
| 177 | * @param[in] conv_info Contains padding and stride information described in @ref PadStrideInfo. |
| 178 | * @param[in] weights_info Specifies if the weights tensor has been reshaped with CLWeightsReshapeKernel. If this is not part of the fully connected layer the weights |
Gian Marco Iodice | 5fc07aa | 2019-05-15 17:08:02 +0100 | [diff] [blame] | 179 | * tensor has also been transposed with CLGEMMReshapeRHSMatrixKernel. Data type supported: Same as @p input. |
Alex Gilday | 7da29b6 | 2018-03-23 14:16:00 +0000 | [diff] [blame] | 180 | * @param[in] dilation (Optional) Dilation, in elements, across x and y. Defaults to (1, 1). |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 181 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 182 | * @param[in] num_groups (Optional) Number of groups when performing a grouped convolution. num_groups != 1 is only supported for NCHW data layout |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 183 | */ |
Alex Gilday | 7da29b6 | 2018-03-23 14:16:00 +0000 | [diff] [blame] | 184 | void configure(const ICLTensor *input, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, const PadStrideInfo &conv_info, const WeightsInfo &weights_info = WeightsInfo(), |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 185 | const Size2D &dilation = Size2D(1U, 1U), const ActivationLayerInfo &act_info = ActivationLayerInfo(), unsigned int num_groups = 1); |
Georgios Pinitas | 78c0090 | 2018-01-09 17:33:11 +0000 | [diff] [blame] | 186 | /** Static function to check if given info will lead to a valid configuration of @ref CLGEMMConvolutionLayer. |
| 187 | * |
| 188 | * @param[in] input Source tensor. 3 lower dimensions represent a single input [width, height, IFM], |
| 189 | * while every optional dimension from 4 and above represent a batch of inputs. |
Vidhya Sudhan Loganathan | 7485d5a | 2018-07-04 09:34:00 +0100 | [diff] [blame] | 190 | * Data types supported: QASYMM8/F16/F32. |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame^] | 191 | * @param[in] weights Weights tensor. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. |
| 192 | * Data type supported: Same as @p input or QASYMM8/QSYMM8_PER_CHANNEL when @p input is QASYMM8. |
Georgios Pinitas | 78c0090 | 2018-01-09 17:33:11 +0000 | [diff] [blame] | 193 | * @param[in] biases Biases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. |
| 194 | * Data type supported: Should match @p input data type, except for input of QASYMM8 type where biases should be of S32 type. |
| 195 | * @param[out] output Destination tensor. 3 lower dimensions represent a single output [width, height, OFM], while the rest represent batch of outputs. |
| 196 | * Data types supported: Same as @p input. |
| 197 | * @param[in] conv_info Contains padding and stride information described in @ref PadStrideInfo. |
| 198 | * @param[in] weights_info Specifies if the weights tensor has been reshaped with CLWeightsReshapeKernel. If this is not part of the fully connected layer the weights |
Gian Marco Iodice | 5fc07aa | 2019-05-15 17:08:02 +0100 | [diff] [blame] | 199 | * tensor has also been transposed with CLGEMMReshapeRHSMatrixKernel. Data type supported: Same as @p input. |
Alex Gilday | 7da29b6 | 2018-03-23 14:16:00 +0000 | [diff] [blame] | 200 | * @param[in] dilation (Optional) Dilation, in elements, across x and y. Defaults to (1, 1). |
Isabella Gottardi | 3f217ec | 2018-02-12 14:59:19 +0000 | [diff] [blame] | 201 | * @param[in] act_info (Optional) Activation layer information in case of a fused activation. |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 202 | * @param[in] num_groups (Optional) Number of groups when performing a grouped convolution. num_groups != 1 is only supported for NCHW data layout |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 203 | * |
| 204 | * @return a status |
Georgios Pinitas | 78c0090 | 2018-01-09 17:33:11 +0000 | [diff] [blame] | 205 | */ |
| 206 | static Status validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const PadStrideInfo &conv_info, |
Gian Marco Iodice | 916d1bc | 2018-08-13 11:20:41 +0100 | [diff] [blame] | 207 | const WeightsInfo &weights_info = WeightsInfo(), const Size2D &dilation = Size2D(1U, 1U), const ActivationLayerInfo &act_info = ActivationLayerInfo(), unsigned int num_groups = 1); |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 208 | |
| 209 | // Inherited methods overridden: |
| 210 | void run() override; |
Georgios Pinitas | e043767 | 2018-05-02 14:07:55 +0100 | [diff] [blame] | 211 | void prepare() override; |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 212 | |
| 213 | private: |
| 214 | /** Configures the appropriate matrix multiply routine |
| 215 | * |
Gian Marco Iodice | 4b90865 | 2018-10-18 10:21:02 +0100 | [diff] [blame] | 216 | * @param[in] input Input tensor. Data types supported: QASYMM8/F16/F32. |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame^] | 217 | * @param[in] weights Weights tensor. Data type supported: Same as @p input or QASYMM8/QSYMM8_PER_CHANNEL when @p input is QASYMM8. |
Gian Marco Iodice | 4b90865 | 2018-10-18 10:21:02 +0100 | [diff] [blame] | 218 | * @param[in] biases Biases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. |
| 219 | * Data type supported: Should match @p input data type, except for input of QASYMM8 type where biases should be of S32 type. |
| 220 | * @param[in, out] output Output tensor. Data types supported: Same as @p input, |
| 221 | * except for input of QASYMM8 type where output should be of S32 type. |
| 222 | * @param[in] gemmlowp_output_stage GEMMLowp output stage info |
Michele Di Giorgio | ebc3a90 | 2018-11-16 16:04:25 +0000 | [diff] [blame] | 223 | * @param[in] gemm_3d_depth Depth of GEMM 3D |
Gian Marco Iodice | f3622be | 2019-07-29 14:27:16 +0100 | [diff] [blame] | 224 | * @param[in] act_info Activation to apply after the matrix multiplication |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 225 | */ |
Gian Marco Iodice | f3622be | 2019-07-29 14:27:16 +0100 | [diff] [blame] | 226 | void configure_mm(const ICLTensor *input, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, const GEMMLowpOutputStageInfo &gemmlowp_output_stage, int gemm_3d_depth, |
| 227 | const ActivationLayerInfo &act_info); |
Georgios Pinitas | 78c0090 | 2018-01-09 17:33:11 +0000 | [diff] [blame] | 228 | /** Static function to check if given info will lead to a valid configuration of @ref CLGEMMConvolutionLayer matrix multiply routines |
| 229 | * |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame^] | 230 | * @param[in] input Input tensor info. Data types supported: QASYMM8/F16/F32. |
| 231 | * @param[in] weights Weights tensor info. Data type supported: Same as @p input or QASYMM8/QSYMM8_PER_CHANNEL when @p input is QASYMM8. |
| 232 | * @param[in] biases Biases tensor info. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. |
Gian Marco Iodice | 4b90865 | 2018-10-18 10:21:02 +0100 | [diff] [blame] | 233 | * Data type supported: Should match @p input data type, except for input of QASYMM8 type where biases should be of S32 type. |
Vidhya Sudhan Loganathan | 951b8a4 | 2019-11-04 14:42:08 +0000 | [diff] [blame^] | 234 | * @param[in] output Output tensor info. Data types supported: Same as @p input, |
| 235 | * except for input of QASYMM8 type where output should be of S32 type. |
Gian Marco Iodice | 4b90865 | 2018-10-18 10:21:02 +0100 | [diff] [blame] | 236 | * @param[in] gemmlowp_output_stage GEMMLowp output stage info |
Michele Di Giorgio | ebc3a90 | 2018-11-16 16:04:25 +0000 | [diff] [blame] | 237 | * @param[in] gemm_3d_depth Depth of GEMM 3D |
| 238 | * @param[in] skip_im2col Flag which specifies if im2col has to be skipped. i.e. 1x1 convolution with NHWC data layout. |
Gian Marco Iodice | f3622be | 2019-07-29 14:27:16 +0100 | [diff] [blame] | 239 | * @param[in] act_info Activation to apply after the matrix multiplication |
Georgios Pinitas | 78c0090 | 2018-01-09 17:33:11 +0000 | [diff] [blame] | 240 | * |
| 241 | * @return a status |
| 242 | */ |
Gian Marco Iodice | 4b90865 | 2018-10-18 10:21:02 +0100 | [diff] [blame] | 243 | static Status validate_mm(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const GEMMLowpOutputStageInfo &gemmlowp_output_stage, |
Gian Marco Iodice | f3622be | 2019-07-29 14:27:16 +0100 | [diff] [blame] | 244 | int gemm_3d_depth, bool skip_im2col, const ActivationLayerInfo &act_info); |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 245 | |
| 246 | private: |
Michalis Spyrou | b27e13a | 2019-09-27 11:04:27 +0100 | [diff] [blame] | 247 | MemoryGroup _memory_group; |
| 248 | IWeightsManager *_weights_manager; |
| 249 | CLConvolutionLayerReshapeWeights _reshape_weights; |
| 250 | weights_transformations::CLConvolutionLayerReshapeWeightsTransform _reshape_weights_managed; |
| 251 | CLIm2ColKernel _im2col_kernel; |
| 252 | CLGEMM _mm_gemm; |
| 253 | CLGEMMLowpMatrixMultiplyCore _mm_gemmlowp; |
| 254 | CLCol2ImKernel _col2im_kernel; |
| 255 | CLActivationLayer _activationlayer_function; |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 256 | |
Georgios Pinitas | 1562be3 | 2018-03-08 19:09:19 +0000 | [diff] [blame] | 257 | const ICLTensor *_original_weights; |
| 258 | |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 259 | CLTensor _im2col_output; |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 260 | CLTensor _weights_reshaped; |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 261 | CLTensor _gemm_output; |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 262 | |
Georgios Pinitas | 19ea419 | 2018-06-19 13:09:53 +0100 | [diff] [blame] | 263 | bool _skip_im2col; |
Georgios Pinitas | 932491f | 2018-09-21 16:33:15 +0100 | [diff] [blame] | 264 | bool _skip_col2im; |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 265 | bool _is_quantized; |
Gian Marco Iodice | f3622be | 2019-07-29 14:27:16 +0100 | [diff] [blame] | 266 | bool _fuse_activation; |
Georgios Pinitas | e043767 | 2018-05-02 14:07:55 +0100 | [diff] [blame] | 267 | bool _is_prepared; |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 268 | }; |
Georgios Pinitas | 19ea419 | 2018-06-19 13:09:53 +0100 | [diff] [blame] | 269 | } // namespace arm_compute |
Isabella Gottardi | f07d28d | 2018-02-06 14:52:43 +0000 | [diff] [blame] | 270 | #endif /* __ARM_COMPUTE_CLGEMMCONVOLUTIONLAYER_H__ */ |