blob: 9d2775ada6f9d6f9696a4319efa2cc8d6d758fe4 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +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_NEDIRECTCONVOLUTIONLAYER_H__
25#define __ARM_COMPUTE_NEDIRECTCONVOLUTIONLAYER_H__
26
27#include "arm_compute/core/NEON/kernels/NEDirectConvolutionLayerBiasAccumulateKernel.h"
28#include "arm_compute/core/NEON/kernels/NEDirectConvolutionLayerKernel.h"
29#include "arm_compute/core/NEON/kernels/NEFillBorderKernel.h"
30#include "arm_compute/core/Types.h"
31#include "arm_compute/runtime/IFunction.h"
32#include "arm_compute/runtime/Tensor.h"
33
34namespace arm_compute
35{
36/** Function to run the direct convolution.
37 *
38 * This function calls the following NEON kernels:
39 *
40 * -# @ref NEFillBorderKernel for the input
41 * -# @ref NEDirectConvolutionLayerBiasAccumulateKernel
42 * -# @ref NEDirectConvolutionLayerKernel
43 */
44class NEDirectConvolutionLayer : public IFunction
45{
46public:
47 /** Constructor */
48 NEDirectConvolutionLayer();
49 /** Set the input, weights, biases and output tensors.
50 *
Pablo Tello06da39d2017-08-10 15:10:40 +010051 * @note: DirectConvolution only works in the following configurations:
52 * 1x1 convolution with stride_x = 1/2/3, stride_y = 1/2/3 data type = QS8/QS16/F16/F32
53 * 3x3 convolution with stride_x = 1/2/3, stride_y = 1/2/3 data type = QS8/F16/F32
54 * 5x5 convolution with stride_x = 1/2/3, stride_y = 1/2/3 data type = F32
55 *
Pablo Tellof87cc7f2017-07-26 10:28:40 +010056 * @param[in, out] input Input tensor. Data types supported: QS8/QS16/F16/F32.
Anthony Barbier6ff3b192017-09-04 18:44:23 +010057 * @param[in] weights Set of kernels to convolve the input volume.
Pablo Tello06da39d2017-08-10 15:10:40 +010058 * Supported sizes: 1x1, 3x3 and 5x5.
Anthony Barbier6ff3b192017-09-04 18:44:23 +010059 * The 3rd dimension must be the same as the input's volume 3rd dimension.
60 * Data type supported: Same as @p input.
61 * @param[in] bias Set of biases. Data type supported: Same as @p input.
62 * @param[out] output Output tensor.
63 * The 3rd dimensions must be equal to the 4th dimension of the @p kernels tensor. Data types supported: Same as @p input.
64 * @param[in] conv_info Contains padding and stride information described in @ref PadStrideInfo.
65 */
66 void configure(ITensor *input, const ITensor *weights, const ITensor *bias, ITensor *output, const PadStrideInfo &conv_info);
67
68 // Inherited methods overridden:
69 void run() override;
70
71private:
72 NEDirectConvolutionLayerBiasAccumulateKernel _accumulate_bias_kernel;
73 NEDirectConvolutionLayerKernel _conv_kernel;
74 NEFillBorderKernel _input_border_handler;
75 Tensor _accumulator;
76};
77}
78#endif /* __ARM_COMPUTE_NEDIRECTCONVOLUTIONLAYER_H__ */