Michalis Spyrou | 7bfe4c5 | 2017-11-24 09:54:20 +0000 | [diff] [blame] | 1 | /* |
Giorgio Arena | a66eaa2 | 2017-12-21 19:50:06 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2018 ARM Limited. |
Michalis Spyrou | 7bfe4c5 | 2017-11-24 09:54:20 +0000 | [diff] [blame] | 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_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 | |
| 37 | namespace arm_compute |
| 38 | { |
| 39 | namespace graph |
| 40 | { |
| 41 | /** Convolution layer node */ |
| 42 | class DepthwiseConvolutionLayer final : public INode |
| 43 | { |
| 44 | public: |
| 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 Pinitas | 236bfe7 | 2017-11-23 15:59:55 +0000 | [diff] [blame] | 50 | * @param[in] biases Biases values tensor |
Michalis Spyrou | 7bfe4c5 | 2017-11-24 09:54:20 +0000 | [diff] [blame] | 51 | * @param[in] conv_info Convolution info |
Michalis Spyrou | 7bfe4c5 | 2017-11-24 09:54:20 +0000 | [diff] [blame] | 52 | * @param[in] opt3x3 (Optional) If true executes DepthwiseConvolutionLayer3x3 |
Giorgio Arena | a66eaa2 | 2017-12-21 19:50:06 +0000 | [diff] [blame] | 53 | * @param[in] quant_info (Optional) Quantization info used for weights |
Michalis Spyrou | 7bfe4c5 | 2017-11-24 09:54:20 +0000 | [diff] [blame] | 54 | */ |
| 55 | template <typename AccessorType> |
Giorgio Arena | a66eaa2 | 2017-12-21 19:50:06 +0000 | [diff] [blame] | 56 | 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 Spyrou | 7bfe4c5 | 2017-11-24 09:54:20 +0000 | [diff] [blame] | 59 | { |
| 60 | } |
| 61 | |
| 62 | // Inherited methods overriden: |
| 63 | std::unique_ptr<arm_compute::IFunction> instantiate_node(GraphContext &ctx, ITensorObject *input, ITensorObject *output) override; |
| 64 | |
| 65 | private: |
Giorgio Arena | a66eaa2 | 2017-12-21 19:50:06 +0000 | [diff] [blame] | 66 | 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 Spyrou | 7bfe4c5 | 2017-11-24 09:54:20 +0000 | [diff] [blame] | 73 | }; |
| 74 | } // namespace graph |
| 75 | } // namespace arm_compute |
| 76 | #endif /* __ARM_COMPUTE_GRAPH_DEPTHWISE_CONVOLUTION_LAYER_H__ */ |