Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 1 | // |
Teresa Charlin | 1814733 | 2021-11-17 14:34:30 +0000 | [diff] [blame] | 2 | // Copyright © 2020 Arm Ltd and Contributors. All rights reserved. |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | %{ |
| 6 | #include "armnn/INetwork.hpp" |
| 7 | #include "armnn/BackendId.hpp" |
| 8 | #include "armnn/Types.hpp" |
| 9 | #include "armnn/Optional.hpp" |
| 10 | #include <fstream> |
| 11 | %} |
| 12 | |
| 13 | %include <typemaps/network_optimize.i> |
alexander | 7301078 | 2021-10-18 19:17:24 +0100 | [diff] [blame] | 14 | %include <typemaps/model_options.i> |
| 15 | |
| 16 | namespace std { |
| 17 | %template() std::vector<armnn::BackendOptions>; |
| 18 | } |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 19 | |
| 20 | namespace armnn |
| 21 | { |
| 22 | %feature("docstring", |
| 23 | " |
| 24 | Struct for holding options relating to the Arm NN optimizer. See `Optimize`. |
| 25 | |
| 26 | Contains: |
| 27 | m_debug (bool): Add debug data for easier troubleshooting. |
Jan Eilers | 841aca1 | 2020-08-12 14:59:06 +0100 | [diff] [blame] | 28 | m_ReduceFp32ToBf16 (bool): Reduces Fp32 network to BFloat16 (Bf16) for faster processing. Layers |
| 29 | that can not be reduced will be left in Fp32. |
| 30 | m_ReduceFp32ToFp16 (bool): Reduces Fp32 network to Fp16 for faster processing. Layers |
| 31 | that can not be reduced will be left in Fp32. |
alexander | 7301078 | 2021-10-18 19:17:24 +0100 | [diff] [blame] | 32 | m_ImportEnabled (bool): Enable memory import. |
| 33 | m_shapeInferenceMethod: The ShapeInferenceMethod modifies how the output shapes are treated. |
| 34 | When ValidateOnly is selected, the output shapes are inferred from the input parameters |
| 35 | of the layer and any mismatch is reported. |
| 36 | When InferAndValidate is selected 2 actions are performed: (1)infer output shape from |
| 37 | inputs and (2)validate the shapes as in ValidateOnly. This option has been added to work |
| 38 | with tensors which rank or dimension sizes are not specified explicitly, however this |
| 39 | information can be calculated from the inputs. |
| 40 | m_ModelOptions: List of backends optimisation options. |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 41 | |
| 42 | ") OptimizerOptions; |
alexander | 7301078 | 2021-10-18 19:17:24 +0100 | [diff] [blame] | 43 | |
| 44 | %model_options_typemap; |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 45 | struct OptimizerOptions |
| 46 | { |
| 47 | OptimizerOptions(); |
| 48 | |
Jan Eilers | 841aca1 | 2020-08-12 14:59:06 +0100 | [diff] [blame] | 49 | OptimizerOptions(bool reduceFp32ToFp16, |
| 50 | bool debug, |
Narumol Prangnawarat | ea063df | 2020-08-21 10:03:49 +0100 | [diff] [blame] | 51 | bool reduceFp32ToBf16 = false, |
alexander | 7301078 | 2021-10-18 19:17:24 +0100 | [diff] [blame] | 52 | ShapeInferenceMethod shapeInferenceMethod = armnn::ShapeInferenceMethod::ValidateOnly, |
| 53 | bool importEnabled = false, |
| 54 | std::vector<armnn::BackendOptions> modelOptions = {}); |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 55 | |
Jan Eilers | 841aca1 | 2020-08-12 14:59:06 +0100 | [diff] [blame] | 56 | bool m_ReduceFp32ToBf16; |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 57 | bool m_ReduceFp32ToFp16; |
| 58 | bool m_Debug; |
alexander | 7301078 | 2021-10-18 19:17:24 +0100 | [diff] [blame] | 59 | ShapeInferenceMethod m_shapeInferenceMethod; |
Narumol Prangnawarat | ea063df | 2020-08-21 10:03:49 +0100 | [diff] [blame] | 60 | bool m_ImportEnabled; |
alexander | 7301078 | 2021-10-18 19:17:24 +0100 | [diff] [blame] | 61 | std::vector<armnn::BackendOptions> m_ModelOptions; |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 62 | }; |
alexander | 7301078 | 2021-10-18 19:17:24 +0100 | [diff] [blame] | 63 | %model_options_clear; |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 64 | |
| 65 | %feature("docstring", |
| 66 | " |
| 67 | An input connection slot for a layer. Slot lifecycle is managed by the layer. |
| 68 | |
| 69 | The input slot can be connected to an output slot of the preceding layer in the graph. |
| 70 | Only one connection to the input slot is allowed. |
| 71 | |
| 72 | ") IInputSlot; |
| 73 | %nodefaultctor IInputSlot; |
| 74 | %nodefaultdtor IInputSlot; |
| 75 | class IInputSlot |
| 76 | { |
| 77 | public: |
| 78 | %feature("docstring", |
| 79 | " |
| 80 | Returns output slot of a preceding layer that is connected to the given input slot. |
| 81 | |
| 82 | Returns: |
| 83 | IOutputSlot: Borrowed reference to an output connection slot for a preceding layer. |
| 84 | |
| 85 | ") GetConnection; |
| 86 | |
| 87 | armnn::IOutputSlot* GetConnection(); |
| 88 | }; |
| 89 | |
| 90 | %feature("docstring", |
| 91 | " |
| 92 | An output connection slot for a layer. Slot lifecycle is managed by the layer. |
| 93 | |
| 94 | The output slot may be connected to 1 or more input slots of subsequent layers in the graph. |
| 95 | ") IOutputSlot; |
| 96 | %nodefaultctor IOutputSlot; |
| 97 | %nodefaultdtor IOutputSlot; |
| 98 | class IOutputSlot |
| 99 | { |
| 100 | public: |
| 101 | |
| 102 | %feature("docstring", |
| 103 | " |
| 104 | Returns the total number of connected input slots. |
| 105 | |
| 106 | The same result could be obtained by calling `len()`: |
| 107 | |
| 108 | >>> output_slot = ... |
| 109 | >>> size = len(output_slot) |
| 110 | >>> assert size == output_slot.GetNumConnections() |
| 111 | |
| 112 | Returns: |
| 113 | int: Number of connected input slots. |
| 114 | ") GetNumConnections; |
| 115 | unsigned int GetNumConnections(); |
| 116 | |
| 117 | |
| 118 | %feature("docstring", |
| 119 | " |
| 120 | Retrieves connected input slot by index. |
| 121 | |
| 122 | The same result could be obtained by using square brackets: |
| 123 | |
| 124 | >>> output_slot = ... |
| 125 | >>> connected_input_slot = output_slot[0] |
| 126 | |
| 127 | Args: |
| 128 | index (int): Slot index. |
| 129 | |
| 130 | Returns: |
| 131 | IInputSlot: Borrowed reference to connected input slot with given index. |
| 132 | |
| 133 | Raises: |
| 134 | RuntimeError: If index out of bounds. |
| 135 | ") GetConnection; |
| 136 | armnn::IInputSlot* GetConnection(unsigned int index); |
| 137 | |
| 138 | %feature("docstring", |
| 139 | " |
| 140 | Sets tensor info for output slot. |
| 141 | Operation does not change TensorInfo ownership. |
| 142 | Args: |
| 143 | tensorInfo (TensorInfo): Output tensor info. |
| 144 | |
| 145 | ") SetTensorInfo; |
| 146 | void SetTensorInfo(const armnn::TensorInfo& tensorInfo); |
| 147 | |
| 148 | %feature("docstring", |
| 149 | " |
| 150 | Gets tensor info for output slot. |
| 151 | |
| 152 | Args: |
| 153 | tensorInfo (TensorInfo): Output tensor info. |
| 154 | |
| 155 | ") GetTensorInfo; |
| 156 | const armnn::TensorInfo& GetTensorInfo(); |
| 157 | |
| 158 | %feature("docstring", |
| 159 | " |
| 160 | Checks if tensor info was set previously. |
| 161 | |
| 162 | Returns: |
| 163 | bool: True if output tensor info was set, False - otherwise. |
| 164 | |
| 165 | ") IsTensorInfoSet; |
| 166 | bool IsTensorInfoSet(); |
| 167 | |
| 168 | %feature("docstring", |
| 169 | " |
| 170 | Connects this output slot with given input slot. |
| 171 | Input slot is updated with this output connection. |
| 172 | |
| 173 | Args: |
| 174 | destination (IInputSlot): Output tensor info. |
| 175 | |
| 176 | Returns: |
| 177 | int: Total number of connections. |
| 178 | |
| 179 | Raises: |
| 180 | RuntimeError: If input slot was already connected. |
| 181 | |
| 182 | ") Connect; |
| 183 | int Connect(IInputSlot& destination); |
| 184 | |
| 185 | %feature("docstring", |
| 186 | " |
| 187 | Disconnects this output slot from given input slot. |
| 188 | |
| 189 | Args: |
| 190 | slot (IInputSlot): Input slot to disconnect from. |
| 191 | |
| 192 | ") Disconnect; |
| 193 | void Disconnect(IInputSlot& slot); |
| 194 | |
| 195 | %feature("docstring", |
| 196 | " |
| 197 | Calculates the index of this slot for the layer. |
| 198 | |
| 199 | Returns: |
| 200 | int: Slot index. |
| 201 | |
| 202 | ") CalculateIndexOnOwner; |
| 203 | unsigned int CalculateIndexOnOwner(); |
| 204 | |
| 205 | %feature("docstring", |
| 206 | " |
| 207 | Returns the index of the layer. Same value as `IConnectableLayer.GetGuid`. |
| 208 | |
| 209 | Returns: |
| 210 | int: Layer id. |
| 211 | |
| 212 | ") GetOwningLayerGuid; |
| 213 | unsigned int GetOwningLayerGuid(); |
| 214 | |
| 215 | }; |
| 216 | |
| 217 | %extend IOutputSlot { |
| 218 | |
| 219 | armnn::IInputSlot* __getitem__(unsigned int index) { |
| 220 | return $self->GetConnection(index); |
| 221 | } |
| 222 | |
| 223 | unsigned int __len__() const { |
| 224 | return $self->GetNumConnections(); |
| 225 | } |
| 226 | |
| 227 | } |
| 228 | |
| 229 | %feature("docstring", |
| 230 | " |
| 231 | Interface for a layer that is connectable to other layers via `IInputSlot` and `IOutputSlot`. |
| 232 | The object implementing this interface is returned by `INetwork` when calling `add*Layer` methods. |
| 233 | |
| 234 | ") IConnectableLayer; |
| 235 | %nodefaultctor IConnectableLayer; |
| 236 | %nodefaultdtor IConnectableLayer; |
| 237 | class IConnectableLayer |
| 238 | { |
| 239 | public: |
| 240 | %feature("docstring", |
| 241 | " |
| 242 | Returns the name of the layer. Name attribute is optional for a layer, thus |
| 243 | `None` value could be returned. |
| 244 | |
| 245 | Returns: |
| 246 | str: Layer name or `None`. |
| 247 | |
| 248 | ") GetName; |
| 249 | const char* GetName(); |
| 250 | |
| 251 | %feature("docstring", |
| 252 | " |
| 253 | Gets the number of input slots for the layer. |
| 254 | |
| 255 | Returns: |
| 256 | int: Number of input slots. |
| 257 | |
| 258 | ") GetNumInputSlots; |
| 259 | unsigned int GetNumInputSlots(); |
| 260 | |
| 261 | %feature("docstring", |
| 262 | " |
| 263 | Gets the number of output slots for the layer. |
| 264 | |
| 265 | Returns: |
| 266 | int: Number of output slots. |
| 267 | |
| 268 | ") GetNumOutputSlots; |
| 269 | unsigned int GetNumOutputSlots(); |
| 270 | |
| 271 | %feature("docstring", |
| 272 | " |
| 273 | Gets the input slot by index. |
| 274 | |
| 275 | Args: |
| 276 | index (int): Slot index. |
| 277 | |
| 278 | Returns: |
| 279 | IInputSlot: Borrowed reference to input slot. |
| 280 | |
| 281 | ") GetInputSlot; |
| 282 | armnn::IInputSlot& GetInputSlot(unsigned int index); |
| 283 | |
| 284 | %feature("docstring", |
| 285 | " |
| 286 | Gets the output slot by index. |
| 287 | |
| 288 | Args: |
| 289 | index (int): Slot index. |
| 290 | |
| 291 | Returns: |
| 292 | IOutputSlot: Borrowed reference to output slot. |
| 293 | |
| 294 | ") GetOutputSlot; |
| 295 | armnn::IOutputSlot& GetOutputSlot(unsigned int index); |
| 296 | |
| 297 | |
| 298 | %feature("docstring", |
| 299 | " |
| 300 | Gets the unique layer id (within one process). |
| 301 | Guid is generated and assigned automatically when the layer is created. |
| 302 | |
| 303 | Returns: |
| 304 | int: The unique layer id. |
| 305 | |
| 306 | ") GetGuid; |
| 307 | unsigned int GetGuid(); |
| 308 | }; |
| 309 | |
| 310 | %feature("docstring", |
| 311 | " |
| 312 | Interface for a network object. Network objects contain the whole computation graph, made up of different layers connected together. |
| 313 | |
| 314 | INetwork objects can be constructed manually or obtained by using parsers. INetwork objects are used to create optimized networks, see `Optimize`. |
| 315 | |
| 316 | ") INetwork; |
| 317 | %nodefaultctor INetwork; |
| 318 | %nodefaultdtor INetwork; |
| 319 | class INetwork |
| 320 | { |
| 321 | public: |
| 322 | |
| 323 | %feature("docstring", |
| 324 | " |
| 325 | Adds an input layer to the network. Input layers are placed at the start of a network and used for feeding input data during inference. |
| 326 | |
| 327 | Args: |
| 328 | id (int): User generated id to uniquely identify a particular input. The same id needs to be specified |
| 329 | when passing the inputs to the IRuntime::EnqueueWorkload() function. |
| 330 | name (str): Optional name for the layer. |
| 331 | |
| 332 | Returns: |
| 333 | IConnectableLayer: Interface for configuring the layer. |
| 334 | ") AddInputLayer; |
| 335 | armnn::IConnectableLayer* AddInputLayer(int id, const char* name = nullptr); |
| 336 | |
| 337 | %feature("docstring", |
| 338 | " |
| 339 | Adds an addition layer to the network. |
| 340 | |
| 341 | Args: |
| 342 | name (str): Optional name for the layer. |
| 343 | |
| 344 | Returns: |
| 345 | IConnectableLayer: Interface for configuring the layer. |
| 346 | ") AddAdditionLayer; |
| 347 | armnn::IConnectableLayer* AddAdditionLayer(const char* name = nullptr); |
| 348 | |
| 349 | %feature("docstring", |
| 350 | " |
| 351 | Adds an output layer to the network. Output layer is the final layer in your network. |
| 352 | |
| 353 | Args: |
| 354 | id (int): User generated id to uniquely identify a particular input. The same id needs to be specified |
| 355 | when passing the inputs to `IRuntime.EnqueueWorkload()`. |
| 356 | name (str): Optional name for the layer. |
| 357 | |
| 358 | Returns: |
| 359 | IConnectableLayer: Interface for configuring the layer. |
| 360 | ") AddOutputLayer; |
| 361 | armnn::IConnectableLayer* AddOutputLayer(int id, const char* name = nullptr); |
| 362 | |
| 363 | |
| 364 | %feature("docstring", |
| 365 | " |
| 366 | Adds an Activation layer to the network. Type of activation is decided by activationDescriptor. |
| 367 | |
| 368 | Args: |
| 369 | activationDescriptor (ActivationDescriptor): ActivationDescriptor to configure the activation. |
| 370 | name (str): Optional name for the layer. |
| 371 | |
| 372 | Returns: |
| 373 | IConnectableLayer: Interface for configuring the layer. |
| 374 | ") AddActivationLayer; |
| 375 | armnn::IConnectableLayer* AddActivationLayer(const ActivationDescriptor& activationDescriptor, |
| 376 | const char* name = nullptr); |
| 377 | |
| 378 | |
| 379 | %feature("docstring", |
| 380 | " |
| 381 | Adds an ArgMinMax layer to the network. |
| 382 | |
| 383 | Args: |
| 384 | desc (ArgMinMaxDescriptor): Parameters for the ArgMinMax layer. |
| 385 | name (str): Optional name for the layer. |
| 386 | |
| 387 | Returns: |
| 388 | IConnectableLayer: Interface for configuring the layer. |
| 389 | ") AddArgMinMaxLayer; |
| 390 | armnn::IConnectableLayer* AddArgMinMaxLayer(const armnn::ArgMinMaxDescriptor& desc, |
| 391 | const char* name = nullptr); |
| 392 | |
| 393 | |
| 394 | %feature("docstring", |
| 395 | " |
| 396 | Adds a Batch Normalization layer to the network. |
| 397 | |
| 398 | Args: |
| 399 | mean (ConstTensor): Pre-calculated mean for each channel. |
| 400 | variance (ConstTensor): Pre-calculated variance for each channel. |
| 401 | beta (ConstTensor): Per-channel additive factor. |
| 402 | gamma (ConstTensor): Per-channel multiplicative factor. |
| 403 | name (str): Optional name for the layer. |
| 404 | |
| 405 | Returns: |
| 406 | IConnectableLayer: Interface for configuring the layer. |
| 407 | ") AddBatchNormalizationLayer; |
| 408 | armnn::IConnectableLayer* AddBatchNormalizationLayer(const armnn::BatchNormalizationDescriptor& desc, |
| 409 | const armnn::ConstTensor& mean, |
| 410 | const armnn::ConstTensor& variance, |
| 411 | const armnn::ConstTensor& beta, |
| 412 | const armnn::ConstTensor& gamma, |
| 413 | const char* name = nullptr); |
| 414 | |
| 415 | |
| 416 | %feature("docstring", |
| 417 | " |
| 418 | Adds a Batch To Space ND layer to the network. |
| 419 | |
| 420 | Args: |
| 421 | batchToSpaceNdDescriptor (BatchToSpaceNdDescriptor): Configuration parameters for the layer. |
| 422 | name (str): Optional name for the layer. |
| 423 | |
| 424 | Returns: |
| 425 | IConnectableLayer: Interface for configuring the layer. |
| 426 | ") AddBatchToSpaceNdLayer; |
| 427 | armnn::IConnectableLayer* AddBatchToSpaceNdLayer(const armnn::BatchToSpaceNdDescriptor& batchToSpaceNdDescriptor, |
Teresa Charlin | f7b5011 | 2021-11-18 15:24:50 +0000 | [diff] [blame] | 428 | const char* name = nullptr); |
| 429 | |
| 430 | %feature("docstring", |
| 431 | " |
| 432 | Adds a ChannelShuffle layer to the network. |
| 433 | |
| 434 | Args: |
| 435 | channelShuffleDescriptor (ChannelShuffleDescriptor): Configuration parameters for the layer. |
| 436 | name (str): Optional name for the layer. |
| 437 | |
| 438 | Returns: |
| 439 | IConnectableLayer: Interface for configuring the layer. |
| 440 | ") AddChannelShuffleLayer; |
| 441 | armnn::IConnectableLayer* AddChannelShuffleLayer(const armnn::ChannelShuffleDescriptor& channelShuffleDescriptor, |
| 442 | const char* name = nullptr); |
| 443 | |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 444 | |
Teresa Charlin | 87dc812 | 2021-11-22 15:34:26 +0000 | [diff] [blame] | 445 | |
| 446 | %feature("docstring", |
| 447 | " |
| 448 | Adds a Cast layer to the network. |
| 449 | |
| 450 | Args: |
| 451 | name (str): Optional name for the layer. |
| 452 | |
| 453 | Returns: |
| 454 | IConnectableLayer: Interface for configuring the layer. |
| 455 | ") AddCastLayer; |
| 456 | armnn::IConnectableLayer* AddCastLayer(const char* name = nullptr); |
| 457 | |
| 458 | |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 459 | %feature("docstring", |
| 460 | " |
| 461 | Adds a Comparison layer to the network. |
| 462 | |
| 463 | Args: |
| 464 | comparisonDescriptor (ComparisonDescriptor): Configuration parameters for the layer. |
| 465 | name (str): Optional name for the layer. |
| 466 | |
| 467 | Returns: |
| 468 | IConnectableLayer: Interface for configuring the layer. |
| 469 | ") AddComparisonLayer; |
| 470 | armnn::IConnectableLayer* AddComparisonLayer(const armnn::ComparisonDescriptor& comparisonDescriptor, |
| 471 | const char* name = nullptr); |
| 472 | |
| 473 | %feature("docstring", |
| 474 | " |
| 475 | Adds a Concatenation layer to the network. |
| 476 | |
| 477 | Args: |
| 478 | concatDescriptor (ConcatDescriptor): Parameters to configure the Concatenation layer. |
| 479 | name (str): Optional name for the layer. |
| 480 | |
| 481 | Returns: |
| 482 | IConnectableLayer: Interface for configuring the layer. |
| 483 | ") AddConcatLayer; |
| 484 | armnn::IConnectableLayer* AddConcatLayer(const armnn::ConcatDescriptor& concatDescriptor, |
Teresa Charlin | 1814733 | 2021-11-17 14:34:30 +0000 | [diff] [blame] | 485 | const char* name = nullptr); |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 486 | |
| 487 | |
| 488 | %feature("docstring", |
| 489 | " |
| 490 | Adds a layer with no inputs and a single output, which always corresponds to the passed in constant tensor. |
| 491 | |
| 492 | Args: |
| 493 | input (ConstTensor): Tensor to be provided as the only output of the layer. The layer will maintain |
| 494 | its own copy of the tensor data, meaning the memory referenced by input can |
| 495 | be freed or reused after this function is called. |
| 496 | name (str): Optional name for the layer. |
| 497 | |
| 498 | Returns: |
| 499 | IConnectableLayer: Interface for configuring the layer. |
| 500 | ") AddConstantLayer; |
| 501 | armnn::IConnectableLayer* AddConstantLayer(const armnn::ConstTensor& input, |
Teresa Charlin | 1814733 | 2021-11-17 14:34:30 +0000 | [diff] [blame] | 502 | const char* name = nullptr); |
| 503 | |
| 504 | |
| 505 | %feature("docstring", |
| 506 | " |
| 507 | Adds a 3D Convolution layer to the network. |
| 508 | |
| 509 | Args: |
| 510 | convolution3dDescriptor (Convolution3dDescriptor): Description of the 3D convolution layer. |
| 511 | name (str): Optional name for the layer. |
| 512 | |
| 513 | Returns: |
| 514 | IConnectableLayer: Interface for configuring the layer. |
| 515 | ") AddConvolution3dLayer; |
| 516 | |
| 517 | armnn::IConnectableLayer* AddConvolution3dLayer(const armnn::Convolution3dDescriptor& convolution3dDescriptor, |
| 518 | const char* name = nullptr); |
| 519 | |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 520 | |
| 521 | %feature("docstring", |
| 522 | " |
| 523 | Adds a Depth To Space layer to the network. |
| 524 | |
| 525 | Args: |
| 526 | depthToSpaceDescriptor (DepthToSpaceDescriptor): Parameters for the depth to space operation. |
| 527 | name (str): Optional name for the layer. |
| 528 | |
| 529 | Returns: |
| 530 | IConnectableLayer: Interface for configuring the layer. |
| 531 | ") AddDepthToSpaceLayer; |
| 532 | armnn::IConnectableLayer* AddDepthToSpaceLayer(const armnn::DepthToSpaceDescriptor& depthToSpaceDescriptor, |
Teresa Charlin | 1814733 | 2021-11-17 14:34:30 +0000 | [diff] [blame] | 533 | const char* name = nullptr); |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 534 | |
| 535 | %feature("docstring", |
| 536 | " |
Colm Donelan | bd4491b | 2022-05-19 12:32:21 +0100 | [diff] [blame^] | 537 | Adds a 2D Depthwise Convolution layer to the network. |
| 538 | |
| 539 | Args: |
| 540 | convolution2dDescriptor (DepthwiseConvolution2dDescriptor): Description of the 2D depthwise convolution layer. |
| 541 | name (str): Optional name for the layer. |
| 542 | |
| 543 | Returns: |
| 544 | IConnectableLayer: Interface for configuring the layer. |
| 545 | ") AddDepthwiseConvolution2dLayer; |
| 546 | |
| 547 | armnn::IConnectableLayer* AddDepthwiseConvolution2dLayer( |
| 548 | const armnn::DepthwiseConvolution2dDescriptor& convolution2dDescriptor, |
| 549 | const char* name = nullptr); |
| 550 | |
| 551 | %feature("docstring", |
| 552 | " |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 553 | Adds a Dequantize layer to the network. |
| 554 | |
| 555 | Args: |
| 556 | name (str): Optional name for the layer. |
| 557 | |
| 558 | Returns: |
| 559 | IConnectableLayer: Interface for configuring the layer. |
| 560 | ") AddDequantizeLayer; |
| 561 | armnn::IConnectableLayer* AddDequantizeLayer(const char* name = nullptr); |
| 562 | |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 563 | %feature("docstring", |
| 564 | " |
| 565 | Adds a Detection PostProcess layer to the network. Detection PostProcess is a custom layer for SSD MobilenetV1. |
| 566 | |
| 567 | Args: |
| 568 | descriptor (DetectionPostProcessDescriptor): Description of the Detection PostProcess layer. |
| 569 | anchors (ConstTensor): Tensor for anchors. |
| 570 | name (str): Optional name for the layer. |
| 571 | |
| 572 | Returns: |
| 573 | IConnectableLayer: Interface for configuring the layer. |
| 574 | ") AddDetectionPostProcessLayer; |
| 575 | armnn::IConnectableLayer* AddDetectionPostProcessLayer( |
| 576 | const armnn::DetectionPostProcessDescriptor& descriptor, |
| 577 | const armnn::ConstTensor& anchors, |
| 578 | const char* name = nullptr); |
| 579 | |
| 580 | |
| 581 | %feature("docstring", |
| 582 | " |
| 583 | Adds a Division layer to the network. |
| 584 | |
| 585 | Args: |
| 586 | name (str): Optional name for the layer. |
| 587 | |
| 588 | Returns: |
| 589 | IConnectableLayer: Interface for configuring the layer. |
| 590 | ") AddDivisionLayer; |
| 591 | armnn::IConnectableLayer* AddDivisionLayer(const char* name = nullptr); |
| 592 | |
| 593 | %feature("docstring", |
Jan Eilers | 841aca1 | 2020-08-12 14:59:06 +0100 | [diff] [blame] | 594 | " |
| 595 | Adds an Elementwise Unary layer to the network. Type of unary operation to use is decided by elementwiseUnaryDescriptor. Unary operations supported are (Abs, Exp, Neg, Rsqrt, Sqrt) |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 596 | |
Jan Eilers | 841aca1 | 2020-08-12 14:59:06 +0100 | [diff] [blame] | 597 | Args: |
| 598 | elementwiseUnaryDescriptor (ElementwiseUnaryDescriptor): ElementwiseUnaryDescriptor to configure the choice of unary operation added to the network. |
| 599 | name (str): Optional name for the layer. |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 600 | |
Jan Eilers | 841aca1 | 2020-08-12 14:59:06 +0100 | [diff] [blame] | 601 | Returns: |
| 602 | IConnectableLayer: Interface for configuring the layer. |
| 603 | ") AddElementwiseUnaryLayer; |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 604 | armnn::IConnectableLayer* AddElementwiseUnaryLayer(const ElementwiseUnaryDescriptor& elementwiseUnaryDescriptor, |
| 605 | const char* name = nullptr); |
| 606 | |
| 607 | %feature("docstring", |
| 608 | " |
Jan Eilers | 841aca1 | 2020-08-12 14:59:06 +0100 | [diff] [blame] | 609 | Add a Fill layer to the network. |
| 610 | |
| 611 | Args: |
| 612 | FillDescriptor (FillDescriptor): Descriptor for the fill operation. |
| 613 | name (str): Optional name for the layer. |
| 614 | |
| 615 | Returns: |
| 616 | IConnectableLayer: Interface for configuring the layer. |
| 617 | ") AddFillLayer; |
| 618 | armnn::IConnectableLayer* AddFillLayer(const FillDescriptor& fillDescriptor, |
| 619 | const char* name = nullptr); |
| 620 | |
| 621 | %feature("docstring", |
| 622 | " |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 623 | Adds a Floor layer to the network. |
| 624 | |
| 625 | Args: |
| 626 | name (str): Optional name for the layer. |
| 627 | |
| 628 | Returns: |
| 629 | IConnectableLayer: Interface for configuring the layer. |
| 630 | ") AddFloorLayer; |
| 631 | armnn::IConnectableLayer* AddFloorLayer(const char* name = nullptr); |
| 632 | |
| 633 | %feature("docstring", |
| 634 | " |
| 635 | Add Gather layer to the network. |
| 636 | |
| 637 | Args: |
Jan Eilers | 841aca1 | 2020-08-12 14:59:06 +0100 | [diff] [blame] | 638 | descriptor (GatherDescriptor): Descriptor for the gather operation. |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 639 | name (str): Optional name for the layer. |
| 640 | |
| 641 | Returns: |
| 642 | IConnectableLayer: Interface for configuring the layer. |
| 643 | ") AddGatherLayer; |
Jan Eilers | 841aca1 | 2020-08-12 14:59:06 +0100 | [diff] [blame] | 644 | armnn::IConnectableLayer* AddGatherLayer(const GatherDescriptor& descriptor, |
| 645 | const char* name = nullptr); |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 646 | |
| 647 | %feature("docstring", |
| 648 | " |
Teresa Charlin | 26ee542 | 2022-05-03 21:39:57 +0100 | [diff] [blame] | 649 | Add GatherNd layer to the network. |
| 650 | |
| 651 | Args: |
| 652 | name (str): Optional name for the layer. |
| 653 | |
| 654 | Returns: |
| 655 | IConnectableLayer: Interface for configuring the layer. |
| 656 | ") AddGatherNdLayer; |
| 657 | armnn::IConnectableLayer* AddGatherNdLayer(const char* name = nullptr); |
| 658 | |
| 659 | %feature("docstring", |
| 660 | " |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 661 | Adds an Instance Normalization layer to the network. |
| 662 | |
| 663 | Args: |
| 664 | desc (InstanceNormalizationDescriptor): Parameters for the instance normalization operation. |
| 665 | name (str): Optional name for the layer. |
| 666 | |
| 667 | Returns: |
| 668 | IConnectableLayer: Interface for configuring the layer. |
| 669 | ") AddInstanceNormalizationLayer; |
| 670 | armnn::IConnectableLayer* AddInstanceNormalizationLayer(const armnn::InstanceNormalizationDescriptor& desc, |
Teresa Charlin | 1814733 | 2021-11-17 14:34:30 +0000 | [diff] [blame] | 671 | const char* name = nullptr); |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 672 | |
Cathal Corbett | 9f184c4 | 2021-11-10 12:14:39 +0000 | [diff] [blame] | 673 | %feature("docstring", |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 674 | " |
| 675 | Adds a Log Softmax layer to the network. |
| 676 | |
| 677 | Args: |
| 678 | desc (SoftmaxDescriptor): parameters to configure the log softmax. |
| 679 | name (str): Optional name for the layer. |
| 680 | |
| 681 | Returns: |
| 682 | IConnectableLayer: Interface for configuring the layer. |
| 683 | ") AddLogSoftmaxLayer; |
| 684 | armnn::IConnectableLayer* AddLogSoftmaxLayer(const armnn::LogSoftmaxDescriptor& logSoftmaxDescriptor, |
| 685 | const char* name = nullptr); |
| 686 | |
Cathal Corbett | 9f184c4 | 2021-11-10 12:14:39 +0000 | [diff] [blame] | 687 | %feature("docstring", |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 688 | " |
| 689 | Adds an L2 Normalization layer to the network. |
| 690 | Normalization is performed along dimension 1, but requires a 4d input. |
| 691 | |
| 692 | Args: |
| 693 | desc (L2NormalizationDescriptor): Parameters for the L2 normalization operation. |
| 694 | name (str): Optional name for the layer. |
| 695 | |
| 696 | Returns: |
| 697 | IConnectableLayer: Interface for configuring the layer. |
| 698 | ") AddL2NormalizationLayer; |
| 699 | armnn::IConnectableLayer* AddL2NormalizationLayer(const armnn::L2NormalizationDescriptor& desc, |
| 700 | const char* name = nullptr); |
| 701 | |
| 702 | %feature("docstring", |
| 703 | " |
| 704 | Add a Long Short-Term Memory layer to the network. |
| 705 | |
| 706 | Args: |
| 707 | descriptor (LstmDescriptor): Parameters for the Lstm operation. |
| 708 | params (LstmInputParams): Weights and biases for the LSTM cell. |
| 709 | name (str): Optional name for the layer. |
| 710 | |
| 711 | Returns: |
| 712 | IConnectableLayer: Interface for configuring the layer. |
| 713 | ") AddLstmLayer; |
| 714 | armnn::IConnectableLayer* AddLstmLayer(const armnn::LstmDescriptor& descriptor, |
| 715 | const armnn::LstmInputParams& params, |
| 716 | const char* name = nullptr); |
| 717 | |
Cathal Corbett | 9f184c4 | 2021-11-10 12:14:39 +0000 | [diff] [blame] | 718 | %feature("docstring", |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 719 | " |
| 720 | Add a Maximum layer to the network. |
| 721 | |
| 722 | Args: |
| 723 | name (str): Optional name for the layer. |
| 724 | |
| 725 | Returns: |
| 726 | IConnectableLayer: Interface for configuring the layer. |
| 727 | ") AddMaximumLayer; |
| 728 | armnn::IConnectableLayer* AddMaximumLayer(const char* name = nullptr); |
| 729 | |
| 730 | %feature("docstring", |
| 731 | " |
| 732 | Adds a Mean layer to the network. |
| 733 | |
| 734 | Args: |
| 735 | meanDescriptor (meanDescriptor): Parameters for the mean operation. |
| 736 | name (str): Optional name for the layer. |
| 737 | |
| 738 | Returns: |
| 739 | IConnectableLayer: Interface for configuring the layer. |
| 740 | ") AddMeanLayer; |
| 741 | armnn::IConnectableLayer* AddMeanLayer(const armnn::MeanDescriptor& meanDescriptor, const char* name = nullptr); |
| 742 | |
| 743 | %feature("docstring", |
| 744 | " |
| 745 | Adds a Merge layer to the network. |
| 746 | |
| 747 | Args: |
| 748 | name (str): Optional name for the layer. |
| 749 | |
| 750 | Returns: |
| 751 | IConnectableLayer: Interface for configuring the layer. |
| 752 | ") AddMergeLayer; |
| 753 | armnn::IConnectableLayer* AddMergeLayer(const char* name = nullptr); |
| 754 | |
| 755 | %feature("docstring", |
| 756 | " |
| 757 | Adds a Minimum layer to the network. |
| 758 | |
| 759 | Args: |
| 760 | name (str): Optional name for the layer. |
| 761 | |
| 762 | Returns: |
| 763 | IConnectableLayer: Interface for configuring the layer. |
| 764 | ") AddMinimumLayer; |
| 765 | armnn::IConnectableLayer* AddMinimumLayer(const char* name = nullptr); |
| 766 | |
| 767 | %feature("docstring", |
| 768 | " |
| 769 | Adds a Multiplication layer to the network. |
| 770 | |
| 771 | Args: |
| 772 | name (str): Optional name for the layer. |
| 773 | |
| 774 | Returns: |
| 775 | IConnectableLayer: Interface for configuring the layer. |
| 776 | ") AddMultiplicationLayer; |
| 777 | armnn::IConnectableLayer* AddMultiplicationLayer(const char* name = nullptr); |
| 778 | |
| 779 | %feature("docstring", |
| 780 | " |
| 781 | Adds a Normalization layer to the network. |
| 782 | |
| 783 | Args: |
| 784 | normalizationDescriptor (NormalizationDescriptor): Parameters to configure the normalization. |
| 785 | name (str): Optional name for the layer. |
| 786 | |
| 787 | Returns: |
| 788 | IConnectableLayer: Interface for configuring the layer. |
| 789 | ") AddNormalizationLayer; |
| 790 | armnn::IConnectableLayer* AddNormalizationLayer(const armnn::NormalizationDescriptor& normalizationDescriptor, |
| 791 | const char* name = nullptr); |
| 792 | |
| 793 | %feature("docstring", |
| 794 | " |
| 795 | Adds a Pad layer to the network. |
| 796 | |
| 797 | Args: |
| 798 | padDescriptor (PadDescriptor): Padding configuration for the layer. See `PadDescriptor` for more details. |
| 799 | name (str): Optional name for the layer. |
| 800 | |
| 801 | Returns: |
| 802 | IConnectableLayer: Interface for configuring the layer. |
| 803 | ") AddPadLayer; |
| 804 | armnn::IConnectableLayer* AddPadLayer(const armnn::PadDescriptor& padDescriptor, |
| 805 | const char* name = nullptr); |
| 806 | |
| 807 | %feature("docstring", |
| 808 | " |
| 809 | Adds a Permute layer to the network. |
| 810 | |
| 811 | Args: |
| 812 | permuteDescriptor (PermuteDescriptor): Configuration of the permutation layer. |
| 813 | name (str): Optional name for the layer. |
| 814 | |
| 815 | Returns: |
| 816 | IConnectableLayer: Interface for configuring the layer. |
| 817 | ") AddPermuteLayer; |
| 818 | armnn::IConnectableLayer* AddPermuteLayer(const armnn::PermuteDescriptor& permuteDescriptor, |
| 819 | const char* name = nullptr); |
| 820 | |
| 821 | %feature("docstring", |
| 822 | " |
| 823 | Adds a Pooling layer to the network. Type of pooling is decided by the configuration. |
| 824 | |
| 825 | Args: |
| 826 | pooling2dDescriptor (Pooling2dDescriptor): Configuration for the pooling layer. |
| 827 | name (str): Optional name for the layer. |
| 828 | |
| 829 | Returns: |
| 830 | IConnectableLayer: Interface for configuring the layer. |
| 831 | ") AddPooling2dLayer; |
| 832 | armnn::IConnectableLayer* AddPooling2dLayer(const armnn::Pooling2dDescriptor& pooling2dDescriptor, |
Ryan OShea | 8965500 | 2022-03-09 02:07:24 +0000 | [diff] [blame] | 833 | const char* name = nullptr); |
| 834 | |
| 835 | %feature("docstring", |
| 836 | " |
| 837 | Adds a 3D Pooling layer to the network. Type of 3D pooling is decided by the configuration. |
| 838 | |
| 839 | Args: |
| 840 | pooling3dDescriptor (Pooling3dDescriptor): Configuration for the 3D pooling layer. |
| 841 | name (str): Optional name for the layer. |
| 842 | |
| 843 | Returns: |
| 844 | IConnectableLayer: Interface for configuring the layer. |
| 845 | ") AddPooling3dLayer; |
| 846 | armnn::IConnectableLayer* AddPooling3dLayer(const armnn::Pooling3dDescriptor& pooling3dDescriptor, |
| 847 | const char* name = nullptr); |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 848 | |
| 849 | %feature("docstring", |
| 850 | " |
| 851 | Adds a PReLU layer to the network. |
| 852 | |
| 853 | Args: |
| 854 | name (str): Optional name for the layer. |
| 855 | |
| 856 | Returns: |
| 857 | IConnectableLayer: Interface for configuring the layer. |
| 858 | ") AddPreluLayer; |
| 859 | armnn::IConnectableLayer* AddPreluLayer(const char* name = nullptr); |
| 860 | |
| 861 | %feature("docstring", |
| 862 | " |
| 863 | Adds a Quantize layer to the network. |
| 864 | |
| 865 | Args: |
| 866 | name (str): Optional name for the layer. |
| 867 | |
| 868 | Returns: |
| 869 | IConnectableLayer: Interface for configuring the layer. |
| 870 | ") AddQuantizeLayer; |
| 871 | armnn::IConnectableLayer* AddQuantizeLayer(const char* name = nullptr); |
| 872 | |
| 873 | %feature("docstring", |
| 874 | " |
| 875 | Adds a Quantized Long Short-Term Memory layer to the network. |
| 876 | |
| 877 | Args: |
| 878 | params (`QuantizedLstmInputParams`): The weights and biases for the Quantized LSTM cell. |
| 879 | name (str): Optional name for the layer. |
| 880 | |
| 881 | Returns: |
| 882 | IConnectableLayer: Interface for configuring the layer. |
| 883 | ") AddQuantizedLstmLayer; |
| 884 | armnn::IConnectableLayer* AddQuantizedLstmLayer(const armnn::QuantizedLstmInputParams& params, |
| 885 | const char* name = nullptr); |
| 886 | |
Jan Eilers | 841aca1 | 2020-08-12 14:59:06 +0100 | [diff] [blame] | 887 | %feature("docstring", |
| 888 | " |
| 889 | Adds a Rank layer to the network. |
| 890 | |
| 891 | Args: |
| 892 | name (str): Optional name for the layer. |
| 893 | |
| 894 | Returns: |
| 895 | IConnectableLayer: Interface for configuring the layer. |
| 896 | ") AddRankLayer; |
| 897 | armnn::IConnectableLayer* AddRankLayer(const char* name = nullptr); |
| 898 | |
Ryan OShea | 09a0522 | 2021-11-18 16:52:41 +0000 | [diff] [blame] | 899 | %feature("docstring", |
| 900 | " |
| 901 | Adds a Reduce layer to the network. |
| 902 | |
| 903 | Args: |
| 904 | reduceDescriptor (ReduceDescriptor): Parameters for the reduce operation. |
| 905 | name (str): Optional name for the layer. |
| 906 | |
| 907 | Returns: |
| 908 | IConnectableLayer: Interface for configuring the layer. |
| 909 | ") AddReduceLayer; |
| 910 | armnn::IConnectableLayer* AddReduceLayer(const armnn::ReduceDescriptor& reduceDescriptor, |
| 911 | const char* name = nullptr); |
Cathal Corbett | 2b4182f | 2021-11-18 10:28:47 +0000 | [diff] [blame] | 912 | |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 913 | %feature("docstring", |
| 914 | " |
| 915 | Adds a Reshape layer to the network. |
| 916 | |
| 917 | Args: |
| 918 | reshapeDescriptor (ReshapeDescriptor): Parameters for the reshape operation. |
| 919 | name (str): Optional name for the layer. |
| 920 | |
| 921 | Returns: |
| 922 | IConnectableLayer: Interface for configuring the layer. |
| 923 | ") AddReshapeLayer; |
| 924 | armnn::IConnectableLayer* AddReshapeLayer(const armnn::ReshapeDescriptor& reshapeDescriptor, |
| 925 | const char* name = nullptr); |
| 926 | |
| 927 | %feature("docstring", |
| 928 | " |
| 929 | Adds a Resize layer to the network. |
| 930 | |
| 931 | Args: |
| 932 | resizeDescriptor (ResizeDescriptor): Configuration for the resize layer. |
| 933 | name (str): Optional name for the layer. |
| 934 | |
| 935 | Returns: |
| 936 | IConnectableLayer: Interface for configuring the layer. |
| 937 | ") AddResizeLayer; |
| 938 | armnn::IConnectableLayer* AddResizeLayer(const armnn::ResizeDescriptor& resizeDescriptor, |
| 939 | const char* name = nullptr); |
| 940 | |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 941 | %feature("docstring", |
| 942 | " |
Ryan OShea | aeee9ad | 2021-11-18 17:43:55 +0000 | [diff] [blame] | 943 | Adds a Shape layer to the network. |
| 944 | |
| 945 | Args: |
| 946 | name(str): Optional name for the layer. |
| 947 | |
| 948 | Returns: |
| 949 | IConnectableLayer: Interface for configuring the layer |
| 950 | ") AddShapeLayer; |
| 951 | armnn::IConnectableLayer* AddShapeLayer(const char* name = nullptr); |
| 952 | |
| 953 | %feature("docstring", |
| 954 | " |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 955 | Adds a Slice layer to the network. |
| 956 | |
| 957 | Args: |
| 958 | sliceDescriptor (SliceDescriptor): Descriptor to configure the slice operation. |
| 959 | name (str): Optional name for the layer. |
| 960 | |
| 961 | Returns: |
| 962 | IConnectableLayer: Interface for configuring the layer. |
| 963 | ") AddSliceLayer; |
| 964 | armnn::IConnectableLayer* AddSliceLayer(const armnn::SliceDescriptor& sliceDescriptor, |
| 965 | const char* name = nullptr); |
| 966 | |
| 967 | %feature("docstring", |
| 968 | " |
| 969 | Adds a Softmax layer to the network. |
| 970 | |
| 971 | If the data type is `DataType_QuantisedAsymm8`, then the output quantization parameters |
| 972 | must have a scale of 1/256 and an offset of 0. |
| 973 | |
| 974 | Args: |
| 975 | softmaxDescriptor (SoftmaxDescriptor): Configuration for the softmax layer. |
| 976 | name (str): Optional name for the layer. |
| 977 | |
| 978 | Returns: |
| 979 | IConnectableLayer: Interface for configuring the layer. |
| 980 | ") AddSoftmaxLayer; |
| 981 | armnn::IConnectableLayer* AddSoftmaxLayer(const armnn::SoftmaxDescriptor& softmaxDescriptor, |
| 982 | const char* name = nullptr); |
| 983 | |
| 984 | %feature("docstring", |
| 985 | " |
| 986 | Adds a Space To Batch layer to the network. |
| 987 | |
| 988 | Args: |
| 989 | spaceToBatchNdDescriptor (SpaceToBatchNdDescriptor): Configuration for the space to batch layer. |
| 990 | name (str): Optional name for the layer. |
| 991 | |
| 992 | Returns: |
| 993 | IConnectableLayer: Interface for configuring the layer. |
| 994 | ") AddSpaceToBatchNdLayer; |
| 995 | armnn::IConnectableLayer* AddSpaceToBatchNdLayer(const armnn::SpaceToBatchNdDescriptor& spaceToBatchNdDescriptor, |
| 996 | const char* name = nullptr); |
| 997 | |
| 998 | %feature("docstring", |
| 999 | " |
| 1000 | Adds a space to depth layer to the network. |
| 1001 | |
| 1002 | Args: |
| 1003 | spaceToDepthDescriptor (SpaceToDepthDescriptor): Parameters for the space to depth operation. |
| 1004 | name (str): Optional name for the layer. |
| 1005 | |
| 1006 | Returns: |
| 1007 | IConnectableLayer: Interface for configuring the layer. |
| 1008 | ") AddSpaceToDepthLayer; |
| 1009 | armnn::IConnectableLayer* AddSpaceToDepthLayer(const armnn::SpaceToDepthDescriptor& spaceToDepthDescriptor, |
| 1010 | const char* name = nullptr); |
| 1011 | |
| 1012 | %feature("docstring", |
| 1013 | " |
| 1014 | Adds a Splitter layer to the network. |
| 1015 | |
| 1016 | Args: |
| 1017 | splitterDescriptor (SplitterDescriptor): Parameters to configure the splitter layer. |
| 1018 | name (str): Optional name for the layer. |
| 1019 | |
| 1020 | Returns: |
| 1021 | IConnectableLayer: Interface for configuring the layer. |
| 1022 | ") AddSplitterLayer; |
| 1023 | armnn::IConnectableLayer* AddSplitterLayer(const armnn::SplitterDescriptor& splitterDescriptor, |
| 1024 | const char* name = nullptr); |
| 1025 | |
| 1026 | %feature("docstring", |
| 1027 | " |
| 1028 | Adds a Stack layer to the network. |
| 1029 | |
| 1030 | Args: |
| 1031 | descriptor (StackDescriptor): Descriptor to configure the stack layer. |
| 1032 | name (str): Optional name for the layer. |
| 1033 | |
| 1034 | Returns: |
| 1035 | IConnectableLayer: Interface for configuring the layer. |
| 1036 | ") AddStackLayer; |
| 1037 | armnn::IConnectableLayer* AddStackLayer(const armnn::StackDescriptor& descriptor, |
| 1038 | const char* name = nullptr); |
| 1039 | |
| 1040 | %feature("docstring", |
| 1041 | " |
| 1042 | Adds a StandIn layer to the network. |
| 1043 | |
| 1044 | Args: |
| 1045 | descriptor (StandInDescriptor): Parameters to configure the standIn layer. |
| 1046 | name (str): Optional name for the layer. |
| 1047 | |
| 1048 | Returns: |
| 1049 | IConnectableLayer: Interface for configuring the layer. |
| 1050 | ") AddStandInLayer; |
| 1051 | armnn::IConnectableLayer* AddStandInLayer(const armnn::StandInDescriptor& descriptor, |
| 1052 | const char* name = nullptr); |
| 1053 | |
| 1054 | %feature("docstring", |
| 1055 | " |
| 1056 | Adds a Strided Slice layer to the network. |
| 1057 | |
| 1058 | Args: |
| 1059 | stridedSliceDescriptor (StridedSliceDescriptor): Parameters for the strided slice operation. |
| 1060 | name (str): Optional name for the layer. |
| 1061 | |
| 1062 | Returns: |
| 1063 | IConnectableLayer: Interface for configuring the layer. |
| 1064 | ") AddStridedSliceLayer; |
| 1065 | armnn::IConnectableLayer* AddStridedSliceLayer(const armnn::StridedSliceDescriptor& stridedSliceDescriptor, |
| 1066 | const char* name = nullptr); |
| 1067 | |
| 1068 | %feature("docstring", |
| 1069 | " |
| 1070 | Adds a Subtraction layer to the network. |
| 1071 | |
| 1072 | Args: |
| 1073 | name (str): Optional name for the layer. |
| 1074 | |
| 1075 | Returns: |
| 1076 | IConnectableLayer: Interface for configuring the layer. |
| 1077 | ") AddSubtractionLayer; |
| 1078 | armnn::IConnectableLayer* AddSubtractionLayer(const char* name = nullptr); |
| 1079 | |
| 1080 | %feature("docstring", |
| 1081 | " |
| 1082 | Adds a Switch layer to the network. |
| 1083 | |
| 1084 | Args: |
| 1085 | name (str): Optional name for the layer. |
| 1086 | |
| 1087 | Returns: |
| 1088 | IConnectableLayer: Interface for configuring the layer. |
| 1089 | ") AddSwitchLayer; |
| 1090 | armnn::IConnectableLayer* AddSwitchLayer(const char* name = nullptr); |
| 1091 | |
Cathal Corbett | 9f184c4 | 2021-11-10 12:14:39 +0000 | [diff] [blame] | 1092 | %feature("docstring", |
| 1093 | " |
| 1094 | Adds a Fully Connected layer to the network. Also known as a Linear or Dense layer. |
| 1095 | |
| 1096 | Args: |
| 1097 | fullyConnectedDescriptor (FullyConnectedDescriptor): Description of the fully connected layer. |
| 1098 | name (str): Optional name for the layer. |
| 1099 | |
| 1100 | Returns: |
| 1101 | IConnectableLayer: Interface for configuring the layer. |
| 1102 | ") AddFullyConnectedLayer; |
| 1103 | armnn::IConnectableLayer* AddFullyConnectedLayer(const armnn::FullyConnectedDescriptor& fullyConnectedDescriptor, |
| 1104 | const char* name = nullptr); |
| 1105 | |
Cathal Corbett | f0836e0 | 2021-11-18 18:17:38 +0000 | [diff] [blame] | 1106 | %feature("docstring", |
| 1107 | " |
| 1108 | Adds a LogicalBinary layer to the network. |
| 1109 | |
| 1110 | Args: |
| 1111 | logicalBinaryDescriptor (LogicalBinaryDescriptor): Description of the LogicalBinary layer. |
| 1112 | name (str): Optional name for the layer. |
| 1113 | |
| 1114 | Returns: |
| 1115 | IConnectableLayer: Interface for configuring the layer. |
| 1116 | ") AddLogicalBinaryLayer; |
| 1117 | armnn::IConnectableLayer* AddLogicalBinaryLayer(const armnn::LogicalBinaryDescriptor& logicalBinaryDescriptor, |
| 1118 | const char* name = nullptr); |
Cathal Corbett | 2b4182f | 2021-11-18 10:28:47 +0000 | [diff] [blame] | 1119 | |
| 1120 | %feature("docstring", |
| 1121 | " |
| 1122 | Adds a Transpose layer to the network. |
| 1123 | |
| 1124 | Args: |
| 1125 | transposeDescriptor (TransposeDescriptor): Description of the transpose layer. |
| 1126 | name (str): Optional name for the layer. |
| 1127 | |
| 1128 | Returns: |
| 1129 | IConnectableLayer: Interface for configuring the layer. |
| 1130 | ") AddTransposeLayer; |
| 1131 | armnn::IConnectableLayer* AddTransposeLayer(const armnn::TransposeDescriptor& transposeDescriptor, |
| 1132 | const char* name = nullptr); |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 1133 | }; |
| 1134 | |
| 1135 | %extend INetwork { |
| 1136 | |
| 1137 | INetwork() { |
| 1138 | return armnn::INetwork::CreateRaw(); |
| 1139 | } |
| 1140 | |
| 1141 | ~INetwork() { |
| 1142 | armnn::INetwork::Destroy($self); |
| 1143 | } |
| 1144 | |
| 1145 | %feature("docstring", |
Cathal Corbett | 9f184c4 | 2021-11-10 12:14:39 +0000 | [diff] [blame] | 1146 | " |
Cathal Corbett | 9f184c4 | 2021-11-10 12:14:39 +0000 | [diff] [blame] | 1147 | Adds a 2D Transpose Convolution layer to the network. |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 1148 | |
Cathal Corbett | 9f184c4 | 2021-11-10 12:14:39 +0000 | [diff] [blame] | 1149 | Args: |
| 1150 | descriptor (TransposeConvolution2dDescriptor): Descriptor containing all parameters to configure this layer. |
| 1151 | weights (ConstTensor): Tensor for the weights data. |
| 1152 | biases (ConstTensor): Optional tensor for the bias data. |
| 1153 | name (str): Optional name for the layer. |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 1154 | |
Cathal Corbett | 9f184c4 | 2021-11-10 12:14:39 +0000 | [diff] [blame] | 1155 | Returns: |
| 1156 | IConnectableLayer: Interface for configuring the layer. |
| 1157 | ") AddTransposeConvolution2dLayer; |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 1158 | armnn::IConnectableLayer* AddTransposeConvolution2dLayer(const armnn::TransposeConvolution2dDescriptor& descriptor, |
| 1159 | const armnn::ConstTensor& weights, |
| 1160 | armnn::ConstTensor* biases = nullptr, |
Cathal Corbett | 9f184c4 | 2021-11-10 12:14:39 +0000 | [diff] [blame] | 1161 | const char* name = nullptr) { |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 1162 | |
| 1163 | if (biases) { |
| 1164 | return $self->AddTransposeConvolution2dLayer(descriptor, weights, |
| 1165 | armnn::Optional<armnn::ConstTensor>(*biases), name); |
| 1166 | } else { |
| 1167 | return $self->AddTransposeConvolution2dLayer(descriptor, weights, |
| 1168 | armnn::Optional<armnn::ConstTensor>(), name); |
| 1169 | } |
| 1170 | } |
| 1171 | |
| 1172 | |
| 1173 | %feature("docstring", |
| 1174 | " |
| 1175 | Adds a 2D Convolution layer to the network. |
| 1176 | |
| 1177 | Args: |
| 1178 | convolution2dDescriptor (Convolution2dDescriptor): Description of the 2D convolution layer. |
| 1179 | weights (ConstTensor): Tensor for the weights data. |
| 1180 | biases (ConstTensor): Optional tensor for the bias data. If specified, must match the output tensor shape. |
| 1181 | name (str): Optional name for the layer. |
| 1182 | |
| 1183 | Returns: |
| 1184 | IConnectableLayer: Interface for configuring the layer. |
| 1185 | ") AddConvolution2dLayer; |
| 1186 | armnn::IConnectableLayer* AddConvolution2dLayer(const armnn::Convolution2dDescriptor& convolution2dDescriptor, |
Teresa Charlin | 1814733 | 2021-11-17 14:34:30 +0000 | [diff] [blame] | 1187 | const armnn::ConstTensor& weights, |
| 1188 | armnn::ConstTensor* biases = nullptr, |
| 1189 | const char* name = nullptr) { |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 1190 | |
| 1191 | if (biases) { |
| 1192 | return $self->AddConvolution2dLayer(convolution2dDescriptor, weights, |
| 1193 | armnn::Optional<armnn::ConstTensor>(*biases), name); |
| 1194 | } else { |
| 1195 | return $self->AddConvolution2dLayer(convolution2dDescriptor, weights, |
| 1196 | armnn::Optional<armnn::ConstTensor>(), name); |
| 1197 | } |
| 1198 | } |
| 1199 | |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 1200 | %feature("docstring", |
| 1201 | " |
| 1202 | Adds a 2D Depthwise Convolution layer to the network. |
| 1203 | |
| 1204 | Args: |
| 1205 | convolution2dDescriptor (DepthwiseConvolution2dDescriptor): Description of the 2D depthwise convolution layer. |
| 1206 | weights (ConstTensor): Tensor for the weights. Expected format: [channelMultiplier, inputChannels, height, width]. |
| 1207 | biases (ConstTensor): Optional tensor for the bias data. If specified, must match the output tensor shape. |
| 1208 | name (str): Optional name for the layer. |
| 1209 | |
| 1210 | Returns: |
| 1211 | IConnectableLayer: Interface for configuring the layer. |
| 1212 | ") AddDepthwiseConvolution2dLayer; |
| 1213 | |
| 1214 | armnn::IConnectableLayer* AddDepthwiseConvolution2dLayer( |
| 1215 | const armnn::DepthwiseConvolution2dDescriptor& convolution2dDescriptor, |
| 1216 | const armnn::ConstTensor& weights, |
| 1217 | const armnn::ConstTensor* biases = nullptr, |
| 1218 | const char* name = nullptr) { |
| 1219 | |
Colm Donelan | bd4491b | 2022-05-19 12:32:21 +0100 | [diff] [blame^] | 1220 | ARMNN_NO_DEPRECATE_WARN_BEGIN |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 1221 | if (biases) { |
| 1222 | return $self->AddDepthwiseConvolution2dLayer(convolution2dDescriptor, weights, |
| 1223 | armnn::Optional<armnn::ConstTensor>(*biases), name); |
| 1224 | } else { |
| 1225 | return $self->AddDepthwiseConvolution2dLayer(convolution2dDescriptor, weights, |
| 1226 | armnn::Optional<armnn::ConstTensor>(), name); |
| 1227 | } |
Colm Donelan | bd4491b | 2022-05-19 12:32:21 +0100 | [diff] [blame^] | 1228 | ARMNN_NO_DEPRECATE_WARN_END |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 1229 | } |
Colm Donelan | bd4491b | 2022-05-19 12:32:21 +0100 | [diff] [blame^] | 1230 | |
Richard Burton | dc0c6ed | 2020-04-08 16:39:05 +0100 | [diff] [blame] | 1231 | } |
| 1232 | |
| 1233 | %feature("docstring", |
| 1234 | " |
| 1235 | Interface class for an optimzied network object. Optimized networks are obtained after running `Optimize` on |
| 1236 | an `INetwork` object. |
| 1237 | Optimized networks are passed to `EnqueueWorkload`. |
| 1238 | |
| 1239 | Args: |
| 1240 | convolution2dDescriptor (DepthwiseConvolution2dDescriptor): Description of the 2D depthwise convolution layer. |
| 1241 | weights (ConstTensor): Tensor for the weights. Expected format: [channelMultiplier, inputChannels, height, width]. |
| 1242 | biases (ConstTensor): Optional tensor for the bias data. If specified, must match the output tensor shape. |
| 1243 | name (str): Optional name for the layer. |
| 1244 | |
| 1245 | Returns: |
| 1246 | IConnectableLayer: Interface for configuring the layer. |
| 1247 | ") IOptimizedNetwork; |
| 1248 | %nodefaultctor IOptimizedNetwork; |
| 1249 | %nodefaultdtor IOptimizedNetwork; |
| 1250 | class IOptimizedNetwork |
| 1251 | { |
| 1252 | }; |
| 1253 | |
| 1254 | %extend IOptimizedNetwork { |
| 1255 | |
| 1256 | ~IOptimizedNetwork() { |
| 1257 | armnn::IOptimizedNetwork::Destroy($self); |
| 1258 | } |
| 1259 | |
| 1260 | %feature("docstring", |
| 1261 | " |
| 1262 | Saves optimized network graph as dot file. |
| 1263 | |
| 1264 | Args: |
| 1265 | fileName (str): File path to save to. |
| 1266 | Raises: |
| 1267 | RuntimeError: If serialization failure. |
| 1268 | ") SerializeToDot; |
| 1269 | |
| 1270 | void SerializeToDot(const std::string& fileName) { |
| 1271 | std::ofstream dot; |
| 1272 | dot.open(fileName); |
| 1273 | if(!dot.is_open()) |
| 1274 | { |
| 1275 | throw armnn::Exception("Failed to open dot file"); |
| 1276 | } else { |
| 1277 | armnn::Status status = $self->SerializeToDot(dot); |
| 1278 | dot.close(); |
| 1279 | if(status == armnn::Status::Failure) |
| 1280 | { |
| 1281 | throw armnn::Exception("Failed to serialize to dot"); |
| 1282 | } |
| 1283 | } |
| 1284 | }; |
| 1285 | } |
| 1286 | } |
| 1287 | |
| 1288 | %{ |
| 1289 | std::pair<armnn::IOptimizedNetwork*, std::vector<std::string>> Optimize(const armnn::INetwork* network, |
| 1290 | const std::vector<armnn::BackendId>& backendPreferences, |
| 1291 | const armnn::IDeviceSpec& deviceSpec, |
| 1292 | const armnn::OptimizerOptions& options = armnn::OptimizerOptions()) |
| 1293 | { |
| 1294 | std::vector<std::string> errorMessages; |
| 1295 | armnn::IOptimizedNetwork* optimizedNetwork = armnn::Optimize(*network, backendPreferences, deviceSpec, |
| 1296 | options, armnn::Optional<std::vector<std::string> &>(errorMessages)).release(); |
| 1297 | |
| 1298 | if(!optimizedNetwork) |
| 1299 | { |
| 1300 | std::string errorString; |
| 1301 | |
| 1302 | for (auto error : errorMessages) { |
| 1303 | errorString.append(error); |
| 1304 | } |
| 1305 | |
| 1306 | throw armnn::Exception(errorString); |
| 1307 | } |
| 1308 | |
| 1309 | return std::make_pair(optimizedNetwork, errorMessages); |
| 1310 | }; |
| 1311 | %} |
| 1312 | |
| 1313 | %feature("docstring", |
| 1314 | " |
| 1315 | Create an optimized version of the given network. Should be called before loading a network into the runtime. |
| 1316 | |
| 1317 | Examples: |
| 1318 | Optimize a loaded network ready for inference. |
| 1319 | >>> parser = ann.ITfLiteParser() |
| 1320 | >>> network = parser.CreateNetworkFromBinaryFile('./model.tflite') |
| 1321 | >>> |
| 1322 | >>> preferredBackends = [ann.BackendId('CpuAcc'), ann.BackendId('CpuRef')] |
| 1323 | >>> opt_network, messages = ann.Optimize(network, preferredBackends, runtime.GetDeviceSpec(), ann.OptimizerOptions()) |
| 1324 | |
| 1325 | Args: |
| 1326 | network (INetwork): INetwork description of the network to be optimized. |
| 1327 | backendPreferences (list): The choice of the backend ordered by user preferences. See `BackendId`. |
| 1328 | deviceSpec (IDeviceSpec): DeviceSpec object as queried from the runtime. See `IRuntime.GetDeviceSpec`. |
| 1329 | options (OptimizerOptions): Object with optimizer configuration options. |
| 1330 | |
| 1331 | Returns: |
| 1332 | tuple: (`IOptimizedNetwork`, a tuple of failures or warnings). |
| 1333 | |
| 1334 | Raises: |
| 1335 | RuntimeError: If process fails. |
| 1336 | ") Optimize; |
| 1337 | |
| 1338 | %optimize_typemap_out; |
| 1339 | std::pair<armnn::IOptimizedNetwork*, std::vector<std::string>> Optimize(const armnn::INetwork* network, |
| 1340 | const std::vector<armnn::BackendId>& backendPreferences, |
| 1341 | const armnn::IDeviceSpec& deviceSpec, |
| 1342 | const armnn::OptimizerOptions& options = OptimizerOptions()); |
| 1343 | %clear_optimize_typemap_out; |