blob: 415b781bc6383f47dc39135c5fcb5557bad3576b [file] [log] [blame]
Anthony Barbier7068f992017-10-26 15:23:08 +01001/*
2 * Copyright (c) 2017 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_GCDIRECTCONVOLUTIONLAYERKERNEL_H__
25#define __ARM_COMPUTE_GCDIRECTCONVOLUTIONLAYERKERNEL_H__
26
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.
61 */
62 void configure(const IGCTensor *input, const IGCTensor *weights, const IGCTensor *bias, IGCTensor *output, const PadStrideInfo &conv_info);
63
64 // Inherited methods overridden:
65 BorderSize border_size() const override;
66
67 // Inherited methods overridden:
68 void run(const Window &window) override;
69
70private:
71 const IGCTensor *_input;
72 const IGCTensor *_bias;
73 const IGCTensor *_weights;
74 IGCTensor *_output;
75 BorderSize _border_size;
76 int _conv_stride_x;
77 int _conv_stride_y;
78 int _conv_pad_x;
79 int _conv_pad_y;
80 gles::NDRange _lws;
81};
82
83using GCDirectConvolutionLayer1x1Kernel = GCDirectConvolutionLayerKernel<1>;
84using GCDirectConvolutionLayer3x3Kernel = GCDirectConvolutionLayerKernel<3>;
85using GCDirectConvolutionLayer5x5Kernel = GCDirectConvolutionLayerKernel<5>;
86}
87#endif /*__ARM_COMPUTE_GCDIRECTCONVOLUTIONLAYERKERNEL_H__ */