blob: 2d4bd1e0c247e698a84584aa97ced92ca3dc5b4e [file] [log] [blame]
Michalis Spyrou7bfe4c52017-11-24 09:54:20 +00001/*
Giorgio Arenaa66eaa22017-12-21 19:50:06 +00002 * Copyright (c) 2017-2018 ARM Limited.
Michalis Spyrou7bfe4c52017-11-24 09:54:20 +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_GRAPH_DEPTHWISE_CONVOLUTION_LAYER_H__
25#define __ARM_COMPUTE_GRAPH_DEPTHWISE_CONVOLUTION_LAYER_H__
26
27#include "arm_compute/graph/GraphContext.h"
28#include "arm_compute/graph/INode.h"
29#include "arm_compute/graph/ITensorObject.h"
30#include "arm_compute/graph/SubTensor.h"
31#include "arm_compute/graph/Tensor.h"
32#include "arm_compute/graph/Types.h"
33#include "arm_compute/runtime/IFunction.h"
34
35#include <memory>
36
37namespace arm_compute
38{
39namespace graph
40{
41/** Convolution layer node */
42class DepthwiseConvolutionLayer final : public INode
43{
44public:
45 /** Default constructor
46 *
47 * @param[in] conv_width Convolution width
48 * @param[in] conv_height Convolution height
49 * @param[in] weights Weights values tensor
Georgios Pinitas236bfe72017-11-23 15:59:55 +000050 * @param[in] biases Biases values tensor
Michalis Spyrou7bfe4c52017-11-24 09:54:20 +000051 * @param[in] conv_info Convolution info
Michalis Spyrou7bfe4c52017-11-24 09:54:20 +000052 * @param[in] opt3x3 (Optional) If true executes DepthwiseConvolutionLayer3x3
Giorgio Arenaa66eaa22017-12-21 19:50:06 +000053 * @param[in] quant_info (Optional) Quantization info used for weights
Michalis Spyrou7bfe4c52017-11-24 09:54:20 +000054 */
55 template <typename AccessorType>
Giorgio Arenaa66eaa22017-12-21 19:50:06 +000056 DepthwiseConvolutionLayer(unsigned int conv_width, unsigned int conv_height, AccessorType &&weights, AccessorType &&biases, const PadStrideInfo conv_info, bool opt3x3 = true,
57 const QuantizationInfo quant_info = QuantizationInfo())
58 : _conv_width(conv_width), _conv_height(conv_height), _weights(std::move(weights)), _biases(std::move(biases)), _conv_info(conv_info), _opt3x3(opt3x3), _quant_info(std::move(quant_info))
Michalis Spyrou7bfe4c52017-11-24 09:54:20 +000059 {
60 }
61
62 // Inherited methods overriden:
63 std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensorObject *input, ITensorObject *output) override;
64
65private:
Giorgio Arenaa66eaa22017-12-21 19:50:06 +000066 unsigned int _conv_width;
67 unsigned int _conv_height;
68 Tensor _weights;
69 Tensor _biases;
70 const PadStrideInfo _conv_info;
71 bool _opt3x3;
72 const QuantizationInfo _quant_info;
Michalis Spyrou7bfe4c52017-11-24 09:54:20 +000073};
74} // namespace graph
75} // namespace arm_compute
76#endif /* __ARM_COMPUTE_GRAPH_DEPTHWISE_CONVOLUTION_LAYER_H__ */