arm_compute v18.05
[platform/upstream/armcl.git] / arm_compute / runtime / NEON / functions / NEDepthwiseSeparableConvolutionLayer.h
1 /*
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_NEON_DEPTHWISE_SEPARABLE_CONVOLUTION_H__
25 #define __ARM_COMPUTE_NEON_DEPTHWISE_SEPARABLE_CONVOLUTION_H__
26
27 #include "arm_compute/core/Types.h"
28 #include "arm_compute/runtime/IFunction.h"
29 #include "arm_compute/runtime/NEON/INESimpleFunction.h"
30 #include "arm_compute/runtime/NEON/functions/NEDepthwiseConvolutionLayer.h"
31 #include "arm_compute/runtime/NEON/functions/NEDirectConvolutionLayer.h"
32 #include "arm_compute/runtime/Tensor.h"
33
34 #include <cstdint>
35
36 namespace arm_compute
37 {
38 class ITensor;
39
40 /** Basic function to execute depthwise convolution. This function calls the following NEON kernels and function:
41  *
42  * -# @ref NEDepthwiseConvolutionLayer
43  * -# @ref NEDirectConvolutionLayer
44  *
45  */
46 class NEDepthwiseSeparableConvolutionLayer : public IFunction
47 {
48 public:
49     /** Default constructor */
50     NEDepthwiseSeparableConvolutionLayer();
51     /** Set the input and output tensors.
52      *
53      * @param[in]  input               Source tensor. 3 lower dimensions represent a single input [width, height, IFM],
54      *                                 while every optional dimension from 4 and above represent a batch of inputs. Data types supported: F32.
55      * @param[in]  depthwise_weights   Depthwise convolution weights tensor. These are 3D tensors with dimensions [kernel_x, kernel_y, IFM]. Data type supported: Same as @p input.
56      * @param[in]  depthwise_biases    (Optional) Biases tensor.Biases are 1D tensor with dimensions [IFM]. Must be nullptr if not needed.
57      *                                 Data type supported: Same as @p weights.
58      * @param[out] depthwise_out       Depthwise destination tensor.
59      * @param[in]  pointwise_weights   Pointwise convolution weights tensor. These are 4D tensors with dimensions [1, 1, IFM, OFM]. Data type supported: Same as @p input.
60      * @param[in]  pointwise_biases    (Optional) Biases tensor. Biases are 1D tensor with dimensions [OFM]. Must be nullptr if not needed.
61      *                                 Data type supported: Same as @p weights.
62      * @param[out] output              Destination tensor. 3 lower dimensions represent a single output [width, height, OFM], while the rest represent batch of outputs.
63      *                                 Data types supported: Same as @p input.
64      * @param[in]  depthwise_conv_info Contains padding and stride information described in @ref PadStrideInfo for depthwise convolution.
65      * @param[in]  pointwise_conv_info Contains padding and stride information described in @ref PadStrideInfo for pointwise convolution.
66      */
67     void configure(ITensor *input, const ITensor *depthwise_weights, const ITensor *depthwise_biases, ITensor *depthwise_out,
68                    const ITensor *pointwise_weights, const ITensor *pointwise_biases, ITensor *output,
69                    const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info);
70
71     // Inherited methods overriden:
72     void run() override;
73
74 private:
75     NEDepthwiseConvolutionLayer _depthwise_conv;
76     NEDirectConvolutionLayer    _pointwise_conv;
77 };
78 }
79 #endif /*__ARM_COMPUTE_NEON_DEPTHWISE_SEPARABLE_CONVOLUTION_H__ */