telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | #pragma once |
| 6 | |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 7 | #include <armnn/Deprecated.hpp> |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [diff] [blame] | 8 | #include <armnn/DescriptorsFwd.hpp> |
jimfly01 | e9e7bfd | 2019-01-24 22:29:33 +0000 | [diff] [blame] | 9 | #include <armnn/ILayerVisitor.hpp> |
Matthew Bentham | 313e1c8 | 2019-03-25 17:37:47 +0000 | [diff] [blame] | 10 | #include <armnn/NetworkFwd.hpp> |
| 11 | #include <armnn/Optional.hpp> |
| 12 | #include <armnn/TensorFwd.hpp> |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [diff] [blame] | 13 | #include <armnn/Types.hpp> |
Matteo Martincigh | fc598e1 | 2019-05-14 10:36:13 +0100 | [diff] [blame] | 14 | #include <armnn/Deprecated.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 15 | |
| 16 | #include <memory> |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 17 | #include <vector> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 18 | |
| 19 | namespace armnn |
| 20 | { |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 21 | /// @brief An input connection slot for a layer. |
| 22 | /// The input slot can be connected to an output slot of the preceding layer in the graph. |
| 23 | /// Only one connection to the input slot is allowed. |
| 24 | class IInputSlot |
| 25 | { |
| 26 | public: |
| 27 | virtual const IOutputSlot* GetConnection() const = 0; |
| 28 | virtual IOutputSlot* GetConnection() = 0; |
| 29 | |
| 30 | protected: |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 31 | /// Not user deletable. |
| 32 | ~IInputSlot() {} |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | /// @brief An output connection slot for a layer. |
| 36 | /// The output slot may be connected to 1 or more input slots of subsequent layers in the graph. |
| 37 | class IOutputSlot |
| 38 | { |
| 39 | public: |
| 40 | virtual unsigned int GetNumConnections() const = 0; |
| 41 | virtual const IInputSlot* GetConnection(unsigned int index) const = 0; |
| 42 | virtual IInputSlot* GetConnection(unsigned int index) = 0; |
| 43 | |
| 44 | virtual void SetTensorInfo(const TensorInfo& tensorInfo) = 0; |
| 45 | virtual const TensorInfo& GetTensorInfo() const = 0; |
| 46 | virtual bool IsTensorInfoSet() const = 0; |
| 47 | |
| 48 | virtual int Connect(IInputSlot& destination) = 0; |
| 49 | virtual void Disconnect(IInputSlot& slot) = 0; |
| 50 | |
Mike Kelly | 8c1701a | 2019-02-11 17:01:27 +0000 | [diff] [blame] | 51 | virtual unsigned int CalculateIndexOnOwner() const = 0; |
| 52 | |
| 53 | virtual LayerGuid GetOwningLayerGuid() const = 0; |
| 54 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 55 | protected: |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 56 | /// Not user deletable. |
| 57 | ~IOutputSlot() {} |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | /// @brief Interface for a layer that is connectable to other layers via InputSlots and OutputSlots. |
| 61 | class IConnectableLayer |
| 62 | { |
| 63 | public: |
| 64 | virtual const char* GetName() const = 0; |
| 65 | |
| 66 | virtual unsigned int GetNumInputSlots() const = 0; |
| 67 | virtual unsigned int GetNumOutputSlots() const = 0; |
| 68 | |
| 69 | virtual const IInputSlot& GetInputSlot(unsigned int index) const = 0; |
| 70 | virtual IInputSlot& GetInputSlot(unsigned int index) = 0; |
| 71 | |
| 72 | virtual const IOutputSlot& GetOutputSlot(unsigned int index) const = 0; |
| 73 | virtual IOutputSlot& GetOutputSlot(unsigned int index) = 0; |
| 74 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 75 | virtual std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& inputShapes) const = 0; |
| 76 | |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 77 | virtual LayerGuid GetGuid() const = 0; |
jimfly01 | e9e7bfd | 2019-01-24 22:29:33 +0000 | [diff] [blame] | 78 | |
| 79 | virtual void Accept(ILayerVisitor& visitor) const = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 80 | protected: |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 81 | /// Objects are not deletable via the handle |
| 82 | ~IConnectableLayer() {} |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | using INetworkPtr = std::unique_ptr<INetwork, void(*)(INetwork* network)>; |
| 86 | |
| 87 | /// Main network class which provides the interface for building up a neural network. |
| 88 | /// This object is subsequently required by the IRuntime::Load() method. |
| 89 | class INetwork |
| 90 | { |
| 91 | public: |
| 92 | static INetwork* CreateRaw(); |
| 93 | static INetworkPtr Create(); |
| 94 | static void Destroy(INetwork* network); |
| 95 | |
| 96 | virtual Status PrintGraph() = 0; |
| 97 | |
Jan Eilers | 99d9d4a | 2019-11-06 10:02:16 +0000 | [diff] [blame] | 98 | virtual profiling::ProfilingGuid GetGuid() const = 0; |
| 99 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 100 | /// Adds an input layer to the network. |
| 101 | /// @param id - User generated id to uniquely identify a particular input. The same id needs to be specified. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 102 | /// when passing the inputs to the IRuntime::EnqueueWorkload() function. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 103 | /// @param name - Optional name for the layer. |
| 104 | /// @return - Interface for configuring the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 105 | virtual IConnectableLayer* AddInputLayer(LayerBindingId id, const char* name = nullptr) = 0; |
| 106 | |
Nikhil Raj | ee391d5 | 2019-09-05 17:50:44 +0100 | [diff] [blame] | 107 | /// Adds an ArgMinMax layer to the network. |
| 108 | /// @param desc - Parameters for the L2 normalization operation. |
| 109 | /// @param name - Optional name for the layer. |
| 110 | /// @return - Interface for configuring the layer. |
| 111 | virtual IConnectableLayer* AddArgMinMaxLayer(const ArgMinMaxDescriptor& desc, |
| 112 | const char* name = nullptr) = 0; |
| 113 | |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 114 | /// Add a Comparison layer to the network. |
| 115 | /// @param name - Optional name for the layer. |
| 116 | /// @param desc - Descriptor for the comparison operation. |
| 117 | /// @ return - Interface for configuring the layer. |
| 118 | virtual IConnectableLayer* AddComparisonLayer(const ComparisonDescriptor& comparisonDescriptor, |
| 119 | const char* name = nullptr) = 0; |
| 120 | |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 121 | /// Adds a concatenation layer to the network. |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 122 | /// @param concatDescriptor - ConcatDescriptor (synonym for OriginsDescriptor) to configure the concatenation |
| 123 | /// process. Number of Views must be equal to the number of inputs, and their order |
| 124 | /// must match - e.g. first view corresponds to the first input, second view to the |
| 125 | /// second input, etc.... |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 126 | /// @param name - Optional name for the layer. |
| 127 | /// @return - Interface for configuring the layer. |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 128 | virtual IConnectableLayer* AddConcatLayer(const ConcatDescriptor& concatDescriptor, |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 129 | const char* name = nullptr) = 0; |
| 130 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 131 | /// Adds a 2D convolution layer to the network. |
| 132 | /// @param convolution2dDescriptor - Description of the 2D convolution layer. |
| 133 | /// @param weights - Tensor for the weights data. |
Aron Virginas-Tar | ad40270 | 2019-02-22 17:03:44 +0000 | [diff] [blame] | 134 | /// @param biases - Optional tensor for the bias data. If specified, must match the output tensor shape. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 135 | /// @param name - Optional name for the layer. |
| 136 | /// @return - Interface for configuring the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 137 | virtual IConnectableLayer* AddConvolution2dLayer(const Convolution2dDescriptor& convolution2dDescriptor, |
Aron Virginas-Tar | ad40270 | 2019-02-22 17:03:44 +0000 | [diff] [blame] | 138 | const ConstTensor& weights, |
| 139 | const Optional<ConstTensor>& biases, |
| 140 | const char* name = nullptr) = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 141 | |
Matteo Martincigh | fc598e1 | 2019-05-14 10:36:13 +0100 | [diff] [blame] | 142 | ARMNN_DEPRECATED_MSG("This AddConvolution2dLayer overload is deprecated") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 143 | virtual IConnectableLayer* AddConvolution2dLayer(const Convolution2dDescriptor& convolution2dDescriptor, |
Aron Virginas-Tar | ad40270 | 2019-02-22 17:03:44 +0000 | [diff] [blame] | 144 | const ConstTensor& weights, |
| 145 | const char* name = nullptr) = 0; |
| 146 | |
Matteo Martincigh | fc598e1 | 2019-05-14 10:36:13 +0100 | [diff] [blame] | 147 | ARMNN_DEPRECATED_MSG("This AddConvolution2dLayer overload is deprecated") |
Aron Virginas-Tar | ad40270 | 2019-02-22 17:03:44 +0000 | [diff] [blame] | 148 | virtual IConnectableLayer* AddConvolution2dLayer(const Convolution2dDescriptor& convolution2dDescriptor, |
| 149 | const ConstTensor& weights, |
| 150 | const ConstTensor& biases, |
| 151 | const char* name = nullptr) = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 152 | |
Aron Virginas-Tar | dd6247f | 2019-09-19 14:31:17 +0100 | [diff] [blame] | 153 | /// Adds a depth to space layer to the network. |
| 154 | /// @param depthToSpaceDescriptor - Parameters for the depth to space operation. |
| 155 | /// @param name - Optional name for the layer. |
| 156 | /// @return - Interface for configuring the layer. |
| 157 | virtual IConnectableLayer* AddDepthToSpaceLayer(const DepthToSpaceDescriptor& depthToSpaceDescriptor, |
| 158 | const char* name = nullptr) = 0; |
| 159 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 160 | /// Adds a 2D depthwise convolution layer to the network. |
| 161 | /// @param convolution2dDescriptor - Description of the 2D depthwise convolution layer. |
Rob Hughes | 144c01b | 2018-11-21 13:34:24 +0000 | [diff] [blame] | 162 | /// @param weights - Tensor for the weights. Expected format: [channelMultiplier, inputChannels, height, width]. |
Aron Virginas-Tar | ad40270 | 2019-02-22 17:03:44 +0000 | [diff] [blame] | 163 | /// @param biases Optional tensor for the bias data. If specified, must match the output tensor shape. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 164 | /// @param name - Optional name for the layer. |
| 165 | /// @return - Interface for configuring the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 166 | virtual IConnectableLayer* AddDepthwiseConvolution2dLayer( |
| 167 | const DepthwiseConvolution2dDescriptor& convolution2dDescriptor, |
| 168 | const ConstTensor& weights, |
Aron Virginas-Tar | ad40270 | 2019-02-22 17:03:44 +0000 | [diff] [blame] | 169 | const Optional<ConstTensor>& biases, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 170 | const char* name = nullptr) = 0; |
| 171 | |
Matteo Martincigh | fc598e1 | 2019-05-14 10:36:13 +0100 | [diff] [blame] | 172 | ARMNN_DEPRECATED_MSG("This AddDepthwiseConvolution2dLayer overload is deprecated") |
Aron Virginas-Tar | ad40270 | 2019-02-22 17:03:44 +0000 | [diff] [blame] | 173 | virtual IConnectableLayer* AddDepthwiseConvolution2dLayer( |
| 174 | const DepthwiseConvolution2dDescriptor& convolution2dDescriptor, |
| 175 | const ConstTensor& weights, |
| 176 | const char* name = nullptr) = 0; |
| 177 | |
Matteo Martincigh | fc598e1 | 2019-05-14 10:36:13 +0100 | [diff] [blame] | 178 | ARMNN_DEPRECATED_MSG("This AddDepthwiseConvolution2dLayer overload is deprecated") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 179 | virtual IConnectableLayer* AddDepthwiseConvolution2dLayer( |
| 180 | const DepthwiseConvolution2dDescriptor& convolution2dDescriptor, |
| 181 | const ConstTensor& weights, |
| 182 | const ConstTensor& biases, |
| 183 | const char* name = nullptr) = 0; |
| 184 | |
Nattapat Chaimanowong | e4294fd | 2019-03-28 09:56:53 +0000 | [diff] [blame] | 185 | /// Adds a Dequantize layer to the network. |
| 186 | /// @return - Interface for configuring the layer. |
| 187 | virtual IConnectableLayer* AddDequantizeLayer(const char* name = nullptr) = 0; |
| 188 | |
Narumol Prangnawarat | 94dd5d8 | 2019-01-23 18:06:26 +0000 | [diff] [blame] | 189 | /// Adds a Detection PostProcess layer to the network. |
| 190 | /// @param descriptor - Description of the Detection PostProcess layer. |
Narumol Prangnawarat | 6d302bf | 2019-02-04 11:46:26 +0000 | [diff] [blame] | 191 | /// @param anchors - Tensor for anchors. |
Narumol Prangnawarat | 94dd5d8 | 2019-01-23 18:06:26 +0000 | [diff] [blame] | 192 | /// @param name - Optional name for the layer. |
| 193 | /// @return - Interface for configuring the layer. |
| 194 | virtual IConnectableLayer* AddDetectionPostProcessLayer( |
Narumol Prangnawarat | 6d302bf | 2019-02-04 11:46:26 +0000 | [diff] [blame] | 195 | const DetectionPostProcessDescriptor& descriptor, |
| 196 | const ConstTensor& anchors, |
| 197 | const char* name = nullptr) = 0; |
Narumol Prangnawarat | 94dd5d8 | 2019-01-23 18:06:26 +0000 | [diff] [blame] | 198 | |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 199 | /// Add an ElementwiseUnary layer to the network. |
| 200 | /// @param name - Optional name for the layer. |
| 201 | /// @param desc - Descriptor for the elementwiseUnary operation. |
| 202 | /// @ return - Interface for configuring the layer. |
| 203 | virtual IConnectableLayer* AddElementwiseUnaryLayer(const ElementwiseUnaryDescriptor& elementwiseUnaryDescriptor, |
| 204 | const char* name = nullptr) = 0; |
| 205 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 206 | /// Adds a fully connected layer to the network. |
| 207 | /// @param fullyConnectedDescriptor - Description of the fully connected layer. |
| 208 | /// @param weights - Tensor for the weights data. |
Aron Virginas-Tar | ad40270 | 2019-02-22 17:03:44 +0000 | [diff] [blame] | 209 | /// @param biases - Optional tensor for the bias data. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 210 | /// @param name - Optional name for the layer. |
| 211 | /// @return - Interface for configuring the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 212 | virtual IConnectableLayer* AddFullyConnectedLayer(const FullyConnectedDescriptor& fullyConnectedDescriptor, |
Aron Virginas-Tar | ad40270 | 2019-02-22 17:03:44 +0000 | [diff] [blame] | 213 | const ConstTensor& weights, |
| 214 | const Optional<ConstTensor>& biases, |
| 215 | const char* name = nullptr) = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 216 | |
Matteo Martincigh | fc598e1 | 2019-05-14 10:36:13 +0100 | [diff] [blame] | 217 | ARMNN_DEPRECATED_MSG("This AddFullyConnectedLayer overload is deprecated") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 218 | virtual IConnectableLayer* AddFullyConnectedLayer(const FullyConnectedDescriptor& fullyConnectedDescriptor, |
Aron Virginas-Tar | ad40270 | 2019-02-22 17:03:44 +0000 | [diff] [blame] | 219 | const ConstTensor& weights, |
| 220 | const char* name = nullptr) = 0; |
| 221 | |
Matteo Martincigh | fc598e1 | 2019-05-14 10:36:13 +0100 | [diff] [blame] | 222 | ARMNN_DEPRECATED_MSG("This AddFullyConnectedLayer overload is deprecated") |
Aron Virginas-Tar | ad40270 | 2019-02-22 17:03:44 +0000 | [diff] [blame] | 223 | virtual IConnectableLayer* AddFullyConnectedLayer(const FullyConnectedDescriptor& fullyConnectedDescriptor, |
| 224 | const ConstTensor& weights, |
| 225 | const ConstTensor& biases, |
| 226 | const char* name = nullptr) = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 227 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 228 | /// Adds a permute layer to the network. |
| 229 | /// @param permuteDescriptor - PermuteDescriptor to configure the permute. |
| 230 | /// @param name - Optional name for the layer. |
| 231 | /// @return - Interface for configuring the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 232 | virtual IConnectableLayer* AddPermuteLayer(const PermuteDescriptor& permuteDescriptor, |
| 233 | const char* name = nullptr) = 0; |
| 234 | |
Éanna Ó Catháin | 4e1e136 | 2018-11-12 11:36:34 +0000 | [diff] [blame] | 235 | /// Adds a batch to space ND layer to the network. |
| 236 | /// @param batchToSpaceNdDescriptor - Description of the layer. |
| 237 | /// @param name - Optional name for the layer. |
| 238 | /// @return - Interface for configuring the layer. |
| 239 | virtual IConnectableLayer* AddBatchToSpaceNdLayer(const BatchToSpaceNdDescriptor& batchToSpaceNdDescriptor, |
| 240 | const char* name = nullptr) = 0; |
| 241 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 242 | /// Adds a pooling layer to the network. |
| 243 | /// @param pooling2dDescriptor - Pooling2dDescriptor to configure the pooling. |
| 244 | /// @param name - Optional name for the layer. |
| 245 | /// @return - Interface for configuring the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 246 | virtual IConnectableLayer* AddPooling2dLayer(const Pooling2dDescriptor& pooling2dDescriptor, |
| 247 | const char* name = nullptr) = 0; |
| 248 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 249 | /// Adds an activation layer to the network. |
| 250 | /// @param activationDescriptor - ActivationDescriptor to configure the activation. |
| 251 | /// @param name - Optional name for the layer. |
| 252 | /// @return - Interface for configuring the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 253 | virtual IConnectableLayer* AddActivationLayer(const ActivationDescriptor& activationDescriptor, |
| 254 | const char* name = nullptr) = 0; |
| 255 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 256 | /// Adds a normalization layer to the network. |
| 257 | /// @param normalizationDescriptor - NormalizationDescriptor to configure the normalization. |
| 258 | /// @param name - Optional name for the layer. |
| 259 | /// @return - Interface for configuring the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 260 | virtual IConnectableLayer* AddNormalizationLayer(const NormalizationDescriptor& normalizationDescriptor, |
| 261 | const char* name = nullptr) = 0; |
| 262 | |
Aron Virginas-Tar | 636ab40 | 2019-09-16 14:27:45 +0100 | [diff] [blame] | 263 | /// Adds a slice layer to the network. |
| 264 | /// @param sliceDescriptor - SliceDescriptor to configure the slice operation. |
| 265 | /// @param name - Optional name for the layer. |
| 266 | /// @return - Interface for configuring the layer. |
| 267 | virtual IConnectableLayer* AddSliceLayer(const SliceDescriptor& sliceDescriptor, const char* name = nullptr) = 0; |
| 268 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 269 | /// Adds a softmax layer to the network. |
David Monahan | b855470 | 2019-04-25 16:03:38 +0100 | [diff] [blame] | 270 | /// If the data type is QAsymm8, then the output quantization parameters |
| 271 | /// must have a scale of 1/256 and an offset of 0 |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 272 | /// @param softmaxDescriptor - SoftmaxDescriptor to configure the softmax. |
| 273 | /// @param name - Optional name for the layer. |
| 274 | /// @return - Interface for configuring the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 275 | virtual IConnectableLayer* AddSoftmaxLayer(const SoftmaxDescriptor& softmaxDescriptor, |
| 276 | const char* name = nullptr) = 0; |
| 277 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 278 | /// Adds a splitter layer to the network. |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 279 | /// @param splitterDescriptor - ViewsDescriptor to configure the splitting process. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 280 | /// Number of Views must be equal to the number of outputs, |
| 281 | /// and their order must match - e.g. first view corresponds to |
| 282 | /// the first output, second view to the second output, etc.... |
| 283 | /// @param name - Optional name for the layer. |
| 284 | /// @return - Interface for configuring the layer. |
Aron Virginas-Tar | 636ab40 | 2019-09-16 14:27:45 +0100 | [diff] [blame] | 285 | virtual IConnectableLayer* AddSplitterLayer(const ViewsDescriptor& splitterDescriptor, |
| 286 | const char* name = nullptr) = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 287 | |
Nattapat Chaimanowong | 1f88630 | 2019-04-05 13:37:19 +0100 | [diff] [blame] | 288 | /// Adds a merge layer to the network. |
| 289 | /// @param name - Optional name for the layer. |
| 290 | /// @return - Interface for configuring the layer. |
| 291 | virtual IConnectableLayer* AddMergeLayer(const char* name = nullptr) = 0; |
| 292 | |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 293 | /// Adds a concat layer to the network. |
| 294 | /// @param mergerDescriptor - MergerDescriptor (synonym for OriginsDescriptor) to configure the concatenation |
| 295 | /// process. Number of Views must be equal to the number of inputs, and their order |
| 296 | /// must match - e.g. first view corresponds to the first input, second view to the |
| 297 | /// second input, etc.... |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 298 | /// @param name - Optional name for the layer. |
| 299 | /// @return - Interface for configuring the layer. |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 300 | ARMNN_DEPRECATED_MSG("Use AddConcatLayer instead") |
Jim Flynn | e242f2d | 2019-05-22 14:24:13 +0100 | [diff] [blame] | 301 | virtual IConnectableLayer* AddMergerLayer(const MergerDescriptor& mergerDescriptor, |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 302 | const char* name = nullptr) = 0; |
| 303 | |
Kevin May | 868eb14 | 2019-09-04 17:29:31 +0100 | [diff] [blame] | 304 | /// Add absolute layer to the network. |
| 305 | /// @param name - Optional name for the layer. |
| 306 | /// @ return - Interface for configuring the layer. |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 307 | ARMNN_DEPRECATED_MSG("Use AddElementwiseUnaryLayer instead") |
Kevin May | 868eb14 | 2019-09-04 17:29:31 +0100 | [diff] [blame] | 308 | virtual IConnectableLayer* AddAbsLayer(const char* name = nullptr) = 0; |
| 309 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 310 | /// Adds an addition layer to the network. |
| 311 | /// @param name - Optional name for the layer. |
| 312 | /// @return - Interface for configuring the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 313 | virtual IConnectableLayer* AddAdditionLayer(const char* name = nullptr) = 0; |
| 314 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 315 | /// Adds a multiplication layer to the network. |
| 316 | /// @param name - Optional name for the layer. |
| 317 | /// @return - Interface for configuring the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 318 | virtual IConnectableLayer* AddMultiplicationLayer(const char* name = nullptr) = 0; |
| 319 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 320 | /// Adds a batch normalization layer to the network. |
| 321 | /// @param mean - Pre-calculated mean for each channel. |
| 322 | /// @param variance - Pre-calculated variance for each channel. |
| 323 | /// @param beta - Per-channel additive factor. |
| 324 | /// @param gamma - Per-channel multiplicative factor. |
| 325 | /// @return - Interface for configuring the layer. |
| 326 | /// @param name - Optional name for the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 327 | virtual IConnectableLayer* AddBatchNormalizationLayer(const BatchNormalizationDescriptor& desc, |
| 328 | const ConstTensor& mean, |
| 329 | const ConstTensor& variance, |
| 330 | const ConstTensor& beta, |
| 331 | const ConstTensor& gamma, |
| 332 | const char* name = nullptr) = 0; |
| 333 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 334 | /// Adds a resize bilinear layer to the network. |
| 335 | /// @param resizeDesc - Parameters for the resize operation. |
| 336 | /// @param name - Optional name for the layer. |
| 337 | /// @return - Interface for configuring the layer. |
Aron Virginas-Tar | 169d2f1 | 2019-07-01 19:01:44 +0100 | [diff] [blame] | 338 | ARMNN_DEPRECATED_MSG("Use AddResizeLayer instead") |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 339 | virtual IConnectableLayer* AddResizeBilinearLayer(const ResizeBilinearDescriptor& resizeDesc, |
| 340 | const char* name = nullptr) = 0; |
| 341 | |
Teresa Charlin | a9075df | 2019-06-27 15:41:57 +0100 | [diff] [blame] | 342 | /// Adds a resize layer to the network. |
| 343 | /// @param resizeDescriptor - Parameters for the resize operation. |
| 344 | /// @param name - Optional name for the layer. |
| 345 | /// @return - Interface for configuring the layer. |
| 346 | virtual IConnectableLayer* AddResizeLayer(const ResizeDescriptor& resizeDescriptor, |
| 347 | const char* name = nullptr) = 0; |
| 348 | |
Kevin May | ce5045a | 2019-10-02 14:07:47 +0100 | [diff] [blame] | 349 | /// Adds an instance normalization layer to the network. |
| 350 | /// @param desc - Parameters for the instance normalization operation. |
| 351 | /// @param name - Optional name for the layer. |
| 352 | /// @return - Interface for configuring the layer. |
| 353 | virtual IConnectableLayer* AddInstanceNormalizationLayer(const InstanceNormalizationDescriptor& desc, |
| 354 | const char* name = nullptr) = 0; |
| 355 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 356 | /// Adds an L2 normalization layer to the network. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 357 | /// Normalization is performed along dimension 1, but requires a 4d input. |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 358 | /// @param desc - Parameters for the L2 normalization operation. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 359 | /// @param name - Optional name for the layer. |
| 360 | /// @return - Interface for configuring the layer. |
Matteo Martincigh | bcd3c85 | 2018-09-28 14:14:12 +0100 | [diff] [blame] | 361 | virtual IConnectableLayer* AddL2NormalizationLayer(const L2NormalizationDescriptor& desc, |
| 362 | const char* name = nullptr) = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 363 | |
Aron Virginas-Tar | f982dea | 2019-10-11 14:07:53 +0100 | [diff] [blame] | 364 | /// Adds a log softmax layer to the network. |
| 365 | /// @param logSoftmaxDescriptor - LogSoftmaxDescriptor to configure the log softmax. |
| 366 | /// @param name - Optional name for the layer. |
| 367 | /// @return - Interface for configuring the layer. |
| 368 | virtual IConnectableLayer* AddLogSoftmaxLayer(const LogSoftmaxDescriptor& logSoftmaxDescriptor, |
| 369 | const char* name = nullptr) = 0; |
| 370 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 371 | /// Adds a layer with no inputs and a single output, which always corresponds to |
| 372 | /// the passed in constant tensor. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 373 | /// @param input - Tensor to be provided as the only output of the layer. The layer will maintain |
| 374 | /// its own copy of the tensor data, meaning the memory referenced by @a input can |
| 375 | /// be freed or reused after this function is called. |
| 376 | /// @param name - Optional name for the layer. |
| 377 | /// @return - Interface for configuring the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 378 | virtual IConnectableLayer* AddConstantLayer(const ConstTensor& input, |
Matteo Martincigh | 5b2159e | 2019-02-11 13:24:38 +0000 | [diff] [blame] | 379 | const char* name = nullptr) = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 380 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 381 | /// Adds a reshape layer to the network. |
| 382 | /// @param reshapeDescriptor - Parameters for the reshape operation. |
| 383 | /// @param name - Optional name for the layer. |
| 384 | /// @return - Interface for configuring the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 385 | virtual IConnectableLayer* AddReshapeLayer(const ReshapeDescriptor& reshapeDescriptor, |
| 386 | const char* name = nullptr) = 0; |
| 387 | |
Nattapat Chaimanowong | 207ef9a | 2018-11-02 10:57:25 +0000 | [diff] [blame] | 388 | /// Adds a space to batch layer to the network. |
| 389 | /// @param spaceToBatchNdDescriptor - Parameters for the space to batch operation. |
| 390 | /// @param name - Optional name for the layer. |
| 391 | /// @return - Interface for configuring the layer. |
| 392 | virtual IConnectableLayer* AddSpaceToBatchNdLayer(const SpaceToBatchNdDescriptor& spaceToBatchNdDescriptor, |
| 393 | const char* name = nullptr) = 0; |
| 394 | |
Aron Virginas-Tar | 972af15 | 2019-06-11 14:14:03 +0100 | [diff] [blame] | 395 | /// Adds a space to depth layer to the network. |
| 396 | /// @param spaceToDepthDescriptor - Parameters for the space to depth operation. |
| 397 | /// @param name - Optional name for the layer. |
| 398 | /// @return - Interface for configuring the layer. |
| 399 | virtual IConnectableLayer* AddSpaceToDepthLayer(const SpaceToDepthDescriptor& spaceToDepthDescriptor, |
| 400 | const char* name = nullptr) = 0; |
| 401 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 402 | /// Adds a floor layer to the network. |
| 403 | /// @param name - Optional name for the layer. |
| 404 | /// @return - Interface for configuring the layer. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 405 | virtual IConnectableLayer* AddFloorLayer(const char* name = nullptr) = 0; |
| 406 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 407 | /// Adds an output layer to the network. |
| 408 | /// @param id - User generated id to uniquely identify a particular output. The same id needs to be specified |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 409 | /// when passing the outputs to the IRuntime::EnqueueWorkload() function. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 410 | /// @param name - Optional name for the layer. |
| 411 | /// @return - Interface for configuring the layer. |
| 412 | virtual IConnectableLayer* AddOutputLayer(LayerBindingId id, const char* name = nullptr) = 0; |
| 413 | |
| 414 | /// Add a Lstm layer to the network |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 415 | /// @param descriptor - Parameters for the Lstm operation |
| 416 | /// @param params - Weights and biases for the LSTM cell |
| 417 | /// @param name - Optional name for the layer |
| 418 | /// @return - Interface for configuring the layer. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 419 | virtual IConnectableLayer* AddLstmLayer(const LstmDescriptor& descriptor, |
| 420 | const LstmInputParams& params, |
| 421 | const char* name = nullptr) = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 422 | |
Francis Murtagh | e7a86a4 | 2018-08-29 12:42:10 +0100 | [diff] [blame] | 423 | /// Adds a division layer to the network. |
| 424 | /// @param name - Optional name for the layer. |
| 425 | /// @return - Interface for configuring the layer. |
| 426 | virtual IConnectableLayer* AddDivisionLayer(const char* name = nullptr) = 0; |
| 427 | |
David Beck | 1952622 | 2018-09-12 16:00:08 +0100 | [diff] [blame] | 428 | /// Adds a subtraction layer to the network. |
| 429 | /// @param name - Optional name for the layer. |
| 430 | /// @return - Interface for configuring the layer. |
| 431 | virtual IConnectableLayer* AddSubtractionLayer(const char* name = nullptr) = 0; |
| 432 | |
Nattapat Chaimanowong | 5a4304a | 2018-11-28 10:44:37 +0000 | [diff] [blame] | 433 | /// Add a Maximum layer to the network. |
| 434 | /// @param name - Optional name for the layer. |
| 435 | /// @ return - Interface for configuring the layer. |
| 436 | virtual IConnectableLayer* AddMaximumLayer(const char* name = nullptr) = 0; |
| 437 | |
narpra01 | 32b9046 | 2018-09-13 11:07:48 +0100 | [diff] [blame] | 438 | /// Add a Mean layer to the network. |
| 439 | /// @param meanDescriptor - Parameters for the mean operation. |
| 440 | /// @param name - Optional name for the layer. |
| 441 | /// @ return - Interface for configuring the layer. |
| 442 | virtual IConnectableLayer* AddMeanLayer(const MeanDescriptor& meanDescriptor, const char* name = nullptr) = 0; |
| 443 | |
Mohamed Nour Abouelseoud | 5662c20 | 2018-09-24 13:30:09 +0100 | [diff] [blame] | 444 | /// Adds a fully pad layer to the network. |
| 445 | /// @param paddings - n by 2 tensor, where n is the rank of the input tensor, |
| 446 | /// such that paddings[i,0] indicates the amount of padding to add in front of dimonsion i, and |
| 447 | /// paddings[i,1] indicates the amount of padding to add after the end of dimension i |
| 448 | /// @param name - Optional name for the layer. |
| 449 | /// @return - Interface for configuring the layer. |
| 450 | virtual IConnectableLayer* AddPadLayer(const PadDescriptor& padDescriptor, |
| 451 | const char* name = nullptr) = 0; |
| 452 | |
Derek Lamberti | a9cca6a | 2019-03-25 15:41:58 +0000 | [diff] [blame] | 453 | /// Add a quantize layer to the network |
| 454 | ///@param name - Optional name for the layer. |
| 455 | /// @return - Interface for configuring the layer. |
| 456 | virtual IConnectableLayer* AddQuantizeLayer(const char* name = nullptr) = 0; |
| 457 | |
Conor Kennedy | 430b5d8 | 2018-11-14 15:28:28 +0000 | [diff] [blame] | 458 | /// Adds a strided slice layer to the network. |
| 459 | /// @param StridedSliceDescriptor - Parameters for the strided slice operation. |
| 460 | /// @param name - Optional name for the layer. |
| 461 | /// @return - Interface for configuring the layer. |
| 462 | virtual IConnectableLayer* AddStridedSliceLayer(const StridedSliceDescriptor& stridedSliceDescriptor, |
| 463 | const char* name = nullptr) = 0; |
| 464 | |
kevmay01 | 9053969 | 2018-11-29 08:40:19 +0000 | [diff] [blame] | 465 | /// Add a Minimum layer to the network. |
| 466 | /// @param name - Optional name for the layer. |
| 467 | /// @ return - Interface for configuring the layer. |
| 468 | virtual IConnectableLayer* AddMinimumLayer(const char* name = nullptr) = 0; |
| 469 | |
Matteo Martincigh | 59a950c | 2018-12-13 12:48:25 +0000 | [diff] [blame] | 470 | /// Add a Greater layer to the network. |
| 471 | /// @param name - Optional name for the layer. |
| 472 | /// @ return - Interface for configuring the layer. |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 473 | ARMNN_DEPRECATED_MSG("Use AddComparisonLayer instead") |
Matteo Martincigh | 59a950c | 2018-12-13 12:48:25 +0000 | [diff] [blame] | 474 | virtual IConnectableLayer* AddGreaterLayer(const char* name = nullptr) = 0; |
| 475 | |
FrancisMurtagh | 2099595 | 2018-12-17 12:11:36 +0000 | [diff] [blame] | 476 | /// Add a Equal layer to the network. |
| 477 | /// @param name - Optional name for the layer. |
| 478 | /// @ return - Interface for configuring the layer. |
Aron Virginas-Tar | 77bfb5e | 2019-10-16 17:45:38 +0100 | [diff] [blame] | 479 | ARMNN_DEPRECATED_MSG("Use AddComparisonLayer instead") |
FrancisMurtagh | 2099595 | 2018-12-17 12:11:36 +0000 | [diff] [blame] | 480 | virtual IConnectableLayer* AddEqualLayer(const char* name = nullptr) = 0; |
| 481 | |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 482 | /// Add Reciprocal of square root layer to the network. |
| 483 | /// @param name - Optional name for the layer. |
| 484 | /// @ return - Interface for configuring the layer. |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 485 | ARMNN_DEPRECATED_MSG("Use AddElementwiseUnaryLayer instead") |
Mohamed Nour Abouelseoud | a1d3c6a | 2018-12-27 12:39:16 +0000 | [diff] [blame] | 486 | virtual IConnectableLayer* AddRsqrtLayer(const char* name = nullptr) = 0; |
| 487 | |
narpra01 | b89b05f | 2019-01-16 09:53:09 +0000 | [diff] [blame] | 488 | /// Add Gather layer to the network. |
| 489 | /// @param name - Optional name for the layer. |
| 490 | /// @ return - Interface for configuring the layer. |
| 491 | virtual IConnectableLayer* AddGatherLayer(const char* name = nullptr) = 0; |
| 492 | |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 493 | /// Adds a switch layer to the network. |
| 494 | /// @param name - Optional name for the layer. |
| 495 | /// @return - Interface for configuring the layer. |
| 496 | virtual IConnectableLayer* AddSwitchLayer(const char* name = nullptr) = 0; |
| 497 | |
Matteo Martincigh | 0e406ee | 2019-06-12 15:42:18 +0100 | [diff] [blame] | 498 | /// Adds a PReLU layer to the network. |
| 499 | /// @param name - Optional name for the layer. |
| 500 | /// @return - Interface for configuring the layer. |
| 501 | virtual IConnectableLayer* AddPreluLayer(const char* name = nullptr) = 0; |
| 502 | |
Aron Virginas-Tar | 639fb04 | 2019-06-20 14:28:19 +0100 | [diff] [blame] | 503 | /// Adds a 2D transpose convolution layer to the network. |
| 504 | /// @param descriptor - Description of the 2D transpose convolution layer. |
| 505 | /// @param weights - Tensor for the weights data. |
| 506 | /// @param biases - Optional tensor for the bias data. |
| 507 | /// @param name - Optional name for the layer. |
| 508 | /// @return - Interface for configuring the layer. |
| 509 | virtual IConnectableLayer* AddTransposeConvolution2dLayer(const TransposeConvolution2dDescriptor& descriptor, |
| 510 | const ConstTensor& weights, |
| 511 | const Optional<ConstTensor>& biases, |
| 512 | const char* name = nullptr) = 0; |
| 513 | |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame^] | 514 | /// Adds a transpose layer to the network. |
| 515 | /// @param transposeDescriptor - TransposeDescriptor to configure the transpose. |
| 516 | /// @param name - Optional name for the layer. |
| 517 | /// @return - Interface for configuring the layer. |
| 518 | virtual IConnectableLayer* AddTransposeLayer(const TransposeDescriptor& transposeDescriptor, |
| 519 | const char* name = nullptr) = 0; |
| 520 | |
Matthew Jackson | 2b8c1da | 2019-07-04 14:59:16 +0100 | [diff] [blame] | 521 | /// Adds a stack layer to the network. |
| 522 | /// @param descriptor - Description of the stack layer. |
| 523 | /// @param name - Optional name for the layer. |
| 524 | /// @return - Interface for configuring the layer. |
| 525 | virtual IConnectableLayer* AddStackLayer(const StackDescriptor& descriptor, |
| 526 | const char* name = nullptr) = 0; |
| 527 | |
Derek Lamberti | 013c390 | 2019-10-21 10:46:16 +0100 | [diff] [blame] | 528 | /// Add a stand-in layer for a type unknown to the Arm NN framework. |
| 529 | /// Note: Due to the nature of this layer, no validation can be performed by the framework. |
| 530 | /// Furthermore, Any model containing this layer cannot make use of dynamic tensors since the |
| 531 | /// tensor sizes cannot be inferred. |
| 532 | /// @descriptor - Descriptor for the StandIn layer. |
| 533 | /// @return - Interface for configuring the layer. |
| 534 | virtual IConnectableLayer* AddStandInLayer(const StandInDescriptor& descriptor, |
| 535 | const char* name = nullptr) = 0; |
| 536 | |
James Conroy | ee18dc8 | 2019-07-17 11:27:46 +0100 | [diff] [blame] | 537 | /// Add a QuantizedLstm layer to the network |
| 538 | /// @param params - The weights and biases for the Quantized LSTM cell |
| 539 | /// @param name - Optional name for the layer |
| 540 | /// @return - Interface for configuring the layer. |
| 541 | virtual IConnectableLayer* AddQuantizedLstmLayer(const QuantizedLstmInputParams& params, |
| 542 | const char* name = nullptr) = 0; |
| 543 | |
Mike Kelly | 8c1701a | 2019-02-11 17:01:27 +0000 | [diff] [blame] | 544 | virtual void Accept(ILayerVisitor& visitor) const = 0; |
| 545 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 546 | protected: |
| 547 | ~INetwork() {} |
| 548 | }; |
| 549 | |
| 550 | using IOptimizedNetworkPtr = std::unique_ptr<IOptimizedNetwork, void(*)(IOptimizedNetwork* network)>; |
| 551 | |
| 552 | class IOptimizedNetwork |
| 553 | { |
| 554 | public: |
| 555 | static void Destroy(IOptimizedNetwork* network); |
| 556 | |
| 557 | virtual Status PrintGraph() = 0; |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 558 | virtual Status SerializeToDot(std::ostream& stream) const = 0; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 559 | |
Jan Eilers | 99d9d4a | 2019-11-06 10:02:16 +0000 | [diff] [blame] | 560 | virtual profiling::ProfilingGuid GetGuid() const = 0; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 561 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 562 | protected: |
| 563 | ~IOptimizedNetwork() {} |
| 564 | }; |
| 565 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 566 | struct OptimizerOptions |
| 567 | { |
Matteo Martincigh | 4912402 | 2019-01-11 13:25:59 +0000 | [diff] [blame] | 568 | OptimizerOptions() |
| 569 | : m_ReduceFp32ToFp16(false) |
| 570 | , m_Debug(false) |
keidav01 | 738c2e6 | 2018-12-11 16:14:20 +0000 | [diff] [blame] | 571 | {} |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 572 | |
keidav01 | 738c2e6 | 2018-12-11 16:14:20 +0000 | [diff] [blame] | 573 | OptimizerOptions(bool reduceFp32ToFp16, bool debug) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 574 | : m_ReduceFp32ToFp16(reduceFp32ToFp16) |
keidav01 | 738c2e6 | 2018-12-11 16:14:20 +0000 | [diff] [blame] | 575 | , m_Debug(debug) |
Matteo Martincigh | 4912402 | 2019-01-11 13:25:59 +0000 | [diff] [blame] | 576 | {} |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 577 | |
| 578 | // Reduce Fp32 data to Fp16 for faster processing |
| 579 | bool m_ReduceFp32ToFp16; |
keidav01 | 738c2e6 | 2018-12-11 16:14:20 +0000 | [diff] [blame] | 580 | |
| 581 | // Add debug data for easier troubleshooting |
| 582 | bool m_Debug; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 583 | }; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 584 | |
| 585 | /// Create an optimized version of the network |
| 586 | /// @param network INetwork description of the network to be optimized. |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 587 | /// @param backendPreferences The choice of the backend ordered by user preferences. |
| 588 | /// @param deviceSpec DeviceSpec object as queried from the runtime. See IRuntime::GetDeviceSpec() |
Rob Hughes | 2321443 | 2019-11-05 11:27:36 +0000 | [diff] [blame] | 589 | /// @param messages If there are failures or warnings a string describing same will be added to the vector |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 590 | /// @param options OptimizerOptions object with optimizer configuration options |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 591 | /// @return An IOptimizedNetworkPtr interface to the optimized network, throws an exception derived from |
| 592 | /// armnn::Exception if process fails. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 593 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 594 | IOptimizedNetworkPtr Optimize(const INetwork& network, |
David Beck | f0b4845 | 2018-10-19 15:20:56 +0100 | [diff] [blame] | 595 | const std::vector<BackendId>& backendPreferences, |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 596 | const IDeviceSpec& deviceSpec, |
jimfly01 | 6b0b53d | 2018-10-08 14:43:01 +0100 | [diff] [blame] | 597 | const OptimizerOptions& options = OptimizerOptions(), |
Rob Hughes | 2321443 | 2019-11-05 11:27:36 +0000 | [diff] [blame] | 598 | Optional<std::vector<std::string>&> messages = EmptyOptional()); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 599 | } //namespace armnn |