blob: 02ae05f83b446f59bd5aeff17ddc78922191b6a0 [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 convolution 2d operation.
surmeh013537c2c2018-05-18 16:31:43 +010015class Convolution2dLayer : public LayerWithParameters<Convolution2dDescriptor>
16{
17public:
Andre Ghattas23ae2ea2019-08-07 12:18:38 +010018
Conor Kennedy35052ae2018-12-21 14:38:36 +000019 /// A unique pointer to store Weight values.
Teresa Charlin71b386d2022-09-28 10:25:40 +010020 /// @Note: Deprecated. Removal date is 23.02. Weights are stored in ConstantLayers now.
James Conroy1f58f032021-04-27 17:13:27 +010021 std::shared_ptr<ConstTensorHandle> m_Weight;
Conor Kennedy35052ae2018-12-21 14:38:36 +000022 /// A unique pointer to store Bias values.
Teresa Charlin71b386d2022-09-28 10:25:40 +010023 /// @Note: Deprecated. Removal date is 23.02. Bias are stored in ConstantLayers now.
James Conroy1f58f032021-04-27 17:13:27 +010024 std::shared_ptr<ConstTensorHandle> m_Bias;
surmeh013537c2c2018-05-18 16:31:43 +010025
Conor Kennedy35052ae2018-12-21 14:38:36 +000026 /// Makes a workload for the Convolution2d type.
27 /// @param [in] graph The graph where this layer can be found.
28 /// @param [in] factory The workload factory which will create the workload.
29 /// @return A pointer to the created workload, or nullptr if not created.
Derek Lamberti94a88d22019-12-10 21:12:59 +000030 virtual std::unique_ptr<IWorkload> CreateWorkload(const IWorkloadFactory& factory) const override;
surmeh013537c2c2018-05-18 16:31:43 +010031
Conor Kennedy35052ae2018-12-21 14:38:36 +000032 /// Creates a dynamically-allocated copy of this layer.
33 /// @param [in] graph The graph into which this layer is being cloned.
surmeh013537c2c2018-05-18 16:31:43 +010034 Convolution2dLayer* Clone(Graph& graph) const override;
35
Conor Kennedy35052ae2018-12-21 14:38:36 +000036 /// Check if the input tensor shape(s)
37 /// will lead to a valid configuration of @ref Convolution2dLayer.
Teresa Charlincdc01492020-06-09 18:00:20 +010038 /// @param [in] shapeInferenceMethod Indicates if output shape shall be overwritten or just validated.
Finn Williamsf24effa2020-07-03 10:12:03 +010039 void ValidateTensorShapesFromInputs() override;
surmeh013537c2c2018-05-18 16:31:43 +010040
Conor Kennedy35052ae2018-12-21 14:38:36 +000041 /// By default returns inputShapes if the number of inputs are equal to number of outputs,
42 /// otherwise infers the output shapes from given input shapes and layer properties.
43 /// @param [in] inputShapes The input shapes layer has.
44 /// @return A vector to the inferred output shape.
telsoa01c577f2c2018-08-31 09:22:23 +010045 std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& inputShapes) const override;
46
Finn Williamsb454c5c2021-02-09 15:56:23 +000047 void ExecuteStrategy(IStrategy& strategy) const override;
48
Andre Ghattas23ae2ea2019-08-07 12:18:38 +010049 void SerializeLayerParameters(ParameterStringifyFunction& fn) const override;
50
surmeh013537c2c2018-05-18 16:31:43 +010051protected:
Conor Kennedy35052ae2018-12-21 14:38:36 +000052 /// Constructor to create a Convolution2dLayer.
53 /// @param [in] param Convolution2dDescriptor to configure the convolution2d operation.
54 /// @param [in] name Optional name for the layer.
surmeh013537c2c2018-05-18 16:31:43 +010055 Convolution2dLayer(const Convolution2dDescriptor& param, const char* name);
Conor Kennedy35052ae2018-12-21 14:38:36 +000056
57 /// Default destructor
surmeh013537c2c2018-05-18 16:31:43 +010058 ~Convolution2dLayer() = default;
telsoa01c577f2c2018-08-31 09:22:23 +010059
Keith Davisb4dd5cc2022-04-07 11:32:00 +010060 /// @Note Deprecated. GetConstantTensorsByRef is deprecated. m_Weights and m_Bias
61 /// should be connected to layer as Constant Layers instead."
telsoa01c577f2c2018-08-31 09:22:23 +010062 ConstantTensors GetConstantTensorsByRef() override;
surmeh013537c2c2018-05-18 16:31:43 +010063};
64
65} // namespace