ArmNN
 23.02
INetwork.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017,2022 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
8 #include <armnn/Deprecated.hpp>
10 #include <armnn/IStrategy.hpp>
11 #include <armnn/NetworkFwd.hpp>
12 #include <armnn/Optional.hpp>
13 #include <armnn/TensorFwd.hpp>
14 #include <armnn/Logging.hpp>
16 
17 #include <memory>
18 #include <vector>
19 
20 namespace armnn
21 {
22 /// @brief An input connection slot for a layer.
23 /// The input slot can be connected to an output slot of the preceding layer in the graph.
24 /// Only one connection to the input slot is allowed.
26 {
27 public:
28  virtual const IOutputSlot* GetConnection() const = 0;
29  virtual IOutputSlot* GetConnection() = 0;
30  virtual const IConnectableLayer& GetOwningIConnectableLayer() const = 0;
32  virtual unsigned int GetSlotIndex() const = 0;
33 
34 protected:
35  /// Not user deletable.
37 };
38 
39 /// @brief An output connection slot for a layer.
40 /// The output slot may be connected to 1 or more input slots of subsequent layers in the graph.
42 {
43 public:
44  virtual unsigned int GetNumConnections() const = 0;
45  virtual const IInputSlot* GetConnection(unsigned int index) const = 0;
46  virtual IInputSlot* GetConnection(unsigned int outputindex) = 0;
47 
48  virtual void SetTensorInfo(const TensorInfo& tensorInfo) = 0;
49  virtual const TensorInfo& GetTensorInfo() const = 0;
50  virtual bool IsTensorInfoSet() const = 0;
51 
52  virtual int Connect(IInputSlot& destination) = 0;
53  virtual void Disconnect(IInputSlot& slot) = 0;
54 
55  virtual unsigned int CalculateIndexOnOwner() const = 0;
56 
57  virtual LayerGuid GetOwningLayerGuid() const = 0;
58 
59  virtual const IConnectableLayer& GetOwningIConnectableLayer() const = 0;
61 
62 protected:
63  /// Not user deletable.
65 };
66 
67 /// @brief Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
69 {
70 public:
71  /// Returns the name of the layer
72  virtual const char* GetName() const = 0;
73 
74  /// Returns the number of connectable input slots
75  virtual unsigned int GetNumInputSlots() const = 0;
76 
77  /// Returns the number of connectable output slots
78  virtual unsigned int GetNumOutputSlots() const = 0;
79 
80  /// Get a const input slot handle by slot index
81  virtual const IInputSlot& GetInputSlot(unsigned int index) const = 0;
82 
83  /// Get the input slot handle by slot index
84  virtual IInputSlot& GetInputSlot(unsigned int index) = 0;
85 
86  /// Get the const output slot handle by slot index
87  virtual const IOutputSlot& GetOutputSlot(unsigned int index) const = 0;
88 
89  /// Get the output slot handle by slot index
90  virtual IOutputSlot& GetOutputSlot(unsigned int index) = 0;
91 
92  /// Infer the shape of the output(s) based on the provided input shape(s)
93  virtual std::vector<TensorShape> InferOutputShapes(const std::vector<TensorShape>& inputShapes) const = 0;
94 
95  /// Returns the unique id of the layer
96  virtual LayerGuid GetGuid() const = 0;
97 
98  /// Apply a visitor to this layer
99  virtual void ExecuteStrategy(IStrategy& strategy) const = 0;
100 
101  /// Provide a hint for the optimizer as to which backend to prefer for this layer.
102  /// By providing a BackendSelectionHint there is no guarantee the input backend supports that layer.
103  /// If IsLayerSupported() returns false with the backend hint, we default to calling IsLayerSupported()
104  /// on the BackendPreferences vector. Use SetBackendId() if we can guarantee a backend supports that
105  /// layer (IsLayerSupported returns true for a specific backend).
106  virtual void BackendSelectionHint(Optional<BackendId> backend) = 0;
107 
108  /// Returns the armnn::LayerType of this layer
109  virtual LayerType GetType() const = 0;
110 
111  /// If the layer has a descriptor return it.
112  /// The base descriptor can then be cast to the correct descriptor class.
113  /// If the layer has no associated descriptor a struct of type NullDescriptor will be returned.
114  /// Note: NullDescriptors can be detected because they return true when
115  /// the BaseDescriptor IsNull function is invoked.
116  virtual const BaseDescriptor& GetParameters() const = 0;
117 
118  /// Set the backend of the IConnectableLayer.
119  /// By using SetBackendId() we guarantee that the input backend supports that
120  /// layer (IsLayerSupported returns true for a specific backend). If there is
121  /// no guarantee the input backend supports that layer use BackendSelectionHint().
122  virtual void SetBackendId(const BackendId& id) = 0;
123 
124  using ConstantTensors = std::vector<std::reference_wrapper<std::shared_ptr<ConstTensorHandle>>>;
125 
126  // Returns ConstantTensors of this Layer if it has any, otherwise returns empty vector.
128 
129 protected:
130  /// Objects are not deletable via the handle
132 };
133 
134 
135 /// ArmNN performs an optimization on each model/network before it gets loaded for execution. OptimizerOptions provides
136 /// a set of features that allows the user to customize this optimization on a per model basis.
138 {
140  : m_ReduceFp32ToFp16(false)
141  , m_Debug(false)
142  , m_DebugToFile(false)
143  , m_ReduceFp32ToBf16(false)
145  , m_ImportEnabled(false)
146  , m_ModelOptions()
147  , m_ProfilingEnabled(false)
148  , m_ExportEnabled(false)
149  , m_AllowExpandedDims(false)
150  {}
151 
152  OptimizerOptions(bool reduceFp32ToFp16, bool debug, bool reduceFp32ToBf16, bool importEnabled,
153  ModelOptions modelOptions = {}, bool exportEnabled = false, bool debugToFile = false)
154  : m_ReduceFp32ToFp16(reduceFp32ToFp16)
155  , m_Debug(debug)
156  , m_DebugToFile(debugToFile)
157  , m_ReduceFp32ToBf16(reduceFp32ToBf16)
159  , m_ImportEnabled(importEnabled)
160  , m_ModelOptions(modelOptions)
161  , m_ProfilingEnabled(false)
162  , m_ExportEnabled(exportEnabled)
163  , m_AllowExpandedDims(false)
164  {
165  }
166 
167  OptimizerOptions(bool reduceFp32ToFp16, bool debug, bool reduceFp32ToBf16 = false,
169  bool importEnabled = false, ModelOptions modelOptions = {}, bool exportEnabled = false,
170  bool debugToFile = false, bool allowExpandedDims = false)
171  : m_ReduceFp32ToFp16(reduceFp32ToFp16)
172  , m_Debug(debug)
173  , m_DebugToFile(debugToFile)
174  , m_ReduceFp32ToBf16(reduceFp32ToBf16)
175  , m_shapeInferenceMethod(shapeInferenceMethod)
176  , m_ImportEnabled(importEnabled)
177  , m_ModelOptions(modelOptions)
178  , m_ProfilingEnabled(false)
179  , m_ExportEnabled(exportEnabled)
180  , m_AllowExpandedDims(allowExpandedDims)
181  {
182  }
183 
184  const std::string ToString() const
185  {
186  std::stringstream stream;
187  stream << "OptimizerOptions: \n";
188  stream << "\tReduceFp32ToFp16: " << m_ReduceFp32ToFp16 << "\n";
189  stream << "\tReduceFp32ToBf16: " << m_ReduceFp32ToBf16 << "\n";
190  stream << "\tDebug: " << m_Debug << "\n";
191  stream << "\tDebug to file: " << m_DebugToFile << "\n";
192  stream << "\tShapeInferenceMethod: " <<
193  (m_shapeInferenceMethod == ShapeInferenceMethod::ValidateOnly ? "ValidateOnly" : "InferAndValidate") << "\n";
194  stream << "\tImportEnabled: " << m_ImportEnabled << "\n";
195  stream << "\tExportEnabled: " << m_ExportEnabled << "\n";
196  stream << "\tProfilingEnabled: " << m_ProfilingEnabled << "\n";
197  stream << "\tAllowExpandedDims: " << m_AllowExpandedDims << "\n";
198 
199  stream << "\tModelOptions: \n";
200  for (auto optionsGroup : m_ModelOptions)
201  {
202  for (size_t i=0; i < optionsGroup.GetOptionCount(); i++)
203  {
204  const armnn::BackendOptions::BackendOption option = optionsGroup.GetOption(i);
205  stream << "\t\tBackend: " << optionsGroup.GetBackendId() << "\n"
206  << "\t\t\tOption: " << option.GetName() << "\n"
207  << "\t\t\tValue: " << std::string(option.GetValue().ToString()) << "\n";
208  }
209  }
210 
211  return stream.str();
212  }
213 
214  /// Reduces all Fp32 operators in the model to Fp16 for faster processing.
215  /// @Note This feature works best if all operators of the model are in Fp32. ArmNN will add conversion layers
216  /// between layers that weren't in Fp32 in the first place or if the operator is not supported in Fp16.
217  /// The overhead of these conversions can lead to a slower overall performance if too many conversions are
218  /// required.
220 
221  /// Add debug data for easier troubleshooting
222  bool m_Debug;
223 
224  /// Pass debug data to separate output files for easier troubleshooting
226 
227  /// @Note This feature has been replaced by enabling Fast Math in compute library backend options.
228  /// This is currently a placeholder option
230 
231  /// Infer output size when not available
233 
234  /// Enable Import
236 
237  /// Enable Model Options
239 
240  /// Enable profiling dump of the optimizer phase
242 
243  /// Enable Export
245 
246  /// When calculating tensor sizes, dimensions of size == 1 will be ignored
248 };
249 
250 class IWorkloadFactory;
251 class NetworkImpl;
252 using INetworkPtr = std::unique_ptr<INetwork, void(*)(INetwork* network)>;
253 using IOptimizedNetworkPtr = std::unique_ptr<IOptimizedNetwork, void(*)(IOptimizedNetwork* network)>;
254 
255 using CompiledBlobDeleter = std::function<void(const void*)>;
256 using CompiledBlobPtr = std::unique_ptr<void, CompiledBlobDeleter>;
257 
258 /// Main network class which provides the interface for building up a neural network.
259 /// This object is subsequently required by the IRuntime::Load() method.
260 class INetwork
261 {
262 public:
263  static INetwork* CreateRaw(const NetworkOptions& networkOptions = {});
264  static INetworkPtr Create(const NetworkOptions& networkOptions = {});
265  static void Destroy(INetwork* network);
266 
267  Status PrintGraph();
268 
269  /// Adds an input layer to the network.
270  /// @param id - User generated id to uniquely identify a particular input. The same id needs to be specified.
271  /// when passing the inputs to the IRuntime::EnqueueWorkload() function.
272  /// @param name - Optional name for the layer.
273  /// @return - Interface for configuring the layer.
274  IConnectableLayer* AddInputLayer(LayerBindingId id, const char* name = nullptr);
275 
276  /// Adds an ArgMinMax layer to the network.
277  /// @param desc - Parameters for the L2 normalization operation.
278  /// @param name - Optional name for the layer.
279  /// @return - Interface for configuring the layer.
281  const char* name = nullptr);
282 
283  /// Adds a cast layer to the network.
284  /// @param name - Optional name for the layer.
285  /// @return - Interface for configuring the layer.
286  IConnectableLayer* AddCastLayer(const char* name = nullptr);
287 
288  /// Add a Comparison layer to the network.
289  /// @param name - Optional name for the layer.
290  /// @param desc - Descriptor for the comparison operation.
291  /// @return - Interface for configuring the layer.
292  IConnectableLayer* AddComparisonLayer(const ComparisonDescriptor& comparisonDescriptor,
293  const char* name = nullptr);
294 
295  /// Adds a concatenation layer to the network.
296  /// @param concatDescriptor - ConcatDescriptor (synonym for OriginsDescriptor) to configure the concatenation
297  /// process. Number of Views must be equal to the number of inputs, and their order
298  /// must match - e.g. first view corresponds to the first input, second view to the
299  /// second input, etc....
300  /// @param name - Optional name for the layer.
301  /// @return - Interface for configuring the layer.
302  IConnectableLayer* AddConcatLayer(const ConcatDescriptor& concatDescriptor,
303  const char* name = nullptr);
304 
305  /// Adds a 2D convolution layer to the network.
306  /// @param convolution2dDescriptor - Description of the 2D convolution layer.
307  /// @param name - Optional name for the layer.
308  /// @return - Interface for configuring the layer.
309  IConnectableLayer* AddConvolution2dLayer(const Convolution2dDescriptor& convolution2dDescriptor,
310  const char* name = nullptr);
311 
312  /// Adds a 3D convolution layer to the network.
313  /// @param convolution3dDescriptor - Description of the 3D convolution layer.
314  /// @param name - Optional name for the layer.
315  /// @return - Interface for configuring the layer.
316  IConnectableLayer* AddConvolution3dLayer(const Convolution3dDescriptor& convolution3dDescriptor,
317  const char* name = nullptr);
318 
319  /// Adds a depth to space layer to the network.
320  /// @param depthToSpaceDescriptor - Parameters for the depth to space operation.
321  /// @param name - Optional name for the layer.
322  /// @return - Interface for configuring the layer.
323  IConnectableLayer* AddDepthToSpaceLayer(const DepthToSpaceDescriptor& depthToSpaceDescriptor,
324  const char* name = nullptr);
325 
326  /// Adds a 2D depthwise convolution layer to the network.
327  /// @param convolution2dDescriptor - Description of the 2D depthwise convolution layer.
328  /// @param name - Optional name for the layer.
329  /// @return - Interface for configuring the layer.
331  const char* name = nullptr);
332 
333  /// Adds a Dequantize layer to the network.
334  /// @return - Interface for configuring the layer.
335  IConnectableLayer* AddDequantizeLayer(const char* name = nullptr);
336 
337  /// Adds a Detection PostProcess layer to the network.
338  /// @param descriptor - Description of the Detection PostProcess layer.
339  /// @param anchors - Tensor for anchors.
340  /// @param name - Optional name for the layer.
341  /// @return - Interface for configuring the layer.
343  const DetectionPostProcessDescriptor& descriptor,
344  const ConstTensor& anchors,
345  const char* name = nullptr);
346 
347  /// Add an ElementwiseUnary layer to the network.
348  /// @param name - Optional name for the layer.
349  /// @param desc - Descriptor for the elementwiseUnary operation.
350  /// @return - Interface for configuring the layer.
351  IConnectableLayer* AddElementwiseUnaryLayer(const ElementwiseUnaryDescriptor& elementwiseUnaryDescriptor,
352  const char* name = nullptr);
353 
354  /// Add an Fill layer to the network.
355  /// @param name - Optional name for the layer.
356  /// @param fillDescriptor - Descriptor for the fill operation.
357  /// @return - Interface for configuring the layer.
358  IConnectableLayer* AddFillLayer(const FillDescriptor& fillDescriptor,
359  const char* name = nullptr);
360 
361 
362  /// Adds a fully connected layer to the network.
363  /// @param fullyConnectedDescriptor - Description of the fully connected layer.
364  /// @return - Interface for configuring the layer.
365  ///
366  /// @note Weights and biases are passed in as inputs. If they are constant tensors you can simply store
367  /// them in a ConstantLayer as seen below. A full example can be found in samples/SimpleSample.cpp.
368  ///
369  /// @code
370  /// // Make sure the IsConstant flag is set on the weightsInfo before passing it to the ConstTensor.
371  /// ConstTensor weights(weightsInfo, weightsData);
372  ///
373  /// // Constant layer that now holds weights data for FullyConnected
374  /// IConnectableLayer* const constantWeightsLayer = myNetwork->AddConstantLayer(weights, "weights");
375  ///
376  /// FullyConnectedDescriptor fullyConnectedDesc;
377  /// IConnectableLayer* const fullyConnectedLayer = myNetwork->AddFullyConnectedLayer(fullyConnectedDesc,
378  /// "fully connected");
379  /// IConnectableLayer* InputLayer = myNetwork->AddInputLayer(0);
380  /// InputLayer->GetOutputSlot(0).Connect(fullyConnectedLayer->GetInputSlot(0));
381  /// constantWeightsLayer->GetOutputSlot(0).Connect(fullyConnectedLayer->GetInputSlot(1));
382  /// @endcode
383  IConnectableLayer* AddFullyConnectedLayer(const FullyConnectedDescriptor& fullyConnectedDescriptor,
384  const char* name = nullptr);
385 
386  /// Adds a permute layer to the network.
387  /// @param permuteDescriptor - PermuteDescriptor to configure the permute.
388  /// @param name - Optional name for the layer.
389  /// @return - Interface for configuring the layer.
390  IConnectableLayer* AddPermuteLayer(const PermuteDescriptor& permuteDescriptor,
391  const char* name = nullptr);
392 
393  /// Adds a batch to space ND layer to the network.
394  /// @param batchToSpaceNdDescriptor - Description of the layer.
395  /// @param name - Optional name for the layer.
396  /// @return - Interface for configuring the layer.
397  IConnectableLayer* AddBatchToSpaceNdLayer(const BatchToSpaceNdDescriptor& batchToSpaceNdDescriptor,
398  const char* name = nullptr);
399 
400  /// Adds a 2D pooling layer to the network.
401  /// @param pooling2dDescriptor - Pooling2dDescriptor to configure the pooling.
402  /// @param name - Optional name for the layer.
403  /// @return - Interface for configuring the layer.
404  IConnectableLayer* AddPooling2dLayer(const Pooling2dDescriptor& pooling2dDescriptor,
405  const char* name = nullptr);
406 
407  /// Adds a 3D pooling layer to the network.
408  /// @param pooling3dDescriptor - Pooling3dDescriptor to configure the pooling.
409  /// @param name - Optional name for the layer.
410  /// @return - Interface for configuring the layer.
411  IConnectableLayer* AddPooling3dLayer(const Pooling3dDescriptor& pooling3dDescriptor,
412  const char* name = nullptr);
413 
414  /// Adds a Precompiled layer to the network.
415  /// Method use is for backend users.
416  /// @param preCompiledDescriptor - PreCompiledDescriptor contains parameters for the Precompiled layer.
417  /// @param compiledBlobPtr - CompiledBlobPtr pre-compiled object set for the Precompiled layer.
418  /// @param backend - optional BackendId set for the Precompiled layer.
419  /// @return - Interface for configuring the layer.
420  IConnectableLayer* AddPrecompiledLayer(const PreCompiledDescriptor& preCompiledDescriptor,
421  CompiledBlobPtr compiledBlobPtr,
422  const Optional<BackendId>& backend,
423  const char* name = nullptr);
424 
425  /// Adds an activation layer to the network.
426  /// @param activationDescriptor - ActivationDescriptor to configure the activation.
427  /// @param name - Optional name for the layer.
428  /// @return - Interface for configuring the layer.
429  IConnectableLayer* AddActivationLayer(const ActivationDescriptor& activationDescriptor,
430  const char* name = nullptr);
431 
432  /// Adds a normalization layer to the network.
433  /// @param normalizationDescriptor - NormalizationDescriptor to configure the normalization.
434  /// @param name - Optional name for the layer.
435  /// @return - Interface for configuring the layer.
436  IConnectableLayer* AddNormalizationLayer(const NormalizationDescriptor& normalizationDescriptor,
437  const char* name = nullptr);
438 
439  /// Adds a slice layer to the network.
440  /// @param sliceDescriptor - SliceDescriptor to configure the slice operation.
441  /// @param name - Optional name for the layer.
442  /// @return - Interface for configuring the layer.
443  IConnectableLayer* AddSliceLayer(const SliceDescriptor& sliceDescriptor, const char* name = nullptr);
444 
445  /// Adds a softmax layer to the network.
446  /// If the data type is QAsymm8, then the output quantization parameters
447  /// must have a scale of 1/256 and an offset of 0
448  /// @param softmaxDescriptor - SoftmaxDescriptor to configure the softmax.
449  /// @param name - Optional name for the layer.
450  /// @return - Interface for configuring the layer.
451  IConnectableLayer* AddSoftmaxLayer(const SoftmaxDescriptor& softmaxDescriptor,
452  const char* name = nullptr);
453 
454  /// Adds a splitter layer to the network.
455  /// @param splitterDescriptor - ViewsDescriptor to configure the splitting process.
456  /// Number of Views must be equal to the number of outputs,
457  /// and their order must match - e.g. first view corresponds to
458  /// the first output, second view to the second output, etc....
459  /// @param name - Optional name for the layer.
460  /// @return - Interface for configuring the layer.
461  IConnectableLayer* AddSplitterLayer(const ViewsDescriptor& splitterDescriptor,
462  const char* name = nullptr);
463 
464  /// Adds a merge layer to the network.
465  /// @param name - Optional name for the layer.
466  /// @return - Interface for configuring the layer.
467  IConnectableLayer* AddMergeLayer(const char* name = nullptr);
468 
469  /// Adds an addition layer to the network.
470  /// @param name - Optional name for the layer.
471  /// @return - Interface for configuring the layer.
472  IConnectableLayer* AddAdditionLayer(const char* name = nullptr);
473 
474  /// Adds a multiplication layer to the network.
475  /// @param name - Optional name for the layer.
476  /// @return - Interface for configuring the layer.
477  IConnectableLayer* AddMultiplicationLayer(const char* name = nullptr);
478 
479  /// Adds a batch normalization layer to the network.
480  /// @param mean - Pre-calculated mean for each channel.
481  /// @param variance - Pre-calculated variance for each channel.
482  /// @param beta - Per-channel additive factor.
483  /// @param gamma - Per-channel multiplicative factor.
484  /// @return - Interface for configuring the layer.
485  /// @param name - Optional name for the layer.
487  const ConstTensor& mean,
488  const ConstTensor& variance,
489  const ConstTensor& beta,
490  const ConstTensor& gamma,
491  const char* name = nullptr);
492 
493  /// Adds a rank layer to the network.
494  /// @param name - Optional name for the layer.
495  /// @return - Interface for configuring the layer.
496  IConnectableLayer* AddRankLayer(const char* name = nullptr);
497 
498  /// Adds a resize layer to the network.
499  /// @param resizeDescriptor - Parameters for the resize operation.
500  /// @param name - Optional name for the layer.
501  /// @return - Interface for configuring the layer.
502  IConnectableLayer* AddResizeLayer(const ResizeDescriptor& resizeDescriptor,
503  const char* name = nullptr);
504 
505  /// Adds a reduce layer to the network.
506  /// @param ReduceDescriptor - Parameters for the reduce operation.
507  /// @param name - Optional name for the layer.
508  /// @return - Interface for configuring the layer.
509  IConnectableLayer* AddReduceLayer(const ReduceDescriptor& reduceDescriptor,
510  const char* name = nullptr);
511 
512  /// Adds an instance normalization layer to the network.
513  /// @param desc - Parameters for the instance normalization operation.
514  /// @param name - Optional name for the layer.
515  /// @return - Interface for configuring the layer.
517  const char* name = nullptr);
518 
519  /// Adds an L2 normalization layer to the network.
520  /// Normalization is performed along dimension 1, but requires a 4d input.
521  /// @param desc - Parameters for the L2 normalization operation.
522  /// @param name - Optional name for the layer.
523  /// @return - Interface for configuring the layer.
525  const char* name = nullptr);
526 
527  /// Adds a log softmax layer to the network.
528  /// @param logSoftmaxDescriptor - LogSoftmaxDescriptor to configure the log softmax.
529  /// @param name - Optional name for the layer.
530  /// @return - Interface for configuring the layer.
531  IConnectableLayer* AddLogSoftmaxLayer(const LogSoftmaxDescriptor& logSoftmaxDescriptor,
532  const char* name = nullptr);
533 
534  /// Adds a layer with no inputs and a single output, which always corresponds to
535  /// the passed in constant tensor.
536  /// @param input - Tensor to be provided as the only output of the layer. The layer will maintain
537  /// its own copy of the tensor data, meaning the memory referenced by @a input can
538  /// be freed or reused after this function is called.
539  /// @param name - Optional name for the layer.
540  /// @return - Interface for configuring the layer.
542  const char* name = nullptr);
543 
544  /// Adds a reshape layer to the network.
545  /// @param reshapeDescriptor - Parameters for the reshape operation.
546  /// @param name - Optional name for the layer.
547  /// @return - Interface for configuring the layer.
548  IConnectableLayer* AddReshapeLayer(const ReshapeDescriptor& reshapeDescriptor,
549  const char* name = nullptr);
550 
551  /// Adds a shape layer to the network.
552  /// @param name - Optional name for the layer.
553  /// @return - Interface for configuring the layer.
554  IConnectableLayer* AddShapeLayer(const char* name = nullptr);
555 
556  /// Adds a space to batch layer to the network.
557  /// @param spaceToBatchNdDescriptor - Parameters for the space to batch operation.
558  /// @param name - Optional name for the layer.
559  /// @return - Interface for configuring the layer.
560  IConnectableLayer* AddSpaceToBatchNdLayer(const SpaceToBatchNdDescriptor& spaceToBatchNdDescriptor,
561  const char* name = nullptr);
562 
563  /// Adds a space to depth layer to the network.
564  /// @param spaceToDepthDescriptor - Parameters for the space to depth operation.
565  /// @param name - Optional name for the layer.
566  /// @return - Interface for configuring the layer.
567  IConnectableLayer* AddSpaceToDepthLayer(const SpaceToDepthDescriptor& spaceToDepthDescriptor,
568  const char* name = nullptr);
569 
570  /// Adds a floor layer to the network.
571  /// @param name - Optional name for the layer.
572  /// @return - Interface for configuring the layer.
573  IConnectableLayer* AddFloorLayer(const char* name = nullptr);
574 
575  /// Adds an output layer to the network.
576  /// @param id - User generated id to uniquely identify a particular output. The same id needs to be specified
577  /// when passing the outputs to the IRuntime::EnqueueWorkload() function.
578  /// @param name - Optional name for the layer.
579  /// @return - Interface for configuring the layer.
580  IConnectableLayer* AddOutputLayer(LayerBindingId id, const char* name = nullptr);
581 
582  /// Add a Lstm layer to the network
583  /// @param descriptor - Parameters for the Lstm operation
584  /// @param params - Weights and biases for the LSTM cell
585  /// @param name - Optional name for the layer
586  /// @return - Interface for configuring the layer.
587  IConnectableLayer* AddLstmLayer(const LstmDescriptor& descriptor,
588  const LstmInputParams& params,
589  const char* name = nullptr);
590 
591  /// Adds a division layer to the network.
592  /// @param name - Optional name for the layer.
593  /// @return - Interface for configuring the layer.
594  IConnectableLayer* AddDivisionLayer(const char* name = nullptr);
595 
596  /// Adds a subtraction layer to the network.
597  /// @param name - Optional name for the layer.
598  /// @return - Interface for configuring the layer.
599  IConnectableLayer* AddSubtractionLayer(const char* name = nullptr);
600 
601  /// Add a Maximum layer to the network.
602  /// @param name - Optional name for the layer.
603  /// @return - Interface for configuring the layer.
604  IConnectableLayer* AddMaximumLayer(const char* name = nullptr);
605 
606  /// Add a Mean layer to the network.
607  /// @param meanDescriptor - Parameters for the mean operation.
608  /// @param name - Optional name for the layer.
609  /// @return - Interface for configuring the layer.
610  IConnectableLayer* AddMeanLayer(const MeanDescriptor& meanDescriptor, const char* name = nullptr);
611 
612  /// Adds a fully pad layer to the network.
613  /// @param paddings - n by 2 tensor, where n is the rank of the input tensor,
614  /// such that paddings[i,0] indicates the amount of padding to add in front of dimonsion i, and
615  /// paddings[i,1] indicates the amount of padding to add after the end of dimension i
616  /// @param name - Optional name for the layer.
617  /// @return - Interface for configuring the layer.
618  IConnectableLayer* AddPadLayer(const PadDescriptor& padDescriptor,
619  const char* name = nullptr);
620 
621  /// Add a quantize layer to the network
622  ///@param name - Optional name for the layer.
623  /// @return - Interface for configuring the layer.
624  IConnectableLayer* AddQuantizeLayer(const char* name = nullptr);
625 
626  /// Adds a strided slice layer to the network.
627  /// @param StridedSliceDescriptor - Parameters for the strided slice operation.
628  /// @param name - Optional name for the layer.
629  /// @return - Interface for configuring the layer.
630  IConnectableLayer* AddStridedSliceLayer(const StridedSliceDescriptor& stridedSliceDescriptor,
631  const char* name = nullptr);
632 
633  /// Add a Minimum layer to the network.
634  /// @param name - Optional name for the layer.
635  /// @return - Interface for configuring the layer.
636  IConnectableLayer* AddMinimumLayer(const char* name = nullptr);
637 
638  /// Add Gather layer to the network.
639  /// @param descriptor - Description of the gather layer.
640  /// @param name - Optional name for the layer.
641  /// @return - Interface for configuring the layer.
643  const char* name = nullptr);
644 
645  /// Add GatherNd layer to the network.
646  /// @param name - Optional name for the layer.
647  /// @return - Interface for configuring the layer.
648  IConnectableLayer* AddGatherNdLayer(const char* name = nullptr);
649 
650  /// Adds a switch layer to the network.
651  /// @param name - Optional name for the layer.
652  /// @return - Interface for configuring the layer.
653  IConnectableLayer* AddSwitchLayer(const char* name = nullptr);
654 
655  /// Adds a PReLU layer to the network.
656  /// @param name - Optional name for the layer.
657  /// @return - Interface for configuring the layer.
658  IConnectableLayer* AddPreluLayer(const char* name = nullptr);
659 
660  /// Adds a 2D transpose convolution layer to the network.
661  /// @param descriptor - Description of the 2D transpose convolution layer.
662  /// @param weights - Tensor for the weights data.
663  /// @param biases - Optional tensor for the bias data.
664  /// @param name - Optional name for the layer.
665  /// @return - Interface for configuring the layer.
667  const ConstTensor& weights,
668  const Optional<ConstTensor>& biases,
669  const char* name = nullptr);
670 
671  /// Adds a transpose layer to the network.
672  /// @param transposeDescriptor - TransposeDescriptor to configure the transpose.
673  /// @param name - Optional name for the layer.
674  /// @return - Interface for configuring the layer.
675  IConnectableLayer* AddTransposeLayer(const TransposeDescriptor& transposeDescriptor,
676  const char* name = nullptr);
677 
678  /// Adds a stack layer to the network.
679  /// @param descriptor - Description of the stack layer.
680  /// @param name - Optional name for the layer.
681  /// @return - Interface for configuring the layer.
683  const char* name = nullptr);
684 
685  /// Add a stand-in layer for a type unknown to the Arm NN framework.
686  /// Note: Due to the nature of this layer, no validation can be performed by the framework.
687  /// Furthermore, Any model containing this layer cannot make use of dynamic tensors since the
688  /// tensor sizes cannot be inferred.
689  /// @descriptor - Descriptor for the StandIn layer.
690  /// @return - Interface for configuring the layer.
692  const char* name = nullptr);
693 
694  /// Add a QuantizedLstm layer to the network
695  /// @param params - The weights and biases for the Quantized LSTM cell
696  /// @param name - Optional name for the layer
697  /// @return - Interface for configuring the layer.
699  const char* name = nullptr);
700 
701  /// Add a QLstm layer to the network
702  /// @param descriptor - Parameters for the QLstm operation
703  /// @param params - Weights and biases for the layer
704  /// @param name - Optional name for the layer
705  /// @return - Interface for configuring the layer.
707  const LstmInputParams& params,
708  const char* name = nullptr);
709 
710  /// Adds a Logical Binary layer to the network.
711  /// @param descriptor - Description of the Logical Binary layer.
712  /// @param name - Optional name for the layer.
713  /// @return - Interface for configuring the layer.
715  const char* name = nullptr);
716 
717  /// Add a UnidirectionalSequenceLstm layer to the network
718  /// @param descriptor - Parameters for the UnidirectionalSequenceLstm operation
719  /// @param params - Weights and biases for the UnidirectionalSequenceLstm
720  /// @param name - Optional name for the layer
721  /// @return - Interface for configuring the layer.
723  const LstmInputParams& params,
724  const char* name = nullptr);
725 
726  /// Add a ChannelShuffle layer to the network
727  /// @param descriptor - Parameters for the ChannelShuffle operation
728  /// @param name - Optional name for the layer
729  /// @return - Interface for configuring the layer
731  const char* name = nullptr);
732 
733  /// Add a BatchMatMul layer to the network
734  /// @param descriptor - Parameters for the BatchMatMul operation
735  /// @param name - Optional name for the layer
736  /// @return - Interface for configuring the layer
738  const char* name = nullptr);
739 
740  void ExecuteStrategy(IStrategy& strategy) const;
741 
742 protected:
743  ~INetwork();
744 
745  friend void VisitLayersTopologically(const INetwork* inputNetwork, IStrategy& strategy);
747  friend TensorInfo GetInputTensorInfo(const INetwork* network);
748  friend IOptimizedNetworkPtr Optimize(const INetwork& network,
749  const std::vector<BackendId>& backendPreferences,
750  const IDeviceSpec& deviceSpec,
751  const OptimizerOptions& options,
752  Optional<std::vector<std::string>&> messages);
753 
754  INetwork(NetworkOptions networkOptions = {});
755 
756  std::unique_ptr<NetworkImpl> pNetworkImpl;
757 };
758 
759 namespace experimental
760 {
761 class AsyncNetworkImpl;
762 class WorkingMemHandle;
763 }
764 
765 struct BackendSettings;
766 struct OptimizationResult;
767 class OptimizedNetworkImpl;
768 class IProfiler;
770 {
771 public:
772  static void Destroy(IOptimizedNetwork* network);
773 
774  Status PrintGraph();
775  Status SerializeToDot(std::ostream& stream) const;
776 
777  arm::pipe::ProfilingGuid GetGuid() const;
778 
779  size_t GetNumInputs() const;
780  size_t GetNumOutputs() const;
781 
782  void ExecuteStrategy(IStrategy& strategy) const;
783 
784  /// Creates a copy of the IOptimizedNetwork. The IOptimizedNetwork will not be reoptimized,
785  /// the provided ModelOptions will only be used when creating a LoadedNetwork.
786  IOptimizedNetwork(const IOptimizedNetwork& other, const ModelOptions& modelOptions);
787  IOptimizedNetwork(std::unique_ptr<Graph> graph);
788  IOptimizedNetwork(std::unique_ptr<OptimizedNetworkImpl> impl);
790 
791  const std::shared_ptr<IProfiler>& GetProfiler() const;
792 
793 protected:
794  friend class LoadedNetwork;
795 
798 
799  friend Graph& GetGraphForTesting(IOptimizedNetwork* optNetPtr);
801  friend IOptimizedNetworkPtr Optimize(const INetwork& inNetwork,
802  const std::vector<BackendId>& backendPreferences,
803  const IDeviceSpec& deviceSpec,
804  const OptimizerOptions& options,
805  Optional<std::vector<std::string>&> messages);
806  friend IOptimizedNetworkPtr Optimize(const Graph& inGraph,
807  const std::vector<BackendId>& backendPreferences,
808  const IDeviceSpec& deviceSpec,
809  const OptimizerOptions& options,
810  Optional<std::vector<std::string>&> messages);
811 
812  IOptimizedNetwork(std::unique_ptr<Graph> graph, const ModelOptions& modelOptions);
813 
814  std::unique_ptr<OptimizedNetworkImpl> pOptimizedNetworkImpl;
815 };
816 
817 /// Create an optimized version of the network
818 /// @param network INetwork description of the network to be optimized.
819 /// @param backendPreferences The choice of the backend ordered by user preferences.
820 /// @param deviceSpec DeviceSpec object as queried from the runtime. See IRuntime::GetDeviceSpec()
821 /// @param messages If there are failures or warnings a string describing same will be added to the vector
822 /// @param options OptimizerOptions object with optimizer configuration options
823 /// @return An IOptimizedNetworkPtr interface to the optimized network, throws an exception derived from
824 /// armnn::Exception if process fails.
825 
826 IOptimizedNetworkPtr Optimize(const INetwork& network,
827  const std::vector<BackendId>& backendPreferences,
828  const IDeviceSpec& deviceSpec,
829  const OptimizerOptions& options = OptimizerOptions(),
830  Optional<std::vector<std::string>&> messages = EmptyOptional());
831 
832 /// Create an optimized version of the network
833 /// @param inGraph Graph to be optimized.
834 /// @param backendPreferences The choice of the backend ordered by user preferences.
835 /// @param deviceSpec DeviceSpec object as queried from the runtime. See IRuntime::GetDeviceSpec()
836 /// @param messages If there are failures or warnings a string describing same will be added to the vector
837 /// @param options OptimizerOptions object with optimizer configuration options
838 /// @return An IOptimizedNetworkPtr interface to the optimized network, throws an exception derived from
839 /// armnn::Exception if process fails.
840 
841 IOptimizedNetworkPtr Optimize(const Graph& inGraph,
842  const std::vector<BackendId>& backendPreferences,
843  const IDeviceSpec& deviceSpec,
844  const OptimizerOptions& options,
845  Optional<std::vector<std::string>&> messages = EmptyOptional());
846 } //namespace armnn
armnn::IConnectableLayer::ExecuteStrategy
virtual void ExecuteStrategy(IStrategy &strategy) const =0
Apply a visitor to this layer.
armnn::INetwork::AddConvolution2dLayer
IConnectableLayer * AddConvolution2dLayer(const Convolution2dDescriptor &convolution2dDescriptor, const char *name=nullptr)
Adds a 2D convolution layer to the network.
Definition: Network.cpp:87
armnn::INetwork::AddDepthwiseConvolution2dLayer
IConnectableLayer * AddDepthwiseConvolution2dLayer(const DepthwiseConvolution2dDescriptor &convolution2dDescriptor, const char *name=nullptr)
Adds a 2D depthwise convolution layer to the network.
Definition: Network.cpp:107
armnn::IOptimizedNetwork::GetGraphForTesting
friend Graph & GetGraphForTesting(IOptimizedNetwork *optNetPtr)
Definition: TestUtils.cpp:49
armnn::BackendId
Definition: BackendId.hpp:75
armnn::IOutputSlot::GetOwningIConnectableLayer
virtual const IConnectableLayer & GetOwningIConnectableLayer() const =0
armnn::IOptimizedNetwork::GetProfiler
const std::shared_ptr< IProfiler > & GetProfiler() const
Definition: Network.cpp:491
armnn::BackendOptions::BackendOption::GetValue
Var GetValue() const
Definition: BackendOptions.hpp:252
armnn::IConnectableLayer::InferOutputShapes
virtual std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const =0
Infer the shape of the output(s) based on the provided input shape(s)
armnn::INetwork::AddFloorLayer
IConnectableLayer * AddFloorLayer(const char *name=nullptr)
Adds a floor layer to the network.
Definition: Network.cpp:293
armnn::GatherDescriptor
A GatherDescriptor for the GatherLayer.
Definition: Descriptors.hpp:912
armnn::NormalizationDescriptor
A NormalizationDescriptor for the NormalizationLayer.
Definition: Descriptors.hpp:737
armnn::TransposeDescriptor
A TransposeDescriptor for the TransposeLayer.
Definition: Descriptors.hpp:1437
armnn::INetwork::AddConstantLayer
IConnectableLayer * AddConstantLayer(const ConstTensor &input, const char *name=nullptr)
Adds a layer with no inputs and a single output, which always corresponds to the passed in constant t...
Definition: Network.cpp:269
armnn::INetwork::AddTransposeConvolution2dLayer
IConnectableLayer * AddTransposeConvolution2dLayer(const TransposeConvolution2dDescriptor &descriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr)
Adds a 2D transpose convolution layer to the network.
Definition: Network.cpp:372
armnn::IOptimizedNetworkPtr
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
Definition: INetwork.hpp:253
armnn::ElementwiseUnaryDescriptor
A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer.
Definition: Descriptors.hpp:109
armnn::PadDescriptor
A PadDescriptor for the PadLayer.
Definition: Descriptors.hpp:1143
armnn::SoftmaxDescriptor
A SoftmaxDescriptor for the SoftmaxLayer.
Definition: Descriptors.hpp:157
armnn::OptimizerOptions::OptimizerOptions
OptimizerOptions(bool reduceFp32ToFp16, bool debug, bool reduceFp32ToBf16, bool importEnabled, ModelOptions modelOptions={}, bool exportEnabled=false, bool debugToFile=false)
Definition: INetwork.hpp:152
armnn::INetwork::pNetworkImpl
std::unique_ptr< NetworkImpl > pNetworkImpl
Definition: INetwork.hpp:756
armnn::OptimizerOptions::m_AllowExpandedDims
bool m_AllowExpandedDims
When calculating tensor sizes, dimensions of size == 1 will be ignored.
Definition: INetwork.hpp:247
armnn::StackDescriptor
A StackDescriptor for the StackLayer.
Definition: Descriptors.hpp:1198
armnn::INetwork::AddPooling3dLayer
IConnectableLayer * AddPooling3dLayer(const Pooling3dDescriptor &pooling3dDescriptor, const char *name=nullptr)
Adds a 3D pooling layer to the network.
Definition: Network.cpp:167
armnn::SliceDescriptor
A SliceDescriptor for the SliceLayer.
Definition: Descriptors.hpp:1175
armnn::INetwork::Optimize
friend IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options, Optional< std::vector< std::string > & > messages)
Create an optimized version of the network.
Definition: Network.cpp:1773
NetworkFwd.hpp
armnn::INetwork::AddDivisionLayer
IConnectableLayer * AddDivisionLayer(const char *name=nullptr)
Adds a division layer to the network.
Definition: Network.cpp:309
armnn::IOptimizedNetwork::SerializeToDot
Status SerializeToDot(std::ostream &stream) const
Definition: Network.cpp:486
armnn::OptimizerOptions::m_ExportEnabled
bool m_ExportEnabled
Enable Export.
Definition: INetwork.hpp:244
armnn::OptimizerOptions::m_ReduceFp32ToFp16
bool m_ReduceFp32ToFp16
Reduces all Fp32 operators in the model to Fp16 for faster processing.
Definition: INetwork.hpp:219
armnn::INetwork::CreateRaw
static INetwork * CreateRaw(const NetworkOptions &networkOptions={})
Definition: Network.cpp:447
armnn::INetwork::GetInputTensorInfo
friend TensorInfo GetInputTensorInfo(const INetwork *network)
armnn::IOutputSlot::~IOutputSlot
~IOutputSlot()
Not user deletable.
Definition: INetwork.hpp:64
armnn::INetwork::AddQLstmLayer
IConnectableLayer * AddQLstmLayer(const QLstmDescriptor &descriptor, const LstmInputParams &params, const char *name=nullptr)
Add a QLstm layer to the network.
Definition: Network.cpp:409
armnn::INetwork::AddLogSoftmaxLayer
IConnectableLayer * AddLogSoftmaxLayer(const LogSoftmaxDescriptor &logSoftmaxDescriptor, const char *name=nullptr)
Adds a log softmax layer to the network.
Definition: Network.cpp:263
armnn::LayerBindingId
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:290
armnn::ActivationDescriptor
An ActivationDescriptor for the ActivationLayer.
Definition: Descriptors.hpp:36
armnn::ShapeInferenceMethod::ValidateOnly
@ ValidateOnly
Validate all output shapes.
armnn::IConnectableLayer
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:68
Optional.hpp
armnn::LstmDescriptor
An LstmDescriptor for the LstmLayer.
Definition: Descriptors.hpp:1049
armnn::FullyConnectedDescriptor
A FullyConnectedDescriptor for the FullyConnectedLayer.
Definition: Descriptors.hpp:475
armnn::OptimizerOptions::m_ModelOptions
ModelOptions m_ModelOptions
Enable Model Options.
Definition: INetwork.hpp:238
armnn::LoadedNetwork
Definition: LoadedNetwork.hpp:42
armnn::IInputSlot::GetOwningIConnectableLayer
virtual const IConnectableLayer & GetOwningIConnectableLayer() const =0
armnn::IOptimizedNetwork
Definition: INetwork.hpp:769
armnn::INetwork::AddDetectionPostProcessLayer
IConnectableLayer * AddDetectionPostProcessLayer(const DetectionPostProcessDescriptor &descriptor, const ConstTensor &anchors, const char *name=nullptr)
Adds a Detection PostProcess layer to the network.
Definition: Network.cpp:121
armnn::INetwork::AddSubtractionLayer
IConnectableLayer * AddSubtractionLayer(const char *name=nullptr)
Adds a subtraction layer to the network.
Definition: Network.cpp:314
armnn::BatchMatMulDescriptor
A BatchMatMulDescriptor for the BatchMatMul operator.
Definition: Descriptors.hpp:1531
armnn::ResizeDescriptor
A ResizeDescriptor for the ResizeLayer.
Definition: Descriptors.hpp:932
armnn::INetwork::AddSliceLayer
IConnectableLayer * AddSliceLayer(const SliceDescriptor &sliceDescriptor, const char *name=nullptr)
Adds a slice layer to the network.
Definition: Network.cpp:193
armnn::StridedSliceDescriptor
A StridedSliceDescriptor for the StridedSliceLayer.
Definition: Descriptors.hpp:1250
armnn::ConstTensor
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:327
armnn::Pooling3dDescriptor
A Pooling3dDescriptor for the Pooling3dLayer.
Definition: Descriptors.hpp:399
armnn::ReduceDescriptor
A ReduceDescriptor for the REDUCE operators.
Definition: Descriptors.hpp:1485
armnn::IOptimizedNetwork::AsyncNetworkImpl
friend class experimental::AsyncNetworkImpl
Definition: INetwork.hpp:796
armnn::INetwork::TestConnectionPreservation
friend class TestConnectionPreservation
Definition: INetwork.hpp:746
armnn::ModelOptions
std::vector< BackendOptions > ModelOptions
Definition: BackendOptions.hpp:18
armnn::ComparisonDescriptor
A ComparisonDescriptor for the ComparisonLayer.
Definition: Descriptors.hpp:89
armnn::IConnectableLayer::ConstantTensors
std::vector< std::reference_wrapper< std::shared_ptr< ConstTensorHandle > >> ConstantTensors
Definition: INetwork.hpp:124
armnn::StandInDescriptor
A StandInDescriptor for the StandIn layer.
Definition: Descriptors.hpp:1228
armnn::INetwork::AddQuantizeLayer
IConnectableLayer * AddQuantizeLayer(const char *name=nullptr)
Add a quantize layer to the network.
Definition: Network.cpp:335
IStrategy.hpp
armnn::INetwork::AddMinimumLayer
IConnectableLayer * AddMinimumLayer(const char *name=nullptr)
Add a Minimum layer to the network.
Definition: Network.cpp:346
TensorHandle.hpp
armnn::ViewsDescriptor
A ViewsDescriptor for the SplitterLayer.
Definition: Descriptors.hpp:224
armnn::IWorkloadFactory
Definition: WorkloadFactory.hpp:22
TensorFwd.hpp
armnn::PreCompiledDescriptor
A PreCompiledDescriptor for the PreCompiledLayer.
Definition: Descriptors.hpp:1314
armnn::IConnectableLayer::GetOutputSlot
virtual const IOutputSlot & GetOutputSlot(unsigned int index) const =0
Get the const output slot handle by slot index.
armnn::INetwork::AddPooling2dLayer
IConnectableLayer * AddPooling2dLayer(const Pooling2dDescriptor &pooling2dDescriptor, const char *name=nullptr)
Adds a 2D pooling layer to the network.
Definition: Network.cpp:161
armnn::ShapeInferenceMethod
ShapeInferenceMethod
The ShapeInferenceMethod modify how the output shapes are treated.
Definition: Types.hpp:221
armnn::INetwork::AddBatchMatMulLayer
IConnectableLayer * AddBatchMatMulLayer(const BatchMatMulDescriptor &descriptor, const char *name=nullptr)
Add a BatchMatMul layer to the network.
Definition: Network.cpp:436
armnn::IOptimizedNetwork::GetNumOutputs
size_t GetNumOutputs() const
Definition: Network.cpp:506
armnn::IOutputSlot::IsTensorInfoSet
virtual bool IsTensorInfoSet() const =0
armnn::INetwork::AddReduceLayer
IConnectableLayer * AddReduceLayer(const ReduceDescriptor &reduceDescriptor, const char *name=nullptr)
Adds a reduce layer to the network.
Definition: Network.cpp:245
armnn::IOutputSlot::Connect
virtual int Connect(IInputSlot &destination)=0
armnn::INetwork::AddDequantizeLayer
IConnectableLayer * AddDequantizeLayer(const char *name=nullptr)
Adds a Dequantize layer to the network.
Definition: Network.cpp:115
armnn::INetwork::Destroy
static void Destroy(INetwork *network)
Definition: Network.cpp:457
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::INetwork::AddMaximumLayer
IConnectableLayer * AddMaximumLayer(const char *name=nullptr)
Add a Maximum layer to the network.
Definition: Network.cpp:319
armnn::IStrategy
Definition: IStrategy.hpp:16
armnn::CompiledBlobDeleter
std::function< void(const void *)> CompiledBlobDeleter
Definition: INetwork.hpp:255
armnn::BackendOptions::Var::ToString
std::string ToString()
Definition: BackendOptions.hpp:124
armnn::IInputSlot
An input connection slot for a layer.
Definition: INetwork.hpp:25
armnn::INetwork::AddStackLayer
IConnectableLayer * AddStackLayer(const StackDescriptor &descriptor, const char *name=nullptr)
Adds a stack layer to the network.
Definition: Network.cpp:391
armnn::IOutputSlot::Disconnect
virtual void Disconnect(IInputSlot &slot)=0
armnn::INetwork::INetwork
INetwork(NetworkOptions networkOptions={})
Definition: Network.cpp:47
armnn::BackendOptions::BackendOption::GetName
std::string GetName() const
Definition: BackendOptions.hpp:251
armnn::BatchToSpaceNdDescriptor
A BatchToSpaceNdDescriptor for the BatchToSpaceNdLayer.
Definition: Descriptors.hpp:843
armnn::INetwork::AddPrecompiledLayer
IConnectableLayer * AddPrecompiledLayer(const PreCompiledDescriptor &preCompiledDescriptor, CompiledBlobPtr compiledBlobPtr, const Optional< BackendId > &backend, const char *name=nullptr)
Adds a Precompiled layer to the network.
Definition: Network.cpp:173
armnn::IConnectableLayer::GetInputSlot
virtual const IInputSlot & GetInputSlot(unsigned int index) const =0
Get a const input slot handle by slot index.
armnn::SpaceToDepthDescriptor
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
Definition: Descriptors.hpp:1022
armnn::INetwork::AddMultiplicationLayer
IConnectableLayer * AddMultiplicationLayer(const char *name=nullptr)
Adds a multiplication layer to the network.
Definition: Network.cpp:219
armnn::NetworkOptions
std::vector< BackendOptions > NetworkOptions
Definition: BackendOptions.hpp:16
armnn::INetwork::AddNormalizationLayer
IConnectableLayer * AddNormalizationLayer(const NormalizationDescriptor &normalizationDescriptor, const char *name=nullptr)
Adds a normalization layer to the network.
Definition: Network.cpp:187
armnn::OptimizerOptions::m_ProfilingEnabled
bool m_ProfilingEnabled
Enable profiling dump of the optimizer phase.
Definition: INetwork.hpp:241
armnn::DetectionPostProcessDescriptor
Definition: Descriptors.hpp:681
armnn::INetwork::AddSpaceToBatchNdLayer
IConnectableLayer * AddSpaceToBatchNdLayer(const SpaceToBatchNdDescriptor &spaceToBatchNdDescriptor, const char *name=nullptr)
Adds a space to batch layer to the network.
Definition: Network.cpp:281
armnn::FillDescriptor
A FillDescriptor for the FillLayer.
Definition: Descriptors.hpp:893
armnn::INetwork::AddConvolution3dLayer
IConnectableLayer * AddConvolution3dLayer(const Convolution3dDescriptor &convolution3dDescriptor, const char *name=nullptr)
Adds a 3D convolution layer to the network.
Definition: Network.cpp:93
armnn::LayerType
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
Definition: Types.hpp:466
armnn::INetwork::AddL2NormalizationLayer
IConnectableLayer * AddL2NormalizationLayer(const L2NormalizationDescriptor &desc, const char *name=nullptr)
Adds an L2 normalization layer to the network.
Definition: Network.cpp:257
armnn::OptimizerOptions::OptimizerOptions
OptimizerOptions()
Definition: INetwork.hpp:139
armnn::IOutputSlot::GetTensorInfo
virtual const TensorInfo & GetTensorInfo() const =0
armnn::IOutputSlot::GetNumConnections
virtual unsigned int GetNumConnections() const =0
armnn::INetwork::AddTransposeLayer
IConnectableLayer * AddTransposeLayer(const TransposeDescriptor &transposeDescriptor, const char *name=nullptr)
Adds a transpose layer to the network.
Definition: Network.cpp:380
armnn::INetwork::AddStandInLayer
IConnectableLayer * AddStandInLayer(const StandInDescriptor &descriptor, const char *name=nullptr)
Add a stand-in layer for a type unknown to the Arm NN framework.
Definition: Network.cpp:397
armnn::IOutputSlot::CalculateIndexOnOwner
virtual unsigned int CalculateIndexOnOwner() const =0
armnn::INetwork::AddAdditionLayer
IConnectableLayer * AddAdditionLayer(const char *name=nullptr)
Adds an addition layer to the network.
Definition: Network.cpp:214
armnn::INetwork::AddPadLayer
IConnectableLayer * AddPadLayer(const PadDescriptor &padDescriptor, const char *name=nullptr)
Adds a fully pad layer to the network.
Definition: Network.cpp:329
armnn::DepthwiseConvolution2dDescriptor
A DepthwiseConvolution2dDescriptor for the DepthwiseConvolution2dLayer.
Definition: Descriptors.hpp:627
armnn::MeanDescriptor
A MeanDescriptor for the MeanLayer.
Definition: Descriptors.hpp:1119
armnn::IConnectableLayer::GetNumOutputSlots
virtual unsigned int GetNumOutputSlots() const =0
Returns the number of connectable output slots.
armnn::INetwork::AddInstanceNormalizationLayer
IConnectableLayer * AddInstanceNormalizationLayer(const InstanceNormalizationDescriptor &desc, const char *name=nullptr)
Adds an instance normalization layer to the network.
Definition: Network.cpp:251
armnn::OptimizerOptions::m_DebugToFile
bool m_DebugToFile
Pass debug data to separate output files for easier troubleshooting.
Definition: INetwork.hpp:225
armnn::IDeviceSpec
Device specific knowledge to be passed to the optimizer.
Definition: Types.hpp:280
armnn::IOptimizedNetwork::GetGuid
arm::pipe::ProfilingGuid GetGuid() const
Definition: Network.cpp:496
armnn::IOptimizedNetwork::Destroy
static void Destroy(IOptimizedNetwork *network)
Definition: Network.cpp:476
armnn::INetwork::AddMergeLayer
IConnectableLayer * AddMergeLayer(const char *name=nullptr)
Adds a merge layer to the network.
Definition: Network.cpp:209
armnn::CompiledBlobPtr
std::unique_ptr< void, CompiledBlobDeleter > CompiledBlobPtr
Definition: INetwork.hpp:256
armnn::IOutputSlot::GetConnection
virtual const IInputSlot * GetConnection(unsigned int index) const =0
armnn::IOptimizedNetwork::pOptimizedNetworkImpl
std::unique_ptr< OptimizedNetworkImpl > pOptimizedNetworkImpl
Definition: INetwork.hpp:814
armnn::L2NormalizationDescriptor
A L2NormalizationDescriptor for the L2NormalizationLayer.
Definition: Descriptors.hpp:777
armnn::INetwork::AddPermuteLayer
IConnectableLayer * AddPermuteLayer(const PermuteDescriptor &permuteDescriptor, const char *name=nullptr)
Adds a permute layer to the network.
Definition: Network.cpp:149
armnn::IConnectableLayer::GetGuid
virtual LayerGuid GetGuid() const =0
Returns the unique id of the layer.
armnn::ChannelShuffleDescriptor
A ChannelShuffleDescriptor for the ChannelShuffle operator.
Definition: Descriptors.hpp:1509
armnn::IOptimizedNetwork::PrintGraph
Status PrintGraph()
Definition: Network.cpp:481
armnn::IOutputSlot
An output connection slot for a layer.
Definition: INetwork.hpp:41
armnn::Convolution3dDescriptor
A Convolution3dDescriptor for the Convolution3dLayer.
Definition: Descriptors.hpp:556
armnn::OptimizerOptions::ToString
const std::string ToString() const
Definition: INetwork.hpp:184
armnn::IConnectableLayer::~IConnectableLayer
~IConnectableLayer()
Objects are not deletable via the handle.
Definition: INetwork.hpp:131
armnn::TensorInfo
Definition: Tensor.hpp:152
armnn::Convolution2dDescriptor
A Convolution2dDescriptor for the Convolution2dLayer.
Definition: Descriptors.hpp:502
armnn::INetwork::AddComparisonLayer
IConnectableLayer * AddComparisonLayer(const ComparisonDescriptor &comparisonDescriptor, const char *name=nullptr)
Add a Comparison layer to the network.
Definition: Network.cpp:73
armnn::IOptimizedNetwork::IOptimizedNetwork
IOptimizedNetwork(const IOptimizedNetwork &other, const ModelOptions &modelOptions)
Creates a copy of the IOptimizedNetwork.
Definition: Network.cpp:462
armnn::INetwork::AddCastLayer
IConnectableLayer * AddCastLayer(const char *name=nullptr)
Adds a cast layer to the network.
Definition: Network.cpp:68
armnn::BatchNormalizationDescriptor
A BatchNormalizationDescriptor for the BatchNormalizationLayer.
Definition: Descriptors.hpp:796
armnn::BackendOptions::BackendOption
Definition: BackendOptions.hpp:215
armnn::QLstmDescriptor
A QLstmDescriptor for the QLstmLayer.
Definition: Descriptors.hpp:1327
armnn::EmptyOptional
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
Definition: Optional.hpp:32
armnn::OptimizerOptions::m_ReduceFp32ToBf16
bool m_ReduceFp32ToBf16
@Note This feature has been replaced by enabling Fast Math in compute library backend options.
Definition: INetwork.hpp:229
armnn::Status
Status
Definition: Types.hpp:42
DescriptorsFwd.hpp
armnn::IOptimizedNetwork::ExecuteStrategy
void ExecuteStrategy(IStrategy &strategy) const
Definition: Network.cpp:2731
armnn::OptimizerOptions::m_shapeInferenceMethod
ShapeInferenceMethod m_shapeInferenceMethod
Infer output size when not available.
Definition: INetwork.hpp:232
armnn::INetwork::AddActivationLayer
IConnectableLayer * AddActivationLayer(const ActivationDescriptor &activationDescriptor, const char *name=nullptr)
Adds an activation layer to the network.
Definition: Network.cpp:181
armnn::IInputSlot::~IInputSlot
~IInputSlot()
Not user deletable.
Definition: INetwork.hpp:36
armnn::INetwork::AddGatherNdLayer
IConnectableLayer * AddGatherNdLayer(const char *name=nullptr)
Add GatherNd layer to the network.
Definition: Network.cpp:357
armnn::QuantizedLstmInputParams
Definition: QuantizedLstmParams.hpp:13
armnn::IInputSlot::GetConnection
virtual const IOutputSlot * GetConnection() const =0
armnn::IOptimizedNetwork::GetNumInputs
size_t GetNumInputs() const
Definition: Network.cpp:501
armnn::INetwork::AddChannelShuffleLayer
IConnectableLayer * AddChannelShuffleLayer(const ChannelShuffleDescriptor &descriptor, const char *name=nullptr)
Add a ChannelShuffle layer to the network.
Definition: Network.cpp:430
armnn::INetwork::AddGatherLayer
IConnectableLayer * AddGatherLayer(const GatherDescriptor &descriptor, const char *name=nullptr)
Add Gather layer to the network.
Definition: Network.cpp:351
armnn::INetwork::Create
static INetworkPtr Create(const NetworkOptions &networkOptions={})
Definition: Network.cpp:452
armnn::IConnectableLayer::SetBackendId
virtual void SetBackendId(const BackendId &id)=0
Set the backend of the IConnectableLayer.
armnn::INetwork::AddDepthToSpaceLayer
IConnectableLayer * AddDepthToSpaceLayer(const DepthToSpaceDescriptor &depthToSpaceDescriptor, const char *name=nullptr)
Adds a depth to space layer to the network.
Definition: Network.cpp:100
armnn::BaseDescriptor
Base class for all descriptors.
Definition: Descriptors.hpp:22
armnn::OriginsDescriptor
An OriginsDescriptor for the ConcatLayer.
Definition: Descriptors.hpp:181
armnn::ReshapeDescriptor
A ReshapeDescriptor for the ReshapeLayer.
Definition: Descriptors.hpp:970
armnn::INetwork::AddPreluLayer
IConnectableLayer * AddPreluLayer(const char *name=nullptr)
Adds a PReLU layer to the network.
Definition: Network.cpp:367
armnn::IOutputSlot::GetOwningLayerGuid
virtual LayerGuid GetOwningLayerGuid() const =0
armnn::PermuteDescriptor
A PermuteDescriptor for the PermuteLayer.
Definition: Descriptors.hpp:129
armnn::TransposeConvolution2dDescriptor
A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer.
Definition: Descriptors.hpp:1387
armnn::Graph
Definition: Graph.hpp:30
armnn::INetwork::AddSpaceToDepthLayer
IConnectableLayer * AddSpaceToDepthLayer(const SpaceToDepthDescriptor &spaceToDepthDescriptor, const char *name=nullptr)
Adds a space to depth layer to the network.
Definition: Network.cpp:287
armnn::INetwork::AddSwitchLayer
IConnectableLayer * AddSwitchLayer(const char *name=nullptr)
Adds a switch layer to the network.
Definition: Network.cpp:362
armnn::IOptimizedNetwork::~IOptimizedNetwork
~IOptimizedNetwork()
armnn::IInputSlot::GetSlotIndex
virtual unsigned int GetSlotIndex() const =0
armnn::IOutputSlot::SetTensorInfo
virtual void SetTensorInfo(const TensorInfo &tensorInfo)=0
armnn::INetwork::AddMeanLayer
IConnectableLayer * AddMeanLayer(const MeanDescriptor &meanDescriptor, const char *name=nullptr)
Add a Mean layer to the network.
Definition: Network.cpp:324
armnn::INetwork::VisitLayersTopologically
friend void VisitLayersTopologically(const INetwork *inputNetwork, IStrategy &strategy)
armnn::INetwork::ExecuteStrategy
void ExecuteStrategy(IStrategy &strategy) const
Definition: Network.cpp:442
armnn::INetwork::AddShapeLayer
IConnectableLayer * AddShapeLayer(const char *name=nullptr)
Adds a shape layer to the network.
Definition: Network.cpp:386
armnn::Pooling2dDescriptor
A Pooling2dDescriptor for the Pooling2dLayer.
Definition: Descriptors.hpp:339
armnn::IOptimizedNetwork::GetModelOptionsForTesting
friend ModelOptions & GetModelOptionsForTesting(IOptimizedNetwork *optNetPtr)
Definition: TestUtils.cpp:54
armnn::LogicalBinaryDescriptor
A LogicalBinaryDescriptor for the LogicalBinaryLayer.
Definition: Descriptors.hpp:1465
armnn::INetwork::~INetwork
~INetwork()
armnn::INetwork::AddResizeLayer
IConnectableLayer * AddResizeLayer(const ResizeDescriptor &resizeDescriptor, const char *name=nullptr)
Adds a resize layer to the network.
Definition: Network.cpp:239
armnn::INetwork::AddConcatLayer
IConnectableLayer * AddConcatLayer(const ConcatDescriptor &concatDescriptor, const char *name=nullptr)
Adds a concatenation layer to the network.
Definition: Network.cpp:80
armnn::INetwork::AddBatchToSpaceNdLayer
IConnectableLayer * AddBatchToSpaceNdLayer(const BatchToSpaceNdDescriptor &batchToSpaceNdDescriptor, const char *name=nullptr)
Adds a batch to space ND layer to the network.
Definition: Network.cpp:155
armnn::INetwork
Main network class which provides the interface for building up a neural network.
Definition: INetwork.hpp:260
armnn::Optional
Definition: Optional.hpp:270
armnn::INetwork::PrintGraph
Status PrintGraph()
Definition: Network.cpp:51
Logging.hpp
armnn::INetwork::AddFillLayer
IConnectableLayer * AddFillLayer(const FillDescriptor &fillDescriptor, const char *name=nullptr)
Add an Fill layer to the network.
Definition: Network.cpp:137
armnn::INetwork::AddQuantizedLstmLayer
IConnectableLayer * AddQuantizedLstmLayer(const QuantizedLstmInputParams &params, const char *name=nullptr)
Add a QuantizedLstm layer to the network.
Definition: Network.cpp:403
armnn::IConnectableLayer::GetName
virtual const char * GetName() const =0
Returns the name of the layer.
armnn::INetwork::AddElementwiseUnaryLayer
IConnectableLayer * AddElementwiseUnaryLayer(const ElementwiseUnaryDescriptor &elementwiseUnaryDescriptor, const char *name=nullptr)
Add an ElementwiseUnary layer to the network.
Definition: Network.cpp:130
armnn::INetwork::AddStridedSliceLayer
IConnectableLayer * AddStridedSliceLayer(const StridedSliceDescriptor &stridedSliceDescriptor, const char *name=nullptr)
Adds a strided slice layer to the network.
Definition: Network.cpp:340
armnn::IOptimizedNetwork::Optimize
friend IOptimizedNetworkPtr Optimize(const INetwork &inNetwork, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options, Optional< std::vector< std::string > & > messages)
Create an optimized version of the network.
Definition: Network.cpp:1773
armnn::INetwork::AddRankLayer
IConnectableLayer * AddRankLayer(const char *name=nullptr)
Adds a rank layer to the network.
Definition: Network.cpp:234
armnn::INetworkPtr
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:252
armnn::ArgMinMaxDescriptor
An ArgMinMaxDescriptor for ArgMinMaxLayer.
Definition: Descriptors.hpp:67
armnn::NetworkImpl
Private implementation of INetwork.
Definition: Network.hpp:31
armnn::IConnectableLayer::GetType
virtual LayerType GetType() const =0
Returns the armnn::LayerType of this layer.
armnn::INetwork::AddUnidirectionalSequenceLstmLayer
IConnectableLayer * AddUnidirectionalSequenceLstmLayer(const UnidirectionalSequenceLstmDescriptor &descriptor, const LstmInputParams &params, const char *name=nullptr)
Add a UnidirectionalSequenceLstm layer to the network.
Definition: Network.cpp:422
armnn::LstmInputParams
Definition: LstmParams.hpp:13
BackendOptions.hpp
armnn::Optimize
IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options=OptimizerOptions(), Optional< std::vector< std::string > & > messages=EmptyOptional())
Create an optimized version of the network.
Definition: Network.cpp:1773
armnn::IConnectableLayer::GetNumInputSlots
virtual unsigned int GetNumInputSlots() const =0
Returns the number of connectable input slots.
armnn::experimental::WorkingMemHandle
Definition: WorkingMemHandle.hpp:29
LayerGuid
arm::pipe::ProfilingGuid LayerGuid
Define LayerGuid type.
Definition: Types.hpp:26
armnn::InstanceNormalizationDescriptor
An InstanceNormalizationDescriptor for InstanceNormalizationLayer.
Definition: Descriptors.hpp:815
armnn::INetwork::AddBatchNormalizationLayer
IConnectableLayer * AddBatchNormalizationLayer(const BatchNormalizationDescriptor &desc, const ConstTensor &mean, const ConstTensor &variance, const ConstTensor &beta, const ConstTensor &gamma, const char *name=nullptr)
Adds a batch normalization layer to the network.
Definition: Network.cpp:224
armnn::INetwork::AddInputLayer
IConnectableLayer * AddInputLayer(LayerBindingId id, const char *name=nullptr)
Adds an input layer to the network.
Definition: Network.cpp:56
armnn::INetwork::AddArgMinMaxLayer
IConnectableLayer * AddArgMinMaxLayer(const ArgMinMaxDescriptor &desc, const char *name=nullptr)
Adds an ArgMinMax layer to the network.
Definition: Network.cpp:62
armnn::OptimizerOptions
ArmNN performs an optimization on each model/network before it gets loaded for execution.
Definition: INetwork.hpp:137
armnn::INetwork::AddLogicalBinaryLayer
IConnectableLayer * AddLogicalBinaryLayer(const LogicalBinaryDescriptor &descriptor, const char *name=nullptr)
Adds a Logical Binary layer to the network.
Definition: Network.cpp:416
armnn::OptimizerOptions::OptimizerOptions
OptimizerOptions(bool reduceFp32ToFp16, bool debug, bool reduceFp32ToBf16=false, ShapeInferenceMethod shapeInferenceMethod=armnn::ShapeInferenceMethod::ValidateOnly, bool importEnabled=false, ModelOptions modelOptions={}, bool exportEnabled=false, bool debugToFile=false, bool allowExpandedDims=false)
Definition: INetwork.hpp:167
armnn::IConnectableLayer::BackendSelectionHint
virtual void BackendSelectionHint(Optional< BackendId > backend)=0
Provide a hint for the optimizer as to which backend to prefer for this layer.
armnn::INetwork::AddLstmLayer
IConnectableLayer * AddLstmLayer(const LstmDescriptor &descriptor, const LstmInputParams &params, const char *name=nullptr)
Add a Lstm layer to the network.
Definition: Network.cpp:302
armnn::INetwork::AddSplitterLayer
IConnectableLayer * AddSplitterLayer(const ViewsDescriptor &splitterDescriptor, const char *name=nullptr)
Adds a splitter layer to the network.
Definition: Network.cpp:203
armnn::OptimizerOptions::m_Debug
bool m_Debug
Add debug data for easier troubleshooting.
Definition: INetwork.hpp:222
armnn::INetwork::AddSoftmaxLayer
IConnectableLayer * AddSoftmaxLayer(const SoftmaxDescriptor &softmaxDescriptor, const char *name=nullptr)
Adds a softmax layer to the network.
Definition: Network.cpp:197
armnn::IConnectableLayer::GetParameters
virtual const BaseDescriptor & GetParameters() const =0
If the layer has a descriptor return it.
armnn::INetwork::AddOutputLayer
IConnectableLayer * AddOutputLayer(LayerBindingId id, const char *name=nullptr)
Adds an output layer to the network.
Definition: Network.cpp:297
armnn::INetwork::AddFullyConnectedLayer
IConnectableLayer * AddFullyConnectedLayer(const FullyConnectedDescriptor &fullyConnectedDescriptor, const char *name=nullptr)
Adds a fully connected layer to the network.
Definition: Network.cpp:143
armnn::INetwork::AddReshapeLayer
IConnectableLayer * AddReshapeLayer(const ReshapeDescriptor &reshapeDescriptor, const char *name=nullptr)
Adds a reshape layer to the network.
Definition: Network.cpp:275
armnn::IConnectableLayer::GetConstantTensorsByRef
virtual ConstantTensors GetConstantTensorsByRef()=0
Deprecated.hpp
armnn::SpaceToBatchNdDescriptor
A SpaceToBatchNdDescriptor for the SpaceToBatchNdLayer.
Definition: Descriptors.hpp:990
armnn::OptimizerOptions::m_ImportEnabled
bool m_ImportEnabled
Enable Import.
Definition: INetwork.hpp:235