blob: 43f94f8662af670d9ea3f9bad2c6fcb7c800b216 [file] [log] [blame]
Anthony Barbier7068f992017-10-26 15:23:08 +01001/*
Michalis Spyrouf4643372019-11-29 16:17:13 +00002 * Copyright (c) 2017-2019 ARM Limited.
Anthony Barbier7068f992017-10-26 15:23:08 +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_GCDIRECTCONVOLUTIONLAYERKERNEL_H
25#define ARM_COMPUTE_GCDIRECTCONVOLUTIONLAYERKERNEL_H
Anthony Barbier7068f992017-10-26 15:23:08 +010026
27#include "arm_compute/core/GLES_COMPUTE/IGCKernel.h"
28#include "arm_compute/core/GLES_COMPUTE/OpenGLES.h"
29
30namespace arm_compute
31{
32class IGCTensor;
33
34/** Interface for the direct convolution kernel.
35 */
36template <unsigned int kernel_size>
37class GCDirectConvolutionLayerKernel : public IGCKernel
38{
39public:
40 /** Default constructor */
41 GCDirectConvolutionLayerKernel();
42 /** Prevent instances of this class from being copied (As this class contains pointers) */
43 GCDirectConvolutionLayerKernel(const GCDirectConvolutionLayerKernel &) = delete;
44 /** Prevent instances of this class from being copied (As this class contains pointers) */
45 GCDirectConvolutionLayerKernel &operator=(const GCDirectConvolutionLayerKernel &) = delete;
46 /** Allow instances of this class to be moved */
47 GCDirectConvolutionLayerKernel(GCDirectConvolutionLayerKernel &&) = default;
48 /** Allow instances of this class to be moved */
49 GCDirectConvolutionLayerKernel &operator=(GCDirectConvolutionLayerKernel &&) = default;
50 /** Default destructor */
51 ~GCDirectConvolutionLayerKernel() = default;
52 /** Set the input and output of the kernel.
53 *
54 * @param[in] input The input tensor to convert. 3 lower dimensions represent a single input [width, height, IFM],
55 * while every optional dimension from 4 and above represent a batch of inputs. Data types supported: F16/F32
56 * @param[in] weights Weights tensor. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. Data type supported:Same as @p input.
57 * @param[in] bias Biases tensor. Shared bias supported. Biases are 1D tensor with dimensions [OFM]. Data type supported:Same as @p input.
58 * @param[out] output The output tensor. First 2 lower dimensions represent a transform of each 3D input,
59 * while every dimension above represents a batch. Data types supported: Same as @p input
60 * @param[in] conv_info Contains padding and stride information described in @ref PadStrideInfo.
Isabella Gottardi3f217ec2018-02-12 14:59:19 +000061 * @param[in] act_info (Optional) Activation layer information in case of a fused activation.
Anthony Barbier7068f992017-10-26 15:23:08 +010062 */
Isabella Gottardi3f217ec2018-02-12 14:59:19 +000063 void configure(const IGCTensor *input, const IGCTensor *weights, const IGCTensor *bias, IGCTensor *output,
64 const PadStrideInfo &conv_info, const ActivationLayerInfo &act_info = ActivationLayerInfo());
Anthony Barbier7068f992017-10-26 15:23:08 +010065
66 // Inherited methods overridden:
67 BorderSize border_size() const override;
68
69 // Inherited methods overridden:
70 void run(const Window &window) override;
71
72private:
73 const IGCTensor *_input;
74 const IGCTensor *_bias;
75 const IGCTensor *_weights;
76 IGCTensor *_output;
77 BorderSize _border_size;
78 int _conv_stride_x;
79 int _conv_stride_y;
80 int _conv_pad_x;
81 int _conv_pad_y;
82 gles::NDRange _lws;
83};
84
Alex Gildayc357c472018-03-21 13:54:09 +000085/** Interface for the 1x1 direct convolution kernel */
Anthony Barbier7068f992017-10-26 15:23:08 +010086using GCDirectConvolutionLayer1x1Kernel = GCDirectConvolutionLayerKernel<1>;
Alex Gildayc357c472018-03-21 13:54:09 +000087/** Interface for the 3x3 direct convolution kernel */
Anthony Barbier7068f992017-10-26 15:23:08 +010088using GCDirectConvolutionLayer3x3Kernel = GCDirectConvolutionLayerKernel<3>;
Alex Gildayc357c472018-03-21 13:54:09 +000089/** Interface for the 5x5 direct convolution kernel */
Anthony Barbier7068f992017-10-26 15:23:08 +010090using GCDirectConvolutionLayer5x5Kernel = GCDirectConvolutionLayerKernel<5>;
91}
Michalis Spyrouf4643372019-11-29 16:17:13 +000092#endif /*ARM_COMPUTE_GCDIRECTCONVOLUTIONLAYERKERNEL_H */