surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1 | // |
Finn Williams | f24effa | 2020-07-03 10:12:03 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 4 | // |
| 5 | #pragma once |
| 6 | |
| 7 | #include "LayerWithParameters.hpp" |
| 8 | |
| 9 | namespace armnn |
| 10 | { |
| 11 | |
James Conroy | 1f58f03 | 2021-04-27 17:13:27 +0100 | [diff] [blame] | 12 | class ScopedTensorHandle; |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 13 | |
Conor Kennedy | 35052ae | 2018-12-21 14:38:36 +0000 | [diff] [blame] | 14 | /// This layer represents a depthwise convolution 2d operation. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 15 | class DepthwiseConvolution2dLayer : public LayerWithParameters<DepthwiseConvolution2dDescriptor> |
| 16 | { |
| 17 | public: |
Conor Kennedy | 35052ae | 2018-12-21 14:38:36 +0000 | [diff] [blame] | 18 | /// A unique pointer to store Weight values. |
Teresa Charlin | 71b386d | 2022-09-28 10:25:40 +0100 | [diff] [blame^] | 19 | /// @Note Deprecated. Removal date is 23.02. Weights are stored in ConstantLayers now. |
James Conroy | 1f58f03 | 2021-04-27 17:13:27 +0100 | [diff] [blame] | 20 | std::shared_ptr<ConstTensorHandle> m_Weight; |
Conor Kennedy | 35052ae | 2018-12-21 14:38:36 +0000 | [diff] [blame] | 21 | /// A unique pointer to store Bias values. |
Teresa Charlin | 71b386d | 2022-09-28 10:25:40 +0100 | [diff] [blame^] | 22 | /// @Note Deprecated. Removal date is 23.02. Bias are stored in ConstantLayers now. |
James Conroy | 1f58f03 | 2021-04-27 17:13:27 +0100 | [diff] [blame] | 23 | std::shared_ptr<ConstTensorHandle> m_Bias; |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 24 | |
Conor Kennedy | 35052ae | 2018-12-21 14:38:36 +0000 | [diff] [blame] | 25 | /// Makes a workload for the DepthwiseConvolution2d type. |
| 26 | /// @param [in] graph The graph where this layer can be found. |
| 27 | /// @param [in] factory The workload factory which will create the workload. |
| 28 | /// @return A pointer to the created workload, or nullptr if not created. |
Derek Lamberti | 94a88d2 | 2019-12-10 21:12:59 +0000 | [diff] [blame] | 29 | virtual std::unique_ptr<IWorkload> CreateWorkload(const IWorkloadFactory& factory) const override; |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 30 | |
Conor Kennedy | 35052ae | 2018-12-21 14:38:36 +0000 | [diff] [blame] | 31 | /// Creates a dynamically-allocated copy of this layer. |
| 32 | /// @param [in] graph The graph into which this layer is being cloned. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 33 | DepthwiseConvolution2dLayer* Clone(Graph& graph) const override; |
| 34 | |
Conor Kennedy | 35052ae | 2018-12-21 14:38:36 +0000 | [diff] [blame] | 35 | /// Check if the input tensor shape(s) |
| 36 | /// will lead to a valid configuration of @ref DepthwiseConvolution2dLayer. |
Teresa Charlin | cdc0149 | 2020-06-09 18:00:20 +0100 | [diff] [blame] | 37 | /// @param [in] shapeInferenceMethod Indicates if output shape shall be overwritten or just validated. |
Finn Williams | f24effa | 2020-07-03 10:12:03 +0100 | [diff] [blame] | 38 | void ValidateTensorShapesFromInputs() override; |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 39 | |
Conor Kennedy | 35052ae | 2018-12-21 14:38:36 +0000 | [diff] [blame] | 40 | /// By default returns inputShapes if the number of inputs are equal to number of outputs, |
| 41 | /// otherwise infers the output shapes from given input shapes and layer properties. |
| 42 | /// @param [in] inputShapes The input shapes layer has. |
| 43 | /// @return A vector to the inferred output shape. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 44 | std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& inputShapes) const override; |
| 45 | |
Finn Williams | b454c5c | 2021-02-09 15:56:23 +0000 | [diff] [blame] | 46 | void ExecuteStrategy(IStrategy& strategy) const override; |
| 47 | |
Andre Ghattas | 23ae2ea | 2019-08-07 12:18:38 +0100 | [diff] [blame] | 48 | void SerializeLayerParameters(ParameterStringifyFunction& fn) const override; |
| 49 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 50 | protected: |
Conor Kennedy | 35052ae | 2018-12-21 14:38:36 +0000 | [diff] [blame] | 51 | /// Constructor to create a DepthwiseConvolution2dLayer. |
| 52 | /// @param [in] param DepthwiseConvolution2dDescriptor to configure the depthwise convolution2d. |
| 53 | /// @param [in] name Optional name for the layer. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 54 | DepthwiseConvolution2dLayer(const DepthwiseConvolution2dDescriptor& param, const char* name); |
Conor Kennedy | 35052ae | 2018-12-21 14:38:36 +0000 | [diff] [blame] | 55 | |
| 56 | /// Default destructor |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 57 | ~DepthwiseConvolution2dLayer() = default; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 58 | |
Conor Kennedy | 35052ae | 2018-12-21 14:38:36 +0000 | [diff] [blame] | 59 | /// Retrieve the handles to the constant values stored by the layer. |
| 60 | /// @return A vector of the constant tensors stored by this layer. |
Cathal Corbett | 0690265 | 2022-04-14 17:55:11 +0100 | [diff] [blame] | 61 | /// @Note Deprecated. GetConstantTensorsByRef is deprecated. m_Weights and m_Bias |
| 62 | /// should be connected to layer as Constant Layers instead." |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 63 | ConstantTensors GetConstantTensorsByRef() override; |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | } // namespace |