blob: f1eae9a96ea9240061f442d98332575c89c742e1 [file] [log] [blame]
Michalis Spyrou7362f0d2017-10-18 17:58:22 +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_NEDEPTHWISECONVOLUTION_H__
25#define __ARM_COMPUTE_NEDEPTHWISECONVOLUTION_H__
26
27#include "arm_compute/core/NEON/kernels/NEDepthwiseConvolution3x3Kernel.h"
28#include "arm_compute/core/NEON/kernels/NEDirectConvolutionLayerBiasAccumulateKernel.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/IMemoryManager.h"
33#include "arm_compute/runtime/MemoryGroup.h"
34#include "arm_compute/runtime/Tensor.h"
35
36namespace arm_compute
37{
38class ITensor;
39
40/** Basic function to execute a depthwise convolution for kernel size 3x3xC. This function calls the following NEON kernels:
41 *
42 * -# @ref NEDepthwiseConvolution3x3
43 * -# @ref NEFillBorderKernel (if pad_x or pad_y > 0)
44 *
45 */
46class NEDepthwiseConvolution3x3 : public IFunction
47{
48public:
49 /** Default constructor */
50 NEDepthwiseConvolution3x3();
51 /** Initialize the function's source, destination, kernels and border_size.
52 *
53 * @param[in, out] input Source tensor. Data type supported: F32. (Written to only for border filling).
54 * @param[out] output Destination tensor. Data type supported: same as @p input.
55 * @param[in] weights Weights tensor. These are 3D tensors with shape [3, 3, IFM]. Data type supported: Same as @p input.
56 * @param[in] biases (Optional) Biases tensor. A 1D tensor with shape [IFM]. Must be nullptr if not needed.
57 * Data type supported: Same as @p input.
58 * @param[in] conv_info Padding and stride information to use for the convolution.
59 */
60 void configure(ITensor *input, ITensor *output, const ITensor *weights, const ITensor *biases, const PadStrideInfo &conv_info);
61
62 // Inherited methods overriden:
63 void run() override;
64
65private:
66 NEDepthwiseConvolution3x3Kernel _kernel;
67 NEDirectConvolutionLayerBiasAccumulateKernel _bias_kernel;
68 NEFillBorderKernel _border_handler;
69 bool _has_bias;
70};
71}
72#endif /* __ARM_COMPUTE_NEDEPTHWISECONVOLUTION_H__ */