blob: 1281238be9822ebdacd60bf1dc5e608b56da085a [file] [log] [blame]
Michalis Spyrou53d8c5c2017-11-23 17:11:35 +00001/*
Georgios Pinitas72219332018-06-05 14:56:06 +01002 * Copyright (c) 2017-2018 ARM Limited.
Michalis Spyrou53d8c5c2017-11-23 17:11:35 +00003 *
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"
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000029#include "arm_compute/runtime/NEON/functions/NEDepthwiseConvolutionLayer.h"
Michalis Spyrou53d8c5c2017-11-23 17:11:35 +000030#include "arm_compute/runtime/NEON/functions/NEDirectConvolutionLayer.h"
31#include "arm_compute/runtime/Tensor.h"
32
33#include <cstdint>
34
35namespace arm_compute
36{
37class ITensor;
38
39/** Basic function to execute depthwise convolution. This function calls the following NEON kernels and function:
40 *
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000041 * -# @ref NEDepthwiseConvolutionLayer
Michalis Spyrou53d8c5c2017-11-23 17:11:35 +000042 * -# @ref NEDirectConvolutionLayer
43 *
44 */
45class NEDepthwiseSeparableConvolutionLayer : public IFunction
46{
47public:
48 /** Default constructor */
49 NEDepthwiseSeparableConvolutionLayer();
50 /** Set the input and output tensors.
51 *
52 * @param[in] input Source tensor. 3 lower dimensions represent a single input [width, height, IFM],
53 * while every optional dimension from 4 and above represent a batch of inputs. Data types supported: F32.
54 * @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.
55 * @param[in] depthwise_biases (Optional) Biases tensor.Biases are 1D tensor with dimensions [IFM]. Must be nullptr if not needed.
56 * Data type supported: Same as @p weights.
57 * @param[out] depthwise_out Depthwise destination tensor.
58 * @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.
59 * @param[in] pointwise_biases (Optional) Biases tensor. Biases are 1D tensor with dimensions [OFM]. Must be nullptr if not needed.
60 * Data type supported: Same as @p weights.
61 * @param[out] output Destination tensor. 3 lower dimensions represent a single output [width, height, OFM], while the rest represent batch of outputs.
62 * Data types supported: Same as @p input.
63 * @param[in] depthwise_conv_info Contains padding and stride information described in @ref PadStrideInfo for depthwise convolution.
64 * @param[in] pointwise_conv_info Contains padding and stride information described in @ref PadStrideInfo for pointwise convolution.
65 */
66 void configure(ITensor *input, const ITensor *depthwise_weights, const ITensor *depthwise_biases, ITensor *depthwise_out,
67 const ITensor *pointwise_weights, const ITensor *pointwise_biases, ITensor *output,
68 const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info);
69
70 // Inherited methods overriden:
71 void run() override;
Georgios Pinitas72219332018-06-05 14:56:06 +010072 void prepare() override;
Michalis Spyrou53d8c5c2017-11-23 17:11:35 +000073
74private:
Giorgio Arena04a8f8c2017-11-23 11:45:24 +000075 NEDepthwiseConvolutionLayer _depthwise_conv;
76 NEDirectConvolutionLayer _pointwise_conv;
Michalis Spyrou53d8c5c2017-11-23 17:11:35 +000077};
Michalis Spyrou95abfdd2018-11-28 14:59:47 +000078} // namespace arm_compute
Michalis Spyrou53d8c5c2017-11-23 17:11:35 +000079#endif /*__ARM_COMPUTE_NEON_DEPTHWISE_SEPARABLE_CONVOLUTION_H__ */