blob: baae7f122a32a2eb8d4fcbe4ae1e0ecfc2835eb1 [file] [log] [blame]
surmeh013537c2c2018-05-18 16:31:43 +01001//
Finn Williamsf24effa2020-07-03 10:12:03 +01002// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
surmeh013537c2c2018-05-18 16:31:43 +01004//
5#pragma once
6
7#include "LayerWithParameters.hpp"
8
9namespace armnn
10{
11
James Conroy1f58f032021-04-27 17:13:27 +010012class ScopedTensorHandle;
surmeh013537c2c2018-05-18 16:31:43 +010013
Conor Kennedy35052ae2018-12-21 14:38:36 +000014/// This layer represents a depthwise convolution 2d operation.
surmeh013537c2c2018-05-18 16:31:43 +010015class DepthwiseConvolution2dLayer : public LayerWithParameters<DepthwiseConvolution2dDescriptor>
16{
17public:
Conor Kennedy35052ae2018-12-21 14:38:36 +000018 /// A unique pointer to store Weight values.
Teresa Charlin71b386d2022-09-28 10:25:40 +010019 /// @Note Deprecated. Removal date is 23.02. Weights are stored in ConstantLayers now.
James Conroy1f58f032021-04-27 17:13:27 +010020 std::shared_ptr<ConstTensorHandle> m_Weight;
Conor Kennedy35052ae2018-12-21 14:38:36 +000021 /// A unique pointer to store Bias values.
Teresa Charlin71b386d2022-09-28 10:25:40 +010022 /// @Note Deprecated. Removal date is 23.02. Bias are stored in ConstantLayers now.
James Conroy1f58f032021-04-27 17:13:27 +010023 std::shared_ptr<ConstTensorHandle> m_Bias;
surmeh013537c2c2018-05-18 16:31:43 +010024
Conor Kennedy35052ae2018-12-21 14:38:36 +000025 /// 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 Lamberti94a88d22019-12-10 21:12:59 +000029 virtual std::unique_ptr<IWorkload> CreateWorkload(const IWorkloadFactory& factory) const override;
surmeh013537c2c2018-05-18 16:31:43 +010030
Conor Kennedy35052ae2018-12-21 14:38:36 +000031 /// Creates a dynamically-allocated copy of this layer.
32 /// @param [in] graph The graph into which this layer is being cloned.
surmeh013537c2c2018-05-18 16:31:43 +010033 DepthwiseConvolution2dLayer* Clone(Graph& graph) const override;
34
Conor Kennedy35052ae2018-12-21 14:38:36 +000035 /// Check if the input tensor shape(s)
36 /// will lead to a valid configuration of @ref DepthwiseConvolution2dLayer.
Teresa Charlincdc01492020-06-09 18:00:20 +010037 /// @param [in] shapeInferenceMethod Indicates if output shape shall be overwritten or just validated.
Finn Williamsf24effa2020-07-03 10:12:03 +010038 void ValidateTensorShapesFromInputs() override;
surmeh013537c2c2018-05-18 16:31:43 +010039
Conor Kennedy35052ae2018-12-21 14:38:36 +000040 /// 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.
telsoa01c577f2c2018-08-31 09:22:23 +010044 std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& inputShapes) const override;
45
Finn Williamsb454c5c2021-02-09 15:56:23 +000046 void ExecuteStrategy(IStrategy& strategy) const override;
47
Andre Ghattas23ae2ea2019-08-07 12:18:38 +010048 void SerializeLayerParameters(ParameterStringifyFunction& fn) const override;
49
surmeh013537c2c2018-05-18 16:31:43 +010050protected:
Conor Kennedy35052ae2018-12-21 14:38:36 +000051 /// Constructor to create a DepthwiseConvolution2dLayer.
52 /// @param [in] param DepthwiseConvolution2dDescriptor to configure the depthwise convolution2d.
53 /// @param [in] name Optional name for the layer.
surmeh013537c2c2018-05-18 16:31:43 +010054 DepthwiseConvolution2dLayer(const DepthwiseConvolution2dDescriptor& param, const char* name);
Conor Kennedy35052ae2018-12-21 14:38:36 +000055
56 /// Default destructor
surmeh013537c2c2018-05-18 16:31:43 +010057 ~DepthwiseConvolution2dLayer() = default;
telsoa01c577f2c2018-08-31 09:22:23 +010058
Conor Kennedy35052ae2018-12-21 14:38:36 +000059 /// Retrieve the handles to the constant values stored by the layer.
60 /// @return A vector of the constant tensors stored by this layer.
Cathal Corbett06902652022-04-14 17:55:11 +010061 /// @Note Deprecated. GetConstantTensorsByRef is deprecated. m_Weights and m_Bias
62 /// should be connected to layer as Constant Layers instead."
telsoa01c577f2c2018-08-31 09:22:23 +010063 ConstantTensors GetConstantTensorsByRef() override;
surmeh013537c2c2018-05-18 16:31:43 +010064};
65
66} // namespace