ArmNN
 24.08
Network.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017-2024 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "Network.hpp"
7 #include "Graph.hpp"
8 #include "Layer.hpp"
9 #include "DeviceSpec.hpp"
10 #include "Optimizer.hpp"
11 #include "SubgraphViewSelector.hpp"
12 #include "BackendSettings.hpp"
13 #include "optimizations/All.hpp"
15 #include "armnn/utility/Timer.hpp"
16 
21 
22 #include <armnn/Exceptions.hpp>
23 #include <armnn/TypesUtils.hpp>
25 #include <armnn/Logging.hpp>
26 #include <armnn/utility/Assert.hpp>
29 
30 #include <client/include/IProfilingService.hpp>
31 
32 #include <common/include/ProfilingGuid.hpp>
33 
34 #include <fmt/format.h>
35 
36 #include <fcntl.h>
37 #include <algorithm>
38 #include <memory>
39 #include <vector>
40 #include <armnn/ArmNN.hpp>
41 
42 namespace armnn
43 {
44 
45 INetwork::INetwork(NetworkOptions networkOptions) : pNetworkImpl(new NetworkImpl(networkOptions)) {}
46 
47 INetwork::~INetwork() = default;
48 
50  : p_OptimizerOptionsImpl(std::make_unique<OptimizerOptionsOpaqueImpl>())
51 {
52 }
53 
55  : p_OptimizerOptionsImpl(std::make_unique<OptimizerOptionsOpaqueImpl>(*other.p_OptimizerOptionsImpl))
56 {
57 }
58 
60 
61 OptimizerOptionsOpaque::OptimizerOptionsOpaque(bool reduceFp32ToFp16, bool debug, bool reduceFp32ToBf16,
62  bool importEnabled, ModelOptions modelOptions, bool exportEnabled,
63  bool debugToFile)
64  : p_OptimizerOptionsImpl(std::make_unique<OptimizerOptionsOpaqueImpl>(reduceFp32ToFp16, debug, reduceFp32ToBf16,
65  importEnabled, modelOptions,
66  exportEnabled, debugToFile))
67 {
68 }
69 
70 OptimizerOptionsOpaque::OptimizerOptionsOpaque(bool reduceFp32ToFp16, bool debug, bool reduceFp32ToBf16,
71  ShapeInferenceMethod shapeInferenceMethod,
72  bool importEnabled, ModelOptions modelOptions, bool exportEnabled,
73  bool debugToFile, bool allowExpandedDims)
74  : p_OptimizerOptionsImpl(std::make_unique<OptimizerOptionsOpaqueImpl>(reduceFp32ToFp16, debug, reduceFp32ToBf16,
75  shapeInferenceMethod, importEnabled,
76  modelOptions, exportEnabled,
77  debugToFile, allowExpandedDims))
78 {
79 }
80 
82  : p_OptimizerOptionsImpl(std::make_unique<OptimizerOptionsOpaqueImpl>())
83 {
84  p_OptimizerOptionsImpl->m_ImportEnabled = OptimizerStruct.m_ImportEnabled;
85  p_OptimizerOptionsImpl->m_shapeInferenceMethod = OptimizerStruct.m_shapeInferenceMethod;
86  p_OptimizerOptionsImpl->m_ModelOptions = OptimizerStruct.m_ModelOptions;
87  p_OptimizerOptionsImpl->m_ProfilingEnabled = OptimizerStruct.m_ProfilingEnabled;
88  p_OptimizerOptionsImpl->m_DebugToFile = OptimizerStruct.m_DebugToFile;
89  p_OptimizerOptionsImpl->m_Debug = OptimizerStruct.m_Debug;
90  p_OptimizerOptionsImpl->m_ReduceFp32ToFp16 = OptimizerStruct.m_ReduceFp32ToFp16;
91  p_OptimizerOptionsImpl->m_ExportEnabled = OptimizerStruct.m_ExportEnabled;
92  p_OptimizerOptionsImpl->m_AllowExpandedDims = OptimizerStruct.m_AllowExpandedDims;
93  p_OptimizerOptionsImpl->m_ReduceFp32ToBf16 = OptimizerStruct.m_ReduceFp32ToBf16;
94 }
95 
97 {
98  p_OptimizerOptionsImpl->m_ImportEnabled = other.GetImportEnabled();
99  p_OptimizerOptionsImpl->m_shapeInferenceMethod = other.GetShapeInferenceMethod();
100  p_OptimizerOptionsImpl->m_ModelOptions = other.GetModelOptions();
101  p_OptimizerOptionsImpl->m_ProfilingEnabled = other.GetProfilingEnabled();
102  p_OptimizerOptionsImpl->m_DebugToFile = other.GetDebugToFileEnabled();
103  p_OptimizerOptionsImpl->m_Debug = other.GetDebugEnabled();
104  p_OptimizerOptionsImpl->m_ReduceFp32ToFp16 = other.GetReduceFp32ToFp16();
105  p_OptimizerOptionsImpl->m_ExportEnabled = other.GetExportEnabled();
106  p_OptimizerOptionsImpl->m_AllowExpandedDims = other.GetAllowExpandedDims();
107  p_OptimizerOptionsImpl->m_ReduceFp32ToBf16 = other.GetReduceFp32ToBf16();
108  return *this;
109 }
110 
112 {
113  p_OptimizerOptionsImpl->m_ImportEnabled = ImportState;
114 }
115 
117 {
118  p_OptimizerOptionsImpl->m_ExportEnabled = ExportState;
119 }
120 
122 {
123  p_OptimizerOptionsImpl->m_ProfilingEnabled = ProfilingState;
124 }
125 
127 {
128  p_OptimizerOptionsImpl->m_Debug = DebugState;
129 }
130 
132 {
133  p_OptimizerOptionsImpl->m_DebugToFile = DebugFileState;
134 }
135 
136 void OptimizerOptionsOpaque::SetReduceFp32ToFp16(bool ReduceFp32ToFp16State)
137 {
138  p_OptimizerOptionsImpl->m_ReduceFp32ToFp16 = ReduceFp32ToFp16State;
139 }
140 
142 {
143  p_OptimizerOptionsImpl->m_shapeInferenceMethod = ShapeInferenceMethodType;
144 }
145 
146 void OptimizerOptionsOpaque::SetAllowExpandedDims(bool ExpandedDimsAllowed)
147 {
148  p_OptimizerOptionsImpl->m_AllowExpandedDims = ExpandedDimsAllowed;
149 }
150 
152 {
153  p_OptimizerOptionsImpl->m_ModelOptions.push_back(NewModelOption);
154 }
155 
157 {
158  return p_OptimizerOptionsImpl->m_ProfilingEnabled;
159 };
160 
162 {
163  return p_OptimizerOptionsImpl->m_ImportEnabled;
164 };
165 
167 {
168  return p_OptimizerOptionsImpl->m_ExportEnabled;
169 };
170 
172 {
173  return p_OptimizerOptionsImpl->m_ReduceFp32ToFp16;
174 };
175 
177 {
178  return p_OptimizerOptionsImpl->m_ReduceFp32ToBf16;
179 }
180 
182 {
183  return p_OptimizerOptionsImpl->m_Debug;
184 }
185 
187 {
188  return p_OptimizerOptionsImpl->m_DebugToFile;
189 }
190 
192 {
193  return p_OptimizerOptionsImpl->m_AllowExpandedDims;
194 }
195 
197 {
198  return p_OptimizerOptionsImpl->m_ModelOptions;
199 }
200 
202 {
203  return p_OptimizerOptionsImpl->m_shapeInferenceMethod;
204 }
205 
206 const std::string OptimizerOptionsOpaque::ToString() const
207 {
208  std::stringstream stream;
209  stream << "OptimizerOptions: \n";
210  stream << "\tReduceFp32ToFp16: " << p_OptimizerOptionsImpl->m_ReduceFp32ToFp16 << "\n";
211  stream << "\tReduceFp32ToBf16: " << p_OptimizerOptionsImpl->m_ReduceFp32ToBf16 << "\n";
212  stream << "\tDebug: " << p_OptimizerOptionsImpl->m_Debug << "\n";
213  stream << "\tDebug to file: " << p_OptimizerOptionsImpl->m_DebugToFile << "\n";
214  stream << "\tShapeInferenceMethod: " <<
215  (p_OptimizerOptionsImpl->m_shapeInferenceMethod == ShapeInferenceMethod::ValidateOnly ?
216  "ValidateOnly" : "InferAndValidate") << "\n";
217  stream << "\tImportEnabled: " << p_OptimizerOptionsImpl->m_ImportEnabled << "\n";
218  stream << "\tExportEnabled: " << p_OptimizerOptionsImpl->m_ExportEnabled << "\n";
219  stream << "\tProfilingEnabled: " << p_OptimizerOptionsImpl->m_ProfilingEnabled << "\n";
220  stream << "\tAllowExpandedDims: " << p_OptimizerOptionsImpl->m_AllowExpandedDims << "\n";
221 
222  stream << "\tModelOptions: \n";
223  for (auto optionsGroup : p_OptimizerOptionsImpl->m_ModelOptions)
224  {
225  for (size_t i=0; i < optionsGroup.GetOptionCount(); i++)
226  {
227  const armnn::BackendOptions::BackendOption option = optionsGroup.GetOption(i);
228  stream << "\t\tBackend: " << optionsGroup.GetBackendId() << "\n"
229  << "\t\t\tOption: " << option.GetName() << "\n"
230  << "\t\t\tValue: " << std::string(option.GetValue().ToString()) << "\n";
231  }
232  }
233 
234  return stream.str();
235 }
236 
238 {
239  return pNetworkImpl->PrintGraph();
240 }
241 
243 {
244  return pNetworkImpl->AddInputLayer(id, name);
245 }
246 
248  const char* name)
249 {
250  return pNetworkImpl->AddArgMinMaxLayer(desc, name);
251 }
252 
254 {
255  return pNetworkImpl->AddCastLayer(name);
256 }
257 
259  const char* name)
260 {
261  return pNetworkImpl->AddComparisonLayer(comparisonDescriptor, name);
262 }
263 
264 
266  const char* name)
267 {
268  return pNetworkImpl->AddConcatLayer(concatDescriptor, name);
269 }
270 
271 
273  const char* name)
274 {
275  return pNetworkImpl->AddConvolution2dLayer(convolution2dDescriptor, name);
276 }
277 
279  const char* name)
280 {
281  return pNetworkImpl->AddConvolution3dLayer(convolution3dDescriptor, name);
282 }
283 
284 
286  const char* name)
287 {
288  return pNetworkImpl->AddDepthToSpaceLayer(depthToSpaceDescriptor, name);
289 }
290 
291 
293  const DepthwiseConvolution2dDescriptor& convolution2dDescriptor,
294  const char* name)
295 {
296  return pNetworkImpl->AddDepthwiseConvolution2dLayer(convolution2dDescriptor, name);
297 }
298 
299 
301 {
302  return pNetworkImpl->AddDequantizeLayer(name);
303 }
304 
305 
307  const DetectionPostProcessDescriptor& descriptor,
308  const ConstTensor& anchors,
309  const char* name)
310 {
311  return pNetworkImpl->AddDetectionPostProcessLayer(descriptor, anchors, name);
312 }
313 
315  const char* name)
316 {
317  return pNetworkImpl->AddElementwiseBinaryLayer(elementwiseBinaryDescriptor, name);
318 }
319 
321  const char* name)
322 {
323  return pNetworkImpl->AddElementwiseUnaryLayer(elementwiseUnaryDescriptor, name);
324 }
325 
327  const char* name)
328 {
329  return pNetworkImpl->AddFillLayer(fillDescriptor, name);
330 }
331 
333  const char* name)
334 {
335  return pNetworkImpl->AddFullyConnectedLayer(fullyConnectedDescriptor, name);
336 }
337 
339  const char* name)
340 {
341  return pNetworkImpl->AddFusedLayer(fusedDescriptor, name);
342 }
343 
345  const char* name)
346 {
347  return pNetworkImpl->AddPermuteLayer(permuteDescriptor, name);
348 }
349 
351  const char* name)
352 {
353  return pNetworkImpl->AddBatchToSpaceNdLayer(batchToSpaceNdDescriptor, name);
354 }
355 
357  const char* name)
358 {
359  return pNetworkImpl->AddPooling2dLayer(pooling2dDescriptor, name);
360 }
361 
363  const char* name)
364 {
365  return pNetworkImpl->AddPooling3dLayer(pooling3dDescriptor, name);
366 }
367 
369  CompiledBlobPtr compiledBlobPtr,
370  const Optional<BackendId>& backend,
371  const char* name)
372 {
373  return pNetworkImpl->AddPrecompiledLayer(preCompiledDescriptor, std::move(compiledBlobPtr), backend, name);
374 }
375 
377  const char* name)
378 {
379  return pNetworkImpl->AddActivationLayer(activationDescriptor, name);
380 }
381 
383  const char* name)
384 {
385  return pNetworkImpl->AddNormalizationLayer(normalizationDescriptor, name);
386 }
387 
388 IConnectableLayer* INetwork::AddSliceLayer(const SliceDescriptor& sliceDescriptor, const char* name)
389 {
390  return pNetworkImpl->AddSliceLayer(sliceDescriptor, name);
391 }
393  const char* name)
394 {
395  return pNetworkImpl->AddSoftmaxLayer(softmaxDescriptor, name);
396 }
397 
399  const char* name)
400 {
401  return pNetworkImpl->AddSplitterLayer(splitterDescriptor, name);
402 }
403 
405 {
406  return pNetworkImpl->AddMergeLayer(name);
407 }
408 
410 {
412  return pNetworkImpl->AddAdditionLayer(name);
414 }
415 
417 {
419  return pNetworkImpl->AddMultiplicationLayer(name);
421 }
422 
424  const ConstTensor& mean,
425  const ConstTensor& variance,
426  const ConstTensor& beta,
427  const ConstTensor& gamma,
428  const char* name)
429 {
430  return pNetworkImpl->AddBatchNormalizationLayer(desc, mean, variance, beta, gamma, name);
431 }
432 
434 {
435  return pNetworkImpl->AddRankLayer(name);
436 }
437 
439  const char* name)
440 {
441  return pNetworkImpl->AddResizeLayer(resizeDescriptor, name);
442 }
443 
445  const char* name)
446 {
447  return pNetworkImpl->AddReduceLayer(reduceDescriptor, name);
448 }
449 
451  const char* name)
452 {
453  return pNetworkImpl->AddInstanceNormalizationLayer(desc, name);
454 }
455 
457  const char* name)
458 {
459  return pNetworkImpl->AddL2NormalizationLayer(desc, name);
460 }
461 
463  const char* name)
464 {
465  return pNetworkImpl->AddLogSoftmaxLayer(logSoftmaxDescriptor, name);
466 }
467 
469  const char* name)
470 {
471  return pNetworkImpl->AddConstantLayer(input, name);
472 }
473 
475  const char* name)
476 {
477  return pNetworkImpl->AddReshapeLayer(reshapeDescriptor, name);
478 }
479 
481  const char* name)
482 {
483  return pNetworkImpl->AddSpaceToBatchNdLayer(spaceToBatchNdDescriptor, name);
484 }
485 
487  const char* name)
488 {
489  return pNetworkImpl->AddSpaceToDepthLayer(spaceToDepthDescriptor, name);
490 }
491 
493 {
494  return pNetworkImpl->AddFloorLayer(name);
495 }
497 {
498  return pNetworkImpl->AddOutputLayer(id, name);
499 }
500 
502  const LstmInputParams& params,
503  const char* name)
504 {
505  return pNetworkImpl->AddLstmLayer(descriptor, params, name);
506 }
507 
509 {
511  return pNetworkImpl->AddDivisionLayer(name);
513 }
514 
516 {
518  return pNetworkImpl->AddSubtractionLayer(name);
520 }
521 
523 {
525  return pNetworkImpl->AddMaximumLayer(name);
527 }
528 
529 IConnectableLayer* INetwork::AddMeanLayer(const MeanDescriptor& meanDescriptor, const char* name)
530 {
531  return pNetworkImpl->AddMeanLayer(meanDescriptor, name);
532 }
533 
535  const char* name)
536 {
537  return pNetworkImpl->AddPadLayer(padDescriptor, name);
538 }
539 
541 {
542  return pNetworkImpl->AddQuantizeLayer(name);
543 }
544 
546  const char* name)
547 {
548  return pNetworkImpl->AddStridedSliceLayer(stridedSliceDescriptor, name);
549 }
550 
552 {
554  return pNetworkImpl->AddMinimumLayer(name);
556 }
557 
559  const char* name)
560 {
561  return pNetworkImpl->AddGatherLayer(descriptor, name);
562 }
563 
565 {
566  return pNetworkImpl->AddGatherNdLayer(name);
567 }
568 
570 {
571  return pNetworkImpl->AddSwitchLayer(name);
572 }
573 
575 {
576  return pNetworkImpl->AddPreluLayer(name);
577 }
578 
580  const ConstTensor& weights,
581  const Optional<ConstTensor>& biases,
582  const char* name)
583 {
584  return pNetworkImpl->AddTransposeConvolution2dLayer(descriptor, weights, biases, name);
585 }
586 
588  const char* name)
589 {
590  return pNetworkImpl->AddTransposeLayer(transposeDescriptor, name);
591 }
592 
594 {
595  return pNetworkImpl->AddShapeLayer(name);
596 }
597 
599  const char* name)
600 {
601  return pNetworkImpl->AddStackLayer(descriptor, name);
602 }
603 
605  const char* name)
606 {
607  return pNetworkImpl->AddStandInLayer(descriptor, name);
608 }
609 
611  const char* name)
612 {
613  return pNetworkImpl->AddQuantizedLstmLayer(params, name);
614 }
615 
617  const LstmInputParams& params,
618  const char* name)
619 {
620  return pNetworkImpl->AddQLstmLayer(descriptor, params, name);
621 }
622 
624  const char* name)
625 {
626  return pNetworkImpl->AddLogicalBinaryLayer(descriptor, name);
627 }
628 
630  const UnidirectionalSequenceLstmDescriptor& descriptor,
631  const LstmInputParams& params,
632  const char* name)
633 {
634  return pNetworkImpl->AddUnidirectionalSequenceLstmLayer(descriptor, params, name);
635 }
636 
638  const char* name)
639 {
640  return pNetworkImpl->AddChannelShuffleLayer(descriptor, name);
641 }
642 
644  const char* name)
645 {
646  return pNetworkImpl->AddBatchMatMulLayer(descriptor, name);
647 }
648 
650 {
651  return pNetworkImpl->AddReverseV2Layer(name);
652 }
653 
655  const char *name)
656 {
657  return pNetworkImpl->AddTileLayer(descriptor, name);
658 }
659 
661  const char* name)
662 {
663  return pNetworkImpl->AddBroadcastToLayer(descriptor, name);
664 }
665 
667  const char *name)
668 {
669  return pNetworkImpl->AddScatterNdLayer(descriptor, name);
670 }
671 
673 {
674  return pNetworkImpl->ExecuteStrategy(strategy);
675 }
676 
678 {
679  return new INetwork(networkOptions);
680 }
681 
683 {
684  return INetworkPtr(CreateRaw(networkOptions), &INetwork::Destroy);
685 }
686 
688 {
689  delete network;
690 }
691 
693  : pOptimizedNetworkImpl(new OptimizedNetworkImpl(*other.pOptimizedNetworkImpl.get(), modelOptions)) {}
694 
695 IOptimizedNetwork::IOptimizedNetwork(std::unique_ptr<Graph> graph)
696  : pOptimizedNetworkImpl(new OptimizedNetworkImpl(std::move(graph))) {}
697 
698 IOptimizedNetwork::IOptimizedNetwork(std::unique_ptr<OptimizedNetworkImpl> impl)
699  : pOptimizedNetworkImpl(std::move(impl)) {}
700 
701 IOptimizedNetwork::IOptimizedNetwork(std::unique_ptr<Graph> graph, const ModelOptions& modelOptions)
702  : pOptimizedNetworkImpl(new OptimizedNetworkImpl(std::move(graph), modelOptions)) {}
703 
705 
707 {
708  delete network;
709 }
710 
712 {
713  return pOptimizedNetworkImpl->PrintGraph();
714 }
715 
716 Status IOptimizedNetwork::SerializeToDot(std::ostream& stream) const
717 {
718  return pOptimizedNetworkImpl->SerializeToDot(stream);
719 }
720 
721 const std::shared_ptr<IProfiler>& IOptimizedNetwork::GetProfiler() const
722 {
723  return pOptimizedNetworkImpl->GetGraph().GetProfiler();
724 }
725 
726 arm::pipe::ProfilingGuid IOptimizedNetwork::GetGuid() const
727 {
728  return pOptimizedNetworkImpl->GetGuid();
729 }
730 
732 {
733  return pOptimizedNetworkImpl->GetNumInputs();
734 }
735 
737 {
738  return pOptimizedNetworkImpl->GetNumOutputs();
739 }
740 
742 {
743  m_Graph->Print();
744  return Status::Success;
745 }
746 
747 Status OptimizedNetworkImpl::SerializeToDot(std::ostream& stream) const
748 {
749  return m_Graph->SerializeToDot(stream);
750 }
751 
753 {
754  return m_Graph->GetNumInputs();
755 }
756 
758 {
759  return m_Graph->GetNumOutputs();
760 }
761 
762 void ReportError(const std::string& errorMessage,
763  Optional<std::vector<std::string>&> errorMessages)
764 {
765  std::stringstream fullErrorMessage;
766  fullErrorMessage << "ERROR: " << errorMessage;
767  ARMNN_LOG(warning) << fullErrorMessage.str();
768  if (errorMessages)
769  {
770  errorMessages.value().push_back(fullErrorMessage.str());
771  }
772 }
773 
774 void ReportWarning(const std::string& warningMessage,
775  Optional<std::vector<std::string>&> warningMessages)
776 {
777  std::stringstream fullWarningMessage;
778  fullWarningMessage << "WARNING: " << warningMessage;
779  ARMNN_LOG(warning) << fullWarningMessage.str();
780  if (warningMessages)
781  {
782  warningMessages.value().push_back(fullWarningMessage.str());
783  }
784 }
785 
787  const Layer* layer,
788  const BackendSettings& backendSettings,
789  Optional<std::vector<std::string>&> errMessages)
790 {
791  std::stringstream failureMsg;
792  failureMsg << "Layer of type " << GetLayerTypeAsCString(layer->GetType())
793  << " is not supported on any preferred backend " << backendSettings.m_PreferredBackends;
794  ReportError(failureMsg.str(), errMessages);
795 
796  res.m_Error = true;
797  return res;
798 }
799 
800 
801 bool CheckScaleSetOnQuantizedType(Layer* layer, Optional<std::vector<std::string>&> errMessages)
802 {
803  bool noErrors = true;
804  unsigned int numOutputs = layer->GetNumOutputSlots();
805  for (unsigned int i = 0; i < numOutputs; i++) {
806  OutputSlot& outputSlot = layer->GetOutputSlot(i);
807  TensorInfo info = outputSlot.GetTensorInfo();
808  auto quantizationDataType = info.GetDataType();
809  auto quantizationScales = info.GetQuantizationScales();
810  // For any Quantized Tensor ensure scale(s) are set
811  switch(quantizationDataType) {
812  case DataType::QAsymmU8:
813  case DataType::QSymmS16:
814  case DataType::QSymmS8:
815  case DataType::QAsymmS8:
816  if ((quantizationDataType == DataType::QAsymmU8 || quantizationDataType == DataType::QAsymmS8)
817  && info.HasPerAxisQuantization()) {
818  throw InvalidArgumentException("Per Axis Quantization is not supported in "
819  "Asymmetric Quantization Datatype.");
820  }
821  // Softmax under QuantisedAsymm8 must always be scale (1.0f/256.0f) and offset 0
822  if (!info.HasPerAxisQuantization() && quantizationDataType == DataType::QAsymmU8 &&
823  (info.GetQuantizationScale() != (1.0f / 256.0f) ||
824  info.GetQuantizationOffset() != 0) &&
825  layer->GetType() == armnn::LayerType::Softmax) {
826  std::stringstream ss;
827  ss << "Quantization parameters for Softmax layer (Scale: " <<
828  info.GetQuantizationScale() << " and Offset: " << info.GetQuantizationOffset() <<
829  ") are incorrect and have been updated to Scale: 0.00390625 and Offset: 0";
830  ARMNN_LOG(warning) << ss.str();
831  info.SetQuantizationScale((1.0f / 256.0f));
832  info.SetQuantizationOffset(0);
833  outputSlot.SetTensorInfo(info);
834  ReportError(ss.str(), errMessages);
835  }
836  break;
837  default:
838  break;
839  }
840  }
841  return noErrors;
842 }
843 
845  Graph& graph,
846  Layer* layer,
847  BackendId backend,
848  DataType dataTypeIn,
849  DataType dataTypeOut,
850  const std::vector<BackendId>& availablePreferredBackends,
851  std::string& reasonIfUnsupported,
852  Optional<std::vector<std::string>&> errMessages)
853 {
854  OptimizationResult result;
855 
856  // Helper lambda to compose meaningful error message before returning with error
857  auto ReturnError = [&](const Layer* layer)
858  {
859  return ReturnWithError(result, layer, backendSettings, errMessages);
860  };
861 
862  // need to set the compute device on the layer
863  // before we can check if it is supported
864  layer->SetBackendId(backend);
865  std::string currentReasonIfUnsupported;
866 
867  // To run FP16 operations on CpuAcc we need at least v8.2 architecture. If the available architecture
868  // is older than v8.2, we can check if the operator is supported by changing operator inputs & outputs
869  // to be FP32 and inserting convert layers around the FP32 operator.
870  bool isLayerSupported = IWorkloadFactory::IsLayerSupported(*layer, EmptyOptional(), currentReasonIfUnsupported);
871  reasonIfUnsupported += currentReasonIfUnsupported;
872  // This string matches the error message that is produced by acl when attempting to run FP16 kernels on
873  // a cpu or build that does not have fp16 support. We use this to check if we should add
874  // conversion layers or not.
875  std::string checkStr = "This CPU architecture does not support F16 data type, you need v8.2 or above";
876  if (!isLayerSupported || currentReasonIfUnsupported.find(checkStr) != std::string::npos)
877  {
878  if (dataTypeIn == DataType::Float16 || dataTypeOut == DataType::Float16)
879  {
880  if (IWorkloadFactory::IsLayerSupported(*layer, DataType::Float32, reasonIfUnsupported)
882  && layer->GetType() != LayerType::ConvertFp16ToFp32)
883  {
884  auto ConstantLayerFromFp16ToFp32 = [](Layer& layer)
885  {
886  if (layer.GetType() == LayerType::Constant)
887  {
888  ConstantLayer* constantLayer = PolymorphicDowncast<ConstantLayer*>(&layer);
889 
890  auto& info = constantLayer->m_LayerOutput->GetTensorInfo();
891 
892  if (info.GetDataType() == DataType::Float16)
893  {
894  std::vector<float> newValues(info.GetNumElements());
895 
897  constantLayer->m_LayerOutput->GetConstTensor<Half>(),
898  info.GetNumElements(),
899  newValues.data());
900 
901  TensorInfo newInfo(info);
903  ConstTensor newInput(newInfo, newValues);
904  constantLayer->m_LayerOutput.reset(new ScopedTensorHandle(newInput));
905 
906  layer.GetOutputSlot(0).SetTensorInfo(newInfo);
907  }
908  }
909  };
910 
911  bool checkType = false;
912 
913  for (auto inputSlot : layer->GetInputSlots())
914  {
915  auto connectedOutputSlot = inputSlot.GetConnectedOutputSlot();
916  if (connectedOutputSlot->GetOwningLayer().GetType() == LayerType::Constant)
917  {
918  if (connectedOutputSlot->GetNumConnections() == 1)
919  {
920  checkType = true;
921  ConstantLayerFromFp16ToFp32(connectedOutputSlot->GetOwningLayer());
922  }
923  }
924  }
925 
926  // Insert FP16 -> FP32 conversion layer before current layer
927  std::vector<ConvertFp16ToFp32Layer*> convertFp16ToFp32Layers;
928  if (dataTypeIn == DataType::Float16)
929  {
930  convertFp16ToFp32Layers =
931  InsertConvertFp16ToFp32LayersBefore(graph, *layer, checkType);
932  }
933 
934  // Insert FP32 -> FP16 conversion layer after current layer
935  std::vector<ConvertFp32ToFp16Layer*> convertFp32ToFp16Layers;
936  if (dataTypeOut == DataType::Float16)
937  {
938  convertFp32ToFp16Layers =
939  InsertConvertFp32ToFp16LayersAfter(graph, *layer);
940  }
941 
942  // Assign a supported backend to the newly introduced conversion layers
943  auto AssignFirstSupportedBackend = [&](Layer* layer, BackendId preferredBackend)
944  {
945  bool supportedBackendFound = false;
946  std::string reasonIfUnsupported;
947 
948  // Try preferred backend first
949  layer->SetBackendId(preferredBackend);
951  EmptyOptional(),
952  reasonIfUnsupported))
953  {
954  supportedBackendFound = true;
955  }
956  else
957  {
958  for (const auto& backend : availablePreferredBackends)
959  {
960  // Skip preferred backend (we already determined that it is not supported)
961  if (backend == preferredBackend)
962  {
963  continue;
964  }
965 
966  layer->SetBackendId(backend);
968  EmptyOptional(),
969  reasonIfUnsupported))
970  {
971  supportedBackendFound = true;
972  break;
973  }
974  }
975  }
976 
977  return supportedBackendFound;
978  };
979 
980  for (ConvertFp16ToFp32Layer* convertLayer : convertFp16ToFp32Layers)
981  {
982  if (!AssignFirstSupportedBackend(convertLayer, backend))
983  {
984  return ReturnError(convertLayer);
985  }
986  }
987 
988  for (ConvertFp32ToFp16Layer* convertLayer : convertFp32ToFp16Layers)
989  {
990  if (!AssignFirstSupportedBackend(convertLayer, backend))
991  {
992  return ReturnError(convertLayer);
993  }
994  }
995 
996  return result;
997  }
998  }
999 
1000  std::stringstream warningMsg;
1001  warningMsg << "Layer of type " << GetLayerTypeAsCString(layer->GetType())
1002  << " is not supported on requested backend " << layer->GetBackendId().Get()
1003  << " for input data type " << GetDataTypeName(dataTypeIn)
1004  << " and output data type " << GetDataTypeName(dataTypeOut)
1005  << " (reason: " << reasonIfUnsupported
1006  << "), falling back to the next backend.";
1007  ReportWarning(warningMsg.str(), errMessages);
1008 
1009  return OptimizationResult(true, false);
1010  }
1011  else
1012  {
1013  return result;
1014  }
1015 }
1016 
1017 inline std::vector<DataType> GetLayerInOutDatatype(const Layer* layer)
1018 {
1019  DataType dataTypeIn = layer->GetNumInputSlots() == 0 ? DataType::Float32 :
1021  DataType dataTypeOut = layer->GetNumOutputSlots() == 0 ? DataType::Float32 :
1022  layer->GetOutputSlot(0).GetTensorInfo().GetDataType();
1023  return {dataTypeIn, dataTypeOut};
1024 }
1025 
1027  const std::vector<BackendId>& availablePreferredBackends)
1028 {
1029  bool hasFp16 = false;
1030  // Check if the first preferred backend has FP16 support
1031  auto firstBackend = availablePreferredBackends[0];
1032  auto backendObjPtr = backends.find(firstBackend)->second.get();
1033 
1034  auto hasFp16Capability = BackendOptions::BackendOption{"HasFp16", true};
1035  auto backendCapabilities = backendObjPtr->GetCapabilities();
1036 
1037  if (HasMatchingCapability(hasFp16Capability, backendCapabilities))
1038  {
1039  // First preferred backend has FP16 support. Enable reduce FP32 to FP16 when fp16-turbo-mode is enabled.
1040  hasFp16 = true;
1041  ARMNN_LOG(debug) << "The first available preferred backend: " << firstBackend
1042  << ", has FP16 support.";
1043  }
1044  else
1045  {
1046  ARMNN_LOG(warning) << "The first available preferred backend: " << firstBackend
1047  << ", does not have FP16 support. "
1048  << "The FP16 turbo mode option will be disable. It will run using FP32.";
1049  }
1050 
1051  // Check if the rest of the available preferred backends have FP16 support
1052  for (size_t i = 1; i < availablePreferredBackends.size(); ++i)
1053  {
1054  auto backend = availablePreferredBackends[i];
1055  backendObjPtr = backends.find(backend)->second.get();
1056  backendCapabilities = backendObjPtr->GetCapabilities();
1057  if (!HasMatchingCapability(hasFp16Capability, backendCapabilities))
1058  {
1059  ARMNN_LOG(warning) << "Next preferred backend: " << backend << ", does not have FP16 support. "
1060  << "It will run using FP32 when falling back to this backend.";
1061  }
1062  else
1063  {
1064  ARMNN_LOG(debug) << "Next preferred backend: " << backend << ", has FP16 support.";
1065  }
1066  }
1067 
1068  return hasFp16;
1069 }
1070 
1071 // Refactor to allow passing the IConnectableLayer* rather than Layer Iterator
1072 // on Graph and SubgraphView which are different types.
1074  IConnectableLayer* it,
1075  Optional<std::vector<std::string>&> errMessages,
1076  OptimizationResult& result,
1077  BackendSettings& backendSettings,
1078  std::vector<BackendId>& availablePreferredBackends)
1079 {
1080  auto ReturnError = [&](const Layer* layer)
1081  {
1082  return ReturnWithError(result, layer, backendSettings, errMessages);
1083  };
1084 
1085  auto layer = PolymorphicDowncast<Layer*>(it);
1086 
1087  if (layer->GetType() == LayerType::Input)
1088  {
1089  return;
1090  }
1091 
1092  std::vector<DataType> inOutDataType = GetLayerInOutDatatype(layer);
1093 
1094  std::string reasonIfUnsupported;
1095  bool found = false;
1096  if (!CheckScaleSetOnQuantizedType(layer, errMessages))
1097  {
1098  // don't bomb immediately, find all the quantized outputs
1099  // which haven't had a scale set and report them all back.
1100  result.m_Error = true;
1101  }
1102 
1103  // First try assign layer to hint backend
1104  if (layer->GetBackendHint().has_value() &&
1105  backendSettings.IsBackendSupported(layer->GetBackendHint().value()) &&
1106  AttemptBackendAssignment(backendSettings,
1107  optNetObjPtr->GetGraph(),
1108  layer,
1109  layer->GetBackendHint().value(),
1110  inOutDataType[0],
1111  inOutDataType[1],
1112  availablePreferredBackends,
1113  reasonIfUnsupported,
1114  errMessages).IsOk())
1115  {
1116  found = true;
1117  backendSettings.m_SelectedBackends.insert(layer->GetBackendHint().value());
1118  }
1119  else
1120  {
1121  // Try assign layer to prefered list of backends
1122  for (const auto& backend : availablePreferredBackends)
1123  {
1124  if (layer->GetBackendHint().has_value() &&
1125  layer->GetBackendHint().value() == backend)
1126  {
1127  continue; //Don't re-test the backend hint
1128  }
1129 
1130  OptimizationResult res = AttemptBackendAssignment(backendSettings,
1131  optNetObjPtr->GetGraph(),
1132  layer,
1133  backend,
1134  inOutDataType[0],
1135  inOutDataType[1],
1136  availablePreferredBackends,
1137  reasonIfUnsupported,
1138  errMessages);
1139 
1140  if (res.IsOk())
1141  {
1142  found = true;
1143  backendSettings.m_SelectedBackends.insert(backend);
1144  break;
1145  }
1146  else if (res.IsError())
1147  {
1148  result = res; // Cannot continue.
1149  // Note: we don't need to log the error as it would already
1150  // be logged in AttemptBackendAssignment().
1151  }
1152  }
1153  }
1154 
1155  // If the layer is unsupported by any devices, log and return a null network.
1156  if (!found)
1157  {
1158  // NOTE: if the layer is not an operation queue type AND we have not got CpuRef as a
1159  // fallback we should set the compute device on the layer to CpuRef (these are not
1160  // available as accelerated operations, or are only available under certain
1161  // conditions, currently they comprise MemCopy, Constant, Permute)
1162  armnn::LayerType layerType = layer->GetType();
1163  if (!backendSettings.IsCpuRefUsed() && (layerType == armnn::LayerType::MemCopy ||
1164  layerType == armnn::LayerType::Constant ||
1165  layerType == armnn::LayerType::Permute))
1166  {
1167  BackendId cpuBackendId(armnn::Compute::CpuRef);
1168  layer->SetBackendId(cpuBackendId);
1169  backendSettings.m_SelectedBackends.insert(cpuBackendId);
1170  }
1171  else
1172  {
1173  result = ReturnError(layer);
1174  }
1175  }
1176 
1177 }
1178 
1180  BackendSettings& backendSettings,
1181  Graph::Iterator& firstLayer,
1182  Graph::Iterator& lastLayer,
1183  Optional<std::vector<std::string>&> errMessages)
1184 {
1185  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_AssignBackends");
1186  OptimizationResult result;
1187 
1188  auto availablePreferredBackends = backendSettings.GetAvailablePreferredBackends();
1189  if (availablePreferredBackends.empty())
1190  {
1191  std::stringstream failureMsg;
1192  failureMsg << "No preferred backends are available";
1193  ReportError(failureMsg.str(), errMessages);
1194 
1195  result.m_Error = true;
1196  return result;
1197  }
1198 
1199  for (auto it = firstLayer; it != lastLayer; ++it)
1200  {
1201  auto layer = PolymorphicDowncast<Layer*>(*it);
1202  std::vector<DataType> inOutDataType = GetLayerInOutDatatype(layer);
1203 
1204  // In AttemptBackendAssignment() we check:
1205  // - if input/output datatypes of the layer are float16
1206  // - if the layer is supported with these datatypes
1207  // If the layer is not supported (failing on ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED() in clframework),
1208  // we attempt to insert convertion layers either side of the new fp32 layer.
1209  bool isFloat16 = false;
1210  for (auto type : inOutDataType)
1211  {
1212  if (type == DataType::Float16)
1213  {
1214  isFloat16 = true;
1215  break;
1216  }
1217  }
1218 
1219  if (layer->GetBackendId() == "Unknown" || isFloat16)
1220  {
1221  AssignBackendsIConnectable(optNetObjPtr,
1222  *it,
1223  errMessages,
1224  result,
1225  backendSettings,
1226  availablePreferredBackends);
1227  }
1228  }
1229 
1230  for (auto it = firstLayer; it != lastLayer; ++it)
1231  {
1232  auto layer = PolymorphicDowncast<Layer*>(*it);
1233 
1234  if(layer->GetType() == LayerType::Input)
1235  {
1236  BackendId connectedBackendId = layer->GetOutputSlot(0).GetConnection(0)->GetOwningLayer().GetBackendId();
1237  layer->SetBackendId(connectedBackendId);
1238  }
1239  }
1240 
1241  return result;
1242 }
1243 
1245  BackendSettings& backendSettings,
1248  Optional<std::vector<std::string>&> errMessages)
1249 {
1250  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_AssignBackends");
1251  OptimizationResult result;
1252 
1253  auto availablePreferredBackends = backendSettings.GetAvailablePreferredBackends();
1254  if (availablePreferredBackends.empty())
1255  {
1256  std::stringstream failureMsg;
1257  failureMsg << "No preferred backends are available";
1258  ReportError(failureMsg.str(), errMessages);
1259 
1260  result.m_Error = true;
1261  return result;
1262  }
1263 
1264  for (auto it = firstLayer; it != lastLayer; ++it)
1265  {
1266  AssignBackendsIConnectable(optNetObjPtr,
1267  *it,
1268  errMessages,
1269  result,
1270  backendSettings,
1271  availablePreferredBackends);
1272  }
1273 
1274  for (auto it = firstLayer; it != lastLayer; ++it)
1275  {
1276  auto layer = PolymorphicDowncast<Layer*>(*it);
1277 
1278  if(layer->GetType() == LayerType::Input)
1279  {
1280  BackendId connectedBackendId = layer->GetOutputSlot(0).GetConnection(0)->GetOwningLayer().GetBackendId();
1281  layer->SetBackendId(connectedBackendId);
1282  }
1283  }
1284 
1285  return result;
1286 }
1287 
1289  BackendSettings& backendSettings,
1290  SubgraphView& subgraph,
1291  Optional<std::vector<std::string>&> errMessages)
1292 {
1293  SubgraphView::IConnectableLayerIterator firstLayer = subgraph.begin();
1294  SubgraphView::IConnectableLayerIterator lastLayer = subgraph.end();
1295  return AssignBackends(optNetObjPtr,
1296  backendSettings,
1297  firstLayer,
1298  lastLayer,
1299  errMessages);
1300 }
1301 
1303  BackendSettings& backendSettings)
1304 {
1305  BackendsMap backends;
1306  auto const& backendRegistry = BackendRegistryInstance();
1307  for (auto&& selectedBackend : backendSettings.m_SupportedBackends)
1308  {
1309  auto backendFactory = backendRegistry.GetFactory(selectedBackend);
1310  auto backendObjPtr = backendFactory();
1311 
1312  backendObjPtr->RegisterTensorHandleFactories(handleFactoryRegistry);
1313 
1314  backends[backendObjPtr->GetId()] = std::move(backendObjPtr);
1315  }
1316 
1317  return backends;
1318 }
1319 
1321  BackendSettings& backendSettings,
1322  BackendsMap& backends,
1323  const ModelOptions& modelOptions,
1324  Optional<std::vector<std::string>&> errMessages)
1325 {
1326  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_ApplyBackendOptimizations")
1327  OptimizationResult result;
1328 
1329  // Get the optimized graph
1330  Graph& optGraph = optNetObjPtr->GetGraph();
1331 
1332  // Run backend specific optimizations
1333  for (auto&& selectedBackend : backendSettings.m_SelectedBackends)
1334  {
1335  auto backendObjPtr = backends.find(selectedBackend)->second.get();
1336  if (!backendObjPtr)
1337  {
1338  throw armnn::NullPointerException("backendObjPtr must not be null.");
1339  }
1340 
1341  if (selectedBackend == armnn::Compute::GpuAcc || selectedBackend == armnn::Compute::CpuAcc)
1342  {
1345  }
1346 
1347  // Select sub-graphs based on backend
1350  // Select layers assigned to the requested backend
1351  [&backendObjPtr](const Layer& layer)
1352  {
1353 
1354  return layer.GetType() != LayerType::Input &&
1355  layer.GetType() != LayerType::Output &&
1356  layer.GetBackendId() == backendObjPtr->GetId();
1357  });
1358  if (subgraphs.empty())
1359  {
1360  // No sub-graphs found, try with next selected backend
1361  continue;
1362  }
1363 
1364  // Try to optimize each sub-graph
1365  for (auto& subgraph : subgraphs)
1366  {
1367  // Try to optimize the current sub-graph
1368  ARMNN_SCOPED_PROFILING_EVENT(backendObjPtr->GetId(), "Optimizer_OptimizeSubgraph");
1369  OptimizationViews optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraph, modelOptions);
1370  if (!optimizationViews.Validate(*subgraph))
1371  {
1372  throw armnn::Exception("optimizationViews must have a valid subgraph.");
1373  }
1374 
1375  // Optimization attempted, check the resulting optimized sub-graph
1376  for (auto& substitution : optimizationViews.GetSubstitutions())
1377  {
1378  // Sub-graph optimized, substitute the sub-graph with the new optimized one in the main optimized graph
1379  SubgraphView& replacementSubgraph = substitution.m_ReplacementSubgraph;
1380  SubgraphView& substitutableSubgraph = substitution.m_SubstitutableSubgraph;
1381  optGraph.SubstituteSubgraph(substitutableSubgraph, replacementSubgraph);
1382 
1383  // Assign the current backend to the optimized sub-graph
1384  const SubgraphView::IConnectableLayers& subgraphLayers = replacementSubgraph.GetIConnectableLayers();
1385  std::for_each(subgraphLayers.begin(), subgraphLayers.end(), [&selectedBackend](IConnectableLayer* l)
1386  {
1387  PolymorphicDowncast<Layer*>(l)->SetBackendId(selectedBackend);
1388  });
1389  }
1390 
1391  // Remove deleted sub-graphs
1392  for (auto& deletedSubgraph : optimizationViews.GetDeletedSubgraphs())
1393  {
1394  for (auto& l : deletedSubgraph.GetIConnectableLayers())
1395  {
1396  Layer* deletedLayer = PolymorphicDowncast<Layer*>(l);
1397  for (unsigned int in = deletedLayer->GetNumInputSlots(); in > 0; --in)
1398  {
1399  auto inputSlot = deletedLayer->GetInputSlot(in -1);
1400  OutputSlot* parentOut = inputSlot.GetConnectedOutputSlot();
1401  parentOut->Disconnect(inputSlot);
1402  for (unsigned int out = deletedLayer->GetOutputSlot(in -1).GetNumConnections(); out > 0; --out)
1403  {
1404  InputSlot* childIn = deletedLayer->GetOutputSlot(in - 1).GetConnection(out -1);
1405  deletedLayer->GetOutputSlot(in - 1).Disconnect(*childIn);
1406  parentOut->Connect(*childIn);
1407  }
1408  }
1409  optGraph.EraseLayer(deletedLayer);
1410  }
1411  }
1412 
1413  if (!optimizationViews.GetFailedSubgraphs().empty())
1414  {
1415  std::stringstream warningMsg;
1416  warningMsg << "Some sub-graph(s) failed to optimized on " << backendObjPtr->GetId() << " backend.";
1417  ReportWarning(warningMsg.str(), errMessages);
1418 
1419  // Failed to optimize the given sub-graph, re-assign the sub-graph layers to other available backends
1420  BackendSettings settingsCopy(backendSettings);
1421  if (!backendObjPtr->GetId().IsCpuRef())
1422  {
1423  // Add the current backend to the list of backends to ignore
1424  settingsCopy.m_IgnoredBackends.insert(backendObjPtr->GetId());
1425  }
1426 
1427  int count=0;
1428  for (auto& failedSubgraph : optimizationViews.GetFailedSubgraphs())
1429  {
1430  // An error occurred: the optimization was attempted but not performed, try different backends
1431  std::stringstream subgraphMsg;
1432  subgraphMsg << "Re-assigning backends to " << failedSubgraph.GetIConnectableLayers().size()
1433  << " layers inside sub-graph " << count++;
1434  ReportWarning(subgraphMsg.str(), errMessages);
1435 
1436  OptimizationResult reassignmentResult = AssignBackends(optNetObjPtr,
1437  settingsCopy,
1438  *subgraph,
1439  errMessages);
1440  if (reassignmentResult.m_Error)
1441  {
1442  // Failed to re-assign one of the remaining backends to each layer of the sub-graph
1443  result.m_Error = true;
1444  return result;
1445  }
1446  }
1447  }
1448  }
1449  }
1450 
1451  return result;
1452 }
1453 
1456  TensorHandleFactoryRegistry& registry)
1457 {
1458  if (src != dst)
1459  {
1460  ITensorHandleFactory* srcFactory = registry.GetFactory(src);
1461  ITensorHandleFactory* dstFactory = registry.GetFactory(dst);
1462 
1463  if (srcFactory && dstFactory &&
1464  (srcFactory->GetExportFlags() & dstFactory->GetImportFlags()) != 0)
1465  {
1466  return false;
1467  }
1468  return true;
1469  }
1470  return false;
1471 }
1472 
1473 // Find the handle factory for the input layer which results in fewest required copies.
1475  OutputSlot& slot,
1476  TensorHandleFactoryRegistry& registry,
1477  bool importEnabled)
1478 {
1479  Layer& layer = slot.GetOwningLayer();
1480 
1481  if (layer.GetType() != LayerType::Input)
1482  {
1483  throw armnn::Exception("layer must be of type \"Input\".");
1484  }
1485 
1486  // Explicitly select the tensorhandle factory for InputLayer because the rules for it are slightly different. It
1487  // doesn't matter which backend it is assigned to because they all use the same implementation, which
1488  // requires Map/Unmap support. This means that, so long as the handle type supports map/unmap semantics, we can
1489  // select a factory with maximum compatibility with the layers connected to the InputLayer.
1490 
1491  // First ensure the from backends can support the TensorHandeAPI
1492  auto frmBackend = backends.find(layer.GetBackendId());
1493  if (frmBackend == backends.end() ||
1494  !frmBackend->second->SupportsTensorAllocatorAPI())
1495  {
1497  }
1498 
1499  // Go through all connections to the output slot and determine the TensorHandleFactory which results in the
1500  // fewest copies.
1501  std::map<ITensorHandleFactory::FactoryId, int> factoryScores;
1502  int topScore = 0;
1504 
1505  for (auto&& connection : slot.GetConnections())
1506  {
1507 
1508  const Layer& connectedLayer = connection->GetOwningLayer();
1509 
1510  auto toBackend = backends.find(connectedLayer.GetBackendId());
1511  if (toBackend == backends.end())
1512  {
1513  throw armnn::Exception("Backend id not found for the connected layer");
1514  }
1515 
1516  if (!toBackend->second.get()->SupportsTensorAllocatorAPI())
1517  {
1518  // The destination backend does not support the tensor allocator API, move to the next one
1519  continue;
1520  }
1521 
1522  auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
1523  for (auto&& dst : dstPrefs)
1524  {
1525  // Input layers use the mem copy workload or import, so the selected factory must
1526  // support either the map/unmap API or Import API
1527  ITensorHandleFactory* factory = registry.GetFactory(dst);
1528  if (importEnabled && factory->GetImportFlags() == 0)
1529  {
1530  continue;
1531  }
1532  else if (!importEnabled && !factory->SupportsMapUnmap())
1533  {
1534  continue;
1535  }
1536 
1537  auto it = factoryScores.find(dst);
1538  if (it == factoryScores.end())
1539  {
1540  // Add new score to the table
1541  factoryScores[dst] = 0;
1542  if (topChoice == ITensorHandleFactory::LegacyFactoryId)
1543  {
1544  topChoice = dst;
1545  }
1546  }
1547  else
1548  {
1549  // Increase the score
1550  factoryScores[dst]++;
1551 
1552  // Track the best option
1553  if (factoryScores[dst] > topScore)
1554  {
1555  topScore = factoryScores[dst];
1556  topChoice = dst;
1557  }
1558  }
1559  }
1560  }
1561 
1562  return topChoice;
1563 }
1564 
1565 // Find the handle factory for the output layer which results in fewest required copies.
1567  OutputSlot& slot,
1568  TensorHandleFactoryRegistry& registry)
1569 {
1570  IgnoreUnused(backends, slot, registry);
1572 }
1573 
1574 // For all handle factories supported on the source backend, we wish to find the one which requires the fewest copies
1575 // when considering all connections.
1577  OutputSlot& outputSlot,
1578  TensorHandleFactoryRegistry& registry,
1579  bool exportEnabled)
1580 {
1581  // First ensure the from backends can support the TensorHandeAPI
1582  Layer& layer = outputSlot.GetOwningLayer();
1583  auto frmBackend = backends.find(layer.GetBackendId());
1584  if (frmBackend == backends.end() ||
1585  !frmBackend->second->SupportsTensorAllocatorAPI())
1586  {
1588  }
1589 
1590  bool outputConnection = false;
1591  for (auto&& connection : outputSlot.GetConnections())
1592  {
1593  const Layer& connectedLayer = connection->GetOwningLayer();
1594  if (connectedLayer.GetType() == LayerType::Output)
1595  {
1596  outputConnection = true;
1597  }
1598  }
1599 
1600  IBackendInternal* srcBackend = frmBackend->second.get();
1601  auto srcPrefs = srcBackend->GetHandleFactoryPreferences();
1602 
1603  // Initialize the scores
1604  std::map<ITensorHandleFactory::FactoryId, int> factoryScores;
1605  for (auto&& pref : srcPrefs)
1606  {
1607  if (exportEnabled)
1608  {
1609  ITensorHandleFactory* factory = registry.GetFactory(pref);
1610  if (outputConnection)
1611  {
1612  // Check if this is fallback case
1613  bool fallbackConnection = false;
1614  for (auto&& inputSlot : layer.GetInputSlots())
1615  {
1616  if (inputSlot.GetConnectedOutputSlot()->GetOwningLayer().GetBackendId() != layer.GetBackendId())
1617  {
1618  fallbackConnection = true;
1619  }
1620  }
1621  if (fallbackConnection)
1622  {
1623  auto factoryCap = factory->GetCapabilities(&layer, &layer, CapabilityClass::FallbackImportDisabled);
1624  // Cannot use factory import if fallback import is not supported.
1625  if (!factoryCap.empty())
1626  {
1627  continue;
1628  }
1629  }
1630  else if (factory->GetExportFlags() == 0)
1631  {
1632  continue;
1633  }
1634  }
1635  if (!outputConnection)
1636  {
1637  auto factoryCap = factory->GetCapabilities(&layer, &layer, CapabilityClass::FallbackImportDisabled);
1638  // Cannot use factory import if fallback import is not supported.
1639  if (!factoryCap.empty())
1640  {
1641  continue;
1642  }
1643  }
1644 
1645  }
1646  else
1647  {
1648  // Only consider factories that support map/unmap
1649  ITensorHandleFactory* factory = registry.GetFactory(pref);
1650  if (!factory->SupportsMapUnmap())
1651  {
1652  // The current tensor handle factory does not support the map/unmap strategy, move to the next one
1653  continue;
1654  }
1655  }
1656 
1657 
1658  auto it = factoryScores.find(pref);
1659  if (it == factoryScores.end())
1660  {
1661  // Add new score to the table
1662  factoryScores[pref] = 0;
1663  }
1664  }
1665 
1666  // Score each handle factory based on how many times it requires copies on the slot connections
1667  for (auto&& connection : outputSlot.GetConnections())
1668  {
1669  const Layer& connectedLayer = connection->GetOwningLayer();
1670 
1671  auto toBackend = backends.find(connectedLayer.GetBackendId());
1672  if (toBackend == backends.end())
1673  {
1674  throw armnn::Exception("Backend id not found for the connected layer");
1675  }
1676 
1677  auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
1678  for (auto&& src : srcPrefs)
1679  {
1680  if (factoryScores.find(src) == factoryScores.end()) // Don't consider excluded factories
1681  {
1682  continue;
1683  }
1684 
1685  for (auto&& dst : dstPrefs)
1686  {
1687  if (RequiresCopy(src, dst, registry))
1688  {
1689  // Copy avoided, increase the score
1690  factoryScores[src]++;
1691  break;
1692  }
1693  }
1694  }
1695  }
1696 
1697  // Find the lowest score
1698  int minScore = std::numeric_limits<int>::max();
1699  for (auto it : factoryScores)
1700  {
1701  minScore = std::min(minScore, it.second);
1702  }
1703 
1704  // Collect factories matching the best(lowest) score
1705  std::vector<ITensorHandleFactory::FactoryId> optimalFactories;
1706  for (auto it : factoryScores)
1707  {
1708  if (it.second == minScore)
1709  {
1710  optimalFactories.push_back(it.first);
1711  }
1712  }
1713 
1714  // For all compatible Factories matching the best score, find the preferred one for the current layer.
1715  for (auto&& srcPref : srcPrefs)
1716  {
1717  for (auto&& comp : optimalFactories)
1718  {
1719  if (comp == srcPref)
1720  {
1721  return comp;
1722  }
1723  }
1724  }
1725 
1727 }
1728 
1730  ITensorHandleFactory::FactoryId srcFactoryId,
1731  const Layer& layer,
1732  const Layer& connectedLayer,
1733  TensorHandleFactoryRegistry& registry,
1734  bool importEnabled)
1735 {
1736  auto toBackend = backends.find(connectedLayer.GetBackendId());
1737  if (toBackend == backends.end())
1738  {
1739  throw armnn::Exception("Backend id not found for the connected layer");
1740  }
1741 
1742  auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
1743 
1744  // Legacy API check for backward compatibility
1745  if (srcFactoryId == ITensorHandleFactory::LegacyFactoryId || dstPrefs.empty())
1746  {
1747  if (layer.GetBackendId() != connectedLayer.GetBackendId())
1748  {
1750  }
1751  else
1752  {
1754  }
1755  }
1756 
1757  // TensorHandleFactory API present, so perform more sophisticated strategies.
1758  // Dst Output layers don't require copy because they use import or map/unmap
1759  if (connectedLayer.GetType() == LayerType::Output)
1760  {
1762  }
1763 
1764  // Search for direct match in prefs
1765  for (auto&& pref : dstPrefs)
1766  {
1767  if (pref == srcFactoryId)
1768  {
1770  }
1771  }
1772 
1773  // Search for export/import options
1774  ITensorHandleFactory* srcFactory = registry.GetFactory(srcFactoryId);
1775  if (srcFactory->GetExportFlags() != 0 && importEnabled)
1776  {
1777  for (auto&& pref : dstPrefs)
1778  {
1779  ITensorHandleFactory* dstFactory = registry.GetFactory(pref);
1780 
1781  // Handles cases when a destPref is not listed in TensorHandleFactoryRegistry
1782  if (!dstFactory) {
1783  continue;
1784  }
1785  if ((dstFactory->GetImportFlags() & srcFactory->GetExportFlags()) != 0)
1786  {
1787  auto srcCapability = srcFactory->GetCapabilities(&layer, &layer, CapabilityClass::PaddingRequired);
1788  auto dstCapability = dstFactory->GetCapabilities(&connectedLayer,
1789  &connectedLayer,
1791  auto srcFallback = srcFactory->GetCapabilities(&layer, &layer, CapabilityClass::FallbackImportDisabled);
1792  auto dstFallback = dstFactory->GetCapabilities(&connectedLayer,
1793  &connectedLayer,
1795  // Do not require memory copy if the source and destination do not require padding.
1796  if (srcCapability.empty() && dstCapability.empty() && srcFallback.empty() && dstFallback.empty())
1797  {
1799  }
1800  }
1801  }
1802  }
1803 
1804  // Search for copy options via map/unmap
1805  if (srcFactory->SupportsMapUnmap())
1806  {
1807  for (auto&& pref : dstPrefs)
1808  {
1809  ITensorHandleFactory* dstFactory = registry.GetFactory(pref);
1810  if (dstFactory && dstFactory->SupportsMapUnmap())
1811  {
1813  }
1814  }
1815  }
1816 
1817  return EdgeStrategy::Undefined;
1818 }
1819 
1820 // Select the TensorHandleFactories and the corresponding memory strategy
1822  BackendsMap& backends,
1823  TensorHandleFactoryRegistry& registry,
1824  bool importEnabled,
1825  bool exportEnabled,
1826  Optional<std::vector<std::string>&> errMessages)
1827 {
1828  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_SelectTensorHandleStrategy");
1829  OptimizationResult result;
1830 
1831  optGraph.ForEachLayer([&backends, &registry, &result, &errMessages, importEnabled, exportEnabled](Layer* layer)
1832  {
1833  // Lets make sure the backend is in our list of supported backends. Something went wrong during backend
1834  // assignment if this check fails
1835  if (backends.find(layer->GetBackendId()) == backends.end())
1836  {
1837  throw armnn::Exception("Backend id not found for the layer");
1838  }
1839 
1840  // Check each output separately
1841  for (unsigned int slotIdx = 0; slotIdx < layer->GetNumOutputSlots(); slotIdx++)
1842  {
1843  OutputSlot& outputSlot = layer->GetOutputSlot(slotIdx);
1844 
1846 
1847  // Calculate the factory to use which results in the fewest copies being made.
1848  switch(layer->GetType())
1849  {
1850  case LayerType::Input:
1851  slotOption = CalculateSlotOptionForInput(backends, outputSlot, registry, importEnabled);
1852  break;
1853  case LayerType::Output:
1854  slotOption = CalculateSlotOptionForOutput(backends, outputSlot, registry);
1855  break;
1856  default:
1857  slotOption = CalculateSlotOption(backends, outputSlot, registry, exportEnabled);
1858  break;
1859  }
1860  outputSlot.SetTensorHandleFactory(slotOption);
1861 
1862  // Now determine the "best" edge strategy for each connection given the slotOption.
1863  unsigned int connectionIdx = 0;
1864  for (auto&& connection : outputSlot.GetConnections())
1865  {
1866  const Layer& connectedLayer = connection->GetOwningLayer();
1867 
1868  EdgeStrategy strategy = CalculateEdgeStrategy(backends, slotOption, *layer, connectedLayer,
1869  registry, importEnabled);
1870 
1871  if (strategy == EdgeStrategy::Undefined)
1872  {
1873  result.m_Error = true;
1874  if (errMessages)
1875  {
1876  errMessages.value().emplace_back("Could not find valid strategy required for compatibility"
1877  " between backends.");
1878  }
1879  return;
1880  }
1881 
1882  outputSlot.SetEdgeStrategy(connectionIdx, strategy);
1883 
1884  connectionIdx++;
1885  }
1886  }
1887  });
1888 
1889  return result;
1890 }
1891 
1892 // Forwarding function to remain backward compatible with legacy OptimizerOptions
1894  const std::vector<BackendId>& backendPreferences,
1895  const IDeviceSpec& deviceSpec,
1896  const OptimizerOptions& options,
1897  Optional<std::vector<std::string>&> messages)
1898 {
1899  return Optimize(inGraph,
1900  backendPreferences,
1901  deviceSpec,
1902  OptimizerOptionsOpaque(options),
1903  messages);
1904 }
1905 
1907  const std::vector<BackendId>& backendPreferences,
1908  const IDeviceSpec& deviceSpec,
1909  const OptimizerOptionsOpaque& options,
1910  Optional<std::vector<std::string>&> messages)
1911 {
1912  ARMNN_LOG(debug) << options.ToString();
1913 
1914  // Enable profiling
1915  auto profiler = inGraph.GetProfiler();
1916  ProfilerManager::GetInstance().RegisterProfiler(profiler.get());
1917  profiler->EnableProfiling(options.GetProfilingEnabled());
1918 
1919  // Some backends don't play well together. Check here before continuing.
1920  {
1921  std::set<BackendId> backendSet(backendPreferences.begin(), backendPreferences.end());
1922  // GpuFsa cannot co-exist with GpuAcc.
1923  if (backendSet.find("GpuFsa") != backendSet.end() &&
1924  backendSet.find("GpuAcc") != backendSet.end())
1925  {
1926  throw InvalidArgumentException("The backends \"GpuAcc\" and \"GpuFsa\" cannot be specified "
1927  "for the same optimized network.");
1928  }
1929  }
1930 
1931  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer");
1932  if (backendPreferences.empty())
1933  {
1934  throw InvalidArgumentException("Invoked Optimize with no backends specified");
1935  }
1936 
1937  if (options.GetReduceFp32ToBf16())
1938  {
1939  throw InvalidArgumentException("BFloat16 optimization is currently ignored. In order to use Bf16 optimization "
1940  "Please use the FastMathEnabled backend option for CpuAcc or GpuAcc.");
1941  }
1942 
1943  if (options.GetReduceFp32ToFp16() && options.GetReduceFp32ToBf16())
1944  {
1945  throw InvalidArgumentException("BFloat16 and Float16 optimization cannot be enabled at the same time.");
1946  }
1947 
1948  // Ensure TensorInfo is set on all output slots of ConstantLayers in the graph
1950 
1951  std::unique_ptr<Graph> graph = std::make_unique<Graph>(inGraph);
1952 
1953  // We need to pass on the information about whether import and export is enabled to the LoadNetwork phase.
1954  // The mechanism to do that is to add model options to the optimized network.
1955  armnn::BackendOptions importExport("Global",
1956  {{"ImportEnabled", options.GetImportEnabled()},
1957  {"ExportEnabled", options.GetExportEnabled()}});
1958  ModelOptions optimizedOptions(options.GetModelOptions());
1959  optimizedOptions.push_back(importExport);
1960 
1961  auto optNet = IOptimizedNetworkPtr(new IOptimizedNetwork(std::move(graph), optimizedOptions),
1962  &IOptimizedNetwork::Destroy);
1963 
1964  IOptimizedNetwork* optNetObjPtr = optNet.get();
1965 
1966  // Get the optimized graph
1967  Graph& optGraph = optNetObjPtr->pOptimizedNetworkImpl->GetGraph();
1968 
1969  if(options.GetShapeInferenceMethod() == ShapeInferenceMethod::InferAndValidate)
1970  {
1971  // Infer the tensor infos for all output slots. Throws an exception on failure
1972  optGraph.InferTensorInfos();
1973  }
1974 
1975  using namespace optimizations;
1976  // Substitute Max + Min with Bounded Relu before AddBroadcastReshapeLayer optimisation,
1977  // as Bounded ReLu needs the constants to be 1D size 1
1978  Optimizer::Pass(optGraph, MakeOptimizations(MaxMinIntoBoundedRelu()));
1979 
1980  // Perform BroadcastToOptimizationLayer before AddBroadcastReshapeLayer optimisation
1981  Optimizer::Pass(optGraph, MakeOptimizations(BroadcastToOptimizationLayer()));
1982 
1983  Optimizer::Pass(optGraph, MakeOptimizations(AddBroadcastReshapeLayer()));
1984 
1985  if(options.GetShapeInferenceMethod() == ShapeInferenceMethod::ValidateOnly)
1986  {
1987  // Validate the tensor infos for all output slots. Throws an exception on failure
1988  optGraph.InferTensorInfos();
1989  }
1990 
1991  // Group Constant Layer optimizations together where possible.
1992  // This is important as:
1993  // FusePermuteIntoConstantLayer must happen before FoldPadIntoDepthwiseConvolution2d and
1994  // FuseBatchNormIntoDepthwiseConvolution2D.
1995  // ConvertConstDequantisationLayersToConstLayers must happen before FoldPadIntoConvolution2d
1996  Optimizer::Pass(optGraph, MakeOptimizations(FusePermuteIntoConstLayer(),
1998  // Perform optimisation passes
1999  Optimizer::Pass(optGraph, MakeOptimizations(SquashEqualPermuteSiblings(),
2004  MovePermuteUp(),
2005  MoveTransposeUp(),
2006  PermuteAsReshape(),
2019 
2020  // Initialize backend settings
2021  BackendSettings backendSettings(backendPreferences, deviceSpec);
2022  auto availablePreferredBackends = backendSettings.GetAvailablePreferredBackends();
2023  if (availablePreferredBackends.empty())
2024  {
2025  std::stringstream failureMsg;
2026  failureMsg << "None of the preferred backends " << backendPreferences
2027  << " are supported. Current platform provides " << backendSettings.m_SupportedBackends;
2028  ReportError(failureMsg.str(), messages);
2029  throw InvalidArgumentException(failureMsg.str());
2030  }
2031 
2032  // Create a map to temporarily hold initialized backend objects
2033  TensorHandleFactoryRegistry tensorHandleFactoryRegistry;
2034  BackendsMap backends = CreateSupportedBackends(tensorHandleFactoryRegistry, backendSettings);
2035 
2036  if (options.GetReduceFp32ToFp16())
2037  {
2038  bool hasFp16 = CheckFp16Support(backends, availablePreferredBackends);
2039  if (hasFp16)
2040  {
2041  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_ReduceFp32ToFp16");
2042  Optimizer::Pass(optGraph, MakeOptimizations(Fp32NetworkToFp16Converter()));
2043  Optimizer::Pass(optGraph, MakeOptimizations(ConvertConstantsFloatToHalf()));
2044  }
2045  }
2046 
2047  // Assign an available backend to each layer
2048  Graph::Iterator firstLayer = optGraph.begin();
2049  Graph::Iterator lastLayer = optGraph.end();
2050  OptimizationResult assignBackendsResult = AssignBackends(optNetObjPtr->pOptimizedNetworkImpl.get(),
2051  backendSettings,
2052  firstLayer,
2053  lastLayer,
2054  messages);
2055  if (assignBackendsResult.m_Error)
2056  {
2057  // Failed to assign a backend to each layer
2058  throw InvalidArgumentException("Failed to assign a backend to each layer");
2059  }
2060 
2061  Optimizer::Pass(optGraph, MakeOptimizations(OptimizeInverseConversionsFp16(),
2063 
2064  // Apply the backend-specific optimizations
2065  OptimizationResult backendOptimizationResult = ApplyBackendOptimizations(optNetObjPtr->pOptimizedNetworkImpl.get(),
2066  backendSettings,
2067  backends,
2068  options.GetModelOptions(),
2069  messages);
2070  if (backendOptimizationResult.m_Error)
2071  {
2072  // Failed to apply the backend-specific optimizations
2073  throw InvalidArgumentException("Failed to apply the backend-specific optimizations");
2074  }
2075 
2076  // Convert constants
2077  {
2078  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_ConvertConstants");
2079  Optimizer::Pass(optGraph, MakeOptimizations(ConvertConstantsFloatToHalf()));
2080  Optimizer::Pass(optGraph, MakeOptimizations(ConvertConstantsHalfToFloat()));
2081  }
2082 
2083  // This must occur after all topological changes to the graph and any redirection of variables
2084  // If the debug flag is set, then insert a DebugLayer after each layer
2085  // Doing this after applying the backend optimizations as they might have changed some layers
2086  if (options.GetDebugEnabled() && !options.GetDebugToFileEnabled())
2087  {
2088  Optimizer::Pass(optGraph, MakeOptimizations(InsertDebugLayer()));
2089  }
2090  else if (options.GetDebugToFileEnabled())
2091  {
2092  // Setup the output file path
2093  try
2094  {
2095 #if !defined(ARMNN_DISABLE_FILESYSTEM)
2096  auto result = armnnUtils::Filesystem::CreateDirectory("/ArmNNIntermediateLayerOutputs");
2097  ARMNN_LOG(info) << "Intermediate tensors will be written to: " << result;
2098 #endif
2099  Optimizer::Pass(optGraph, MakeOptimizations(InsertDebugToFileLayer()));
2100  }
2101  catch (const armnn::RuntimeException& e)
2102  {
2103  // If we cannot create the output directory then we'll issue a warning and continue.
2104  ARMNN_LOG(warning) << "Unable to print intermediate layer outputs : " << e.what();
2105  }
2106  }
2107 
2108  // Calculate the compatibility strategies for tensor handles
2109  OptimizationResult strategyResult = SelectTensorHandleStrategy(optGraph,
2110  backends,
2111  tensorHandleFactoryRegistry,
2112  options.GetImportEnabled(),
2113  options.GetExportEnabled(),
2114  messages);
2115 
2116  if (strategyResult.m_Error)
2117  {
2118  // Failed to apply the backend-specific optimizations
2119  return IOptimizedNetworkPtr(nullptr, &IOptimizedNetwork::Destroy);
2120  }
2121 
2122  // Based on the tensor handle strategy determined above, insert copy layers where required.
2123  {
2124  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_AddCompatibilityLayers");
2125  optGraph.AddCompatibilityLayers(backends, tensorHandleFactoryRegistry);
2126  }
2127 
2128  return optNet;
2129 }
2130 
2131 // Forwarding function to remain backward compatible with legacy OptimizerOptions
2133  const std::vector<BackendId>& backendPreferences,
2134  const IDeviceSpec& deviceSpec,
2135  const OptimizerOptions& options,
2136  Optional<std::vector<std::string>&> messages)
2137 {
2138  return Optimize(inNetwork,
2139  backendPreferences,
2140  deviceSpec,
2141  OptimizerOptionsOpaque(options),
2142  messages);
2143 }
2144 
2146  const std::vector<BackendId>& backendPreferences,
2147  const IDeviceSpec& deviceSpec,
2148  const OptimizerOptionsOpaque& options,
2149  Optional<std::vector<std::string>&> messages)
2150 {
2151  return Optimize(inNetwork.pNetworkImpl->GetGraph(),
2152  backendPreferences,
2153  deviceSpec,
2154  options,
2155  messages);
2156 }
2157 
2158 bool NetworkImpl::GetShapeInferenceMethod()
2159 {
2160  bool shapeInferenceMethod = false;
2161 
2162  ParseOptions(m_NetworkOptions, "ShapeInferenceMethod", [&](std::string name, const BackendOptions::Var& value)
2163  {
2164  if (name == "InferAndValidate")
2165  {
2166  shapeInferenceMethod |= value.AsBool();
2167  }
2168  });
2169  return shapeInferenceMethod;
2170 }
2171 
2172 bool NetworkImpl::GetAllowExpandedDims()
2173 {
2174  bool allowExpandedDims = false;
2175 
2176  ParseOptions(m_NetworkOptions, "AllowExpandedDims", [&](std::string name, const BackendOptions::Var& value)
2177  {
2178  if (name == "AllowExpandedDims")
2179  {
2180  allowExpandedDims |= value.AsBool();
2181  }
2182  });
2183  return allowExpandedDims;
2184 }
2185 
2186 NetworkImpl::NetworkImpl(const NetworkOptions& networkOptions)
2187 : m_NetworkOptions(networkOptions),
2188  m_Graph(std::make_unique<Graph>(GetShapeInferenceMethod(), GetAllowExpandedDims()))
2189 {}
2190 
2192 {
2193 }
2194 
2196 {
2197  m_Graph->Print();
2198  return Status::Success;
2199 }
2200 
2202 {
2203  return m_Graph->AddLayer<InputLayer>(id, name);
2204 }
2205 
2207  const char* name)
2208 {
2209  return m_Graph->AddLayer<BatchToSpaceNdLayer>(batchToSpaceNdDescriptor, name);
2210 }
2211 
2213 {
2214  return m_Graph->AddLayer<CastLayer>(name);
2215 }
2217  const char* name)
2218 {
2219  return m_Graph->AddLayer<ChannelShuffleLayer>(channelShuffleDescriptor, name);
2220 }
2221 
2223  const char* name)
2224 {
2225  return m_Graph->AddLayer<ComparisonLayer>(comparisonDescriptor, name);
2226 }
2227 
2229  const char* name)
2230 {
2231  return m_Graph->AddLayer<ElementwiseBinaryLayer>(elementwiseBinaryDesc, name);
2232 }
2233 
2235  const char* name)
2236 {
2237  return m_Graph->AddLayer<ElementwiseUnaryLayer>(elementwiseUnaryDescriptor, name);
2238 }
2239 
2241  const char* name)
2242 {
2243  return m_Graph->AddLayer<FillLayer>(fillDescriptor, name);
2244 }
2245 
2247  const char* name)
2248 {
2249  return m_Graph->AddLayer<FullyConnectedLayer>(fullyConnectedDescriptor, name);
2250 }
2251 
2253  const char* name)
2254 {
2255  return m_Graph->AddLayer<FusedLayer>(fusedDescriptor, name);
2256 }
2257 
2259  const char* name)
2260 {
2261  return m_Graph->AddLayer<ConcatLayer>(concatDescriptor, name);
2262 }
2263 
2265  const char* name)
2266 {
2267  return m_Graph->AddLayer<Convolution2dLayer>(convolution2dDescriptor, name);
2268 }
2269 
2271 {
2272  return m_Graph->AddLayer<ConvertFp16ToFp32Layer>(name);
2273 }
2274 
2276 {
2277  return m_Graph->AddLayer<ConvertFp32ToFp16Layer>(name);
2278 }
2279 
2281  const char* name)
2282 {
2283  return m_Graph->AddLayer<Convolution3dLayer>(convolution3dDescriptor, name);
2284 }
2285 
2287  const char* name)
2288 {
2289  return m_Graph->AddLayer<DepthToSpaceLayer>(depthToSpaceDescriptor, name);
2290 }
2291 
2293  const DepthwiseConvolution2dDescriptor& convolution2dDescriptor,
2294  const char* name)
2295 {
2296  return m_Graph->AddLayer<DepthwiseConvolution2dLayer>(convolution2dDescriptor, name);
2297 }
2298 
2300  const ConstTensor& anchors, const char* name)
2301 {
2302  const auto layer = m_Graph->AddLayer<DetectionPostProcessLayer>(descriptor, name);
2303 
2304  layer->m_Anchors = std::make_shared<ScopedTensorHandle>(anchors);
2305 
2306  return layer;
2307 }
2308 
2310  const char* name)
2311 {
2312  return m_Graph->AddLayer<PermuteLayer>(permuteDescriptor, name);
2313 }
2314 
2316  const char* name)
2317 {
2318  return m_Graph->AddLayer<Pooling2dLayer>(pooling2dDescriptor, name);
2319 }
2320 
2322  const char* name)
2323 {
2324  return m_Graph->AddLayer<Pooling3dLayer>(pooling3dDescriptor, name);
2325 }
2326 
2328  const char* name)
2329 {
2330  return m_Graph->AddLayer<ActivationLayer>(activationDescriptor, name);
2331 }
2332 
2334  const char* name)
2335 {
2336  return m_Graph->AddLayer<ArgMinMaxLayer>(argMinMaxDescriptor, name);
2337 }
2338 
2340 normalizationDescriptor,
2341  const char* name)
2342 {
2343  return m_Graph->AddLayer<NormalizationLayer>(normalizationDescriptor, name);
2344 }
2345 
2346 IConnectableLayer* NetworkImpl::AddSliceLayer(const SliceDescriptor& sliceDescriptor, const char* name)
2347 {
2348  return m_Graph->AddLayer<SliceLayer>(sliceDescriptor, name);
2349 }
2350 
2352  const char* name)
2353 {
2354  return m_Graph->AddLayer<SoftmaxLayer>(softmaxDescriptor, name);
2355 }
2356 
2358  const char* name)
2359 {
2360  return m_Graph->AddLayer<SplitterLayer>(splitterDescriptor, name);
2361 }
2362 
2364 {
2365  return m_Graph->AddLayer<MaximumLayer>(name);
2366 }
2367 
2369 {
2370  return m_Graph->AddLayer<MinimumLayer>(name);
2371 }
2372 
2374 {
2375  return m_Graph->AddLayer<AdditionLayer>(name);
2376 }
2377 
2379 {
2380  return m_Graph->AddLayer<MultiplicationLayer>(name);
2381 }
2382 
2384 {
2385  return m_Graph->AddLayer<OutputLayer>(id, name);
2386 }
2387 
2389  const ConstTensor& mean,
2390  const ConstTensor& variance,
2391  const ConstTensor& beta,
2392  const ConstTensor& gamma,
2393  const char* name)
2394 {
2395  const auto layer = m_Graph->AddLayer<BatchNormalizationLayer>(desc, name);
2396 
2397  layer->m_Mean = std::make_shared<ScopedTensorHandle>(mean);
2398  layer->m_Variance = std::make_shared<ScopedTensorHandle>(variance);
2399  layer->m_Beta = std::make_shared<ScopedTensorHandle>(beta);
2400  layer->m_Gamma = std::make_shared<ScopedTensorHandle>(gamma);
2401 
2402  return layer;
2403 }
2404 
2406 {
2407  return m_Graph->AddLayer<RankLayer>(name);
2408 }
2409 
2411  const char* name)
2412 {
2413  return m_Graph->AddLayer<ReduceLayer>(reduceDescriptor, name);
2414 }
2415 
2416 IConnectableLayer* NetworkImpl::AddResizeLayer(const ResizeDescriptor& resizeDescriptor, const char* name)
2417 {
2418  return m_Graph->AddLayer<ResizeLayer>(resizeDescriptor, name);
2419 }
2420 
2422 {
2423  return m_Graph->AddLayer<ShapeLayer>(name);
2424 }
2425 
2427  const char* name)
2428 {
2429  return m_Graph->AddLayer<InstanceNormalizationLayer>(desc, name);
2430 }
2431 
2433  const char* name)
2434 {
2435  return m_Graph->AddLayer<L2NormalizationLayer>(desc, name);
2436 }
2437 
2439  const char* name)
2440 {
2441  return m_Graph->AddLayer<LogSoftmaxLayer>(desc, name);
2442 }
2443 
2445 {
2446  auto layer = m_Graph->AddLayer<ConstantLayer>(name);
2447 
2448  layer->m_LayerOutput = std::make_shared<ScopedTensorHandle>(input);
2449 
2450  return layer;
2451 }
2452 
2454  const char* name)
2455 {
2456  return m_Graph->AddLayer<ReshapeLayer>(reshapeDescriptor, name);
2457 }
2458 
2460  const char* name)
2461 {
2462  return m_Graph->AddLayer<SpaceToBatchNdLayer>(spaceToBatchNdDescriptor, name);
2463 }
2464 
2466  const char* name)
2467 {
2468  return m_Graph->AddLayer<SpaceToDepthLayer>(spaceToDepthDescriptor, name);
2469 }
2470 
2472 {
2473  return m_Graph->AddLayer<FloorLayer>(name);
2474 }
2475 
2477  const LstmInputParams& params,
2478  const char* name)
2479 {
2480  const auto layer = m_Graph->AddLayer<LstmLayer>(descriptor, name);
2481 
2482  //Lstm Basic Parameters
2484  std::make_shared<ScopedTensorHandle>(*(params.m_InputToForgetWeights));
2485  layer->m_BasicParameters.m_InputToCellWeights =
2486  std::make_shared<ScopedTensorHandle>(*(params.m_InputToCellWeights));
2487  layer->m_BasicParameters.m_InputToOutputWeights =
2488  std::make_shared<ScopedTensorHandle>(*(params.m_InputToOutputWeights));
2489  layer->m_BasicParameters.m_RecurrentToForgetWeights =
2490  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToForgetWeights));
2491  layer->m_BasicParameters.m_RecurrentToCellWeights =
2492  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToCellWeights));
2493  layer->m_BasicParameters.m_RecurrentToOutputWeights =
2494  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToOutputWeights));
2495  layer->m_BasicParameters.m_ForgetGateBias =
2496  std::make_shared<ScopedTensorHandle>(*(params.m_ForgetGateBias));
2497  layer->m_BasicParameters.m_CellBias =
2498  std::make_shared<ScopedTensorHandle>(*(params.m_CellBias));
2499  layer->m_BasicParameters.m_OutputGateBias =
2500  std::make_shared<ScopedTensorHandle>(*(params.m_OutputGateBias));
2501 
2502  //Lstm Cifg parameters
2503  if(!descriptor.m_CifgEnabled)
2504  {
2505  if(params.m_InputToInputWeights == nullptr)
2506  {
2507  throw InvalidArgumentException("AddLstmLayer: Input To Input Weights cannot be NULL "
2508  "when CIFG is disabled.");
2509  }
2510  if(params.m_RecurrentToInputWeights == nullptr)
2511  {
2513  "AddLstmLayer: Recurrent To Input Weights cannot be NULL "
2514  "when CIFG is disabled.");
2515  }
2516  if(params.m_InputGateBias == nullptr)
2517  {
2518  throw InvalidArgumentException("AddLstmLayer: Input Gate Bias cannot be NULL "
2519  "when CIFG is disabled.");
2520  }
2521  layer->m_CifgParameters.m_InputToInputWeights =
2522  std::make_shared<ScopedTensorHandle>(*(params.m_InputToInputWeights));
2523  layer->m_CifgParameters.m_RecurrentToInputWeights =
2524  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToInputWeights));
2525  layer->m_CifgParameters.m_InputGateBias =
2526  std::make_shared<ScopedTensorHandle>(*(params.m_InputGateBias));
2527  }
2528 
2529  //Lstm projection parameters
2530  if(descriptor.m_ProjectionEnabled)
2531  {
2532  if(params.m_ProjectionWeights == nullptr)
2533  {
2534  throw InvalidArgumentException("AddLstmLayer: Projection Weights cannot be NULL "
2535  "when projection is enabled.");
2536  }
2537  layer->m_ProjectionParameters.m_ProjectionWeights =
2538  std::make_shared<ScopedTensorHandle>(*(params.m_ProjectionWeights));
2539  if(params.m_ProjectionBias != nullptr)
2540  {
2541  layer->m_ProjectionParameters.m_ProjectionBias =
2542  std::make_shared<ScopedTensorHandle>(*(params.m_ProjectionBias));
2543  }
2544  }
2545 
2546  //Lstm Peephole params
2547  if(descriptor.m_PeepholeEnabled)
2548  {
2549  if(!descriptor.m_CifgEnabled)
2550  {
2551  if(params.m_CellToInputWeights == nullptr)
2552  {
2553  throw InvalidArgumentException("AddLstmLayer: Cell To Input Weights cannot be NULL "
2554  "when Peephole is enabled and CIFG disabled.");
2555  }
2556 
2557  layer->m_PeepholeParameters.m_CellToInputWeights =
2558  std::make_shared<ScopedTensorHandle>(*(params.m_CellToInputWeights));
2559  }
2560 
2561  if(params.m_CellToForgetWeights == nullptr)
2562  {
2563  throw InvalidArgumentException("AddLstmLayer: Cell To Forget Weights cannot be NULL "
2564  "when Peephole is enabled.");
2565  }
2566  if(params.m_CellToOutputWeights == nullptr)
2567  {
2568  throw InvalidArgumentException("AddLstmLayer: Cell To Output Weights cannot be NULL "
2569  "when Peephole is enabled.");
2570  }
2571 
2572  layer->m_PeepholeParameters.m_CellToForgetWeights =
2573  std::make_shared<ScopedTensorHandle>(*(params.m_CellToForgetWeights));
2574  layer->m_PeepholeParameters.m_CellToOutputWeights =
2575  std::make_shared<ScopedTensorHandle>(*(params.m_CellToOutputWeights));
2576  }
2577 
2578  //Lstm Layer Normalization params
2579  if(descriptor.m_LayerNormEnabled)
2580  {
2581  if(!descriptor.m_CifgEnabled)
2582  {
2583  if(params.m_InputLayerNormWeights == nullptr)
2584  {
2585  throw InvalidArgumentException("AddLstmLayer: Input layer normalization weights cannot be NULL "
2586  "when layer normalization is enabled and CIFG disabled.");
2587  }
2588  layer->m_LayerNormParameters.m_InputLayerNormWeights =
2589  std::make_shared<ScopedTensorHandle>(*(params.m_InputLayerNormWeights));
2590  }
2591 
2592  if(params.m_ForgetLayerNormWeights == nullptr)
2593  {
2594  throw InvalidArgumentException("AddLstmLayer: Forget layer normalization weights cannot be NULL "
2595  "when layer normalization is enabled.");
2596  }
2597  if(params.m_CellLayerNormWeights == nullptr)
2598  {
2599  throw InvalidArgumentException("AddLstmLayer: Cell layer normalization weights cannot be NULL "
2600  "when layer normalization is enabled.");
2601  }
2602  if(params.m_OutputLayerNormWeights == nullptr)
2603  {
2604  throw InvalidArgumentException("AddLstmLayer: Output layer normalization weights cannot be NULL "
2605  "when layer normalization is enabled.");
2606  }
2607  layer->m_LayerNormParameters.m_ForgetLayerNormWeights =
2608  std::make_shared<ScopedTensorHandle>(*(params.m_ForgetLayerNormWeights));
2609  layer->m_LayerNormParameters.m_CellLayerNormWeights =
2610  std::make_shared<ScopedTensorHandle>(*(params.m_CellLayerNormWeights));
2611  layer->m_LayerNormParameters.m_OutputLayerNormWeights =
2612  std::make_shared<ScopedTensorHandle>(*(params.m_OutputLayerNormWeights));
2613  }
2614  return layer;
2615 }
2616 
2618 {
2619  return m_Graph->AddLayer<DivisionLayer>(name);
2620 }
2621 
2623 {
2624  return m_Graph->AddLayer<SubtractionLayer>(name);
2625 }
2626 
2627 IConnectableLayer* NetworkImpl::AddMeanLayer(const MeanDescriptor& meanDescriptor, const char* name)
2628 {
2629  return m_Graph->AddLayer<MeanLayer>(meanDescriptor,name);
2630 }
2631 
2632 IConnectableLayer* NetworkImpl::AddPadLayer(const PadDescriptor& padDescriptor, const char* name)
2633 {
2634  return m_Graph->AddLayer<PadLayer>(padDescriptor,name);
2635 }
2636 
2638 {
2639  return m_Graph->AddLayer<QuantizeLayer>(name);
2640 }
2641 
2643 {
2644  return m_Graph->AddLayer<DequantizeLayer>(name);
2645 }
2646 
2648  const char* name)
2649 {
2650  return m_Graph->AddLayer<StridedSliceLayer>(stridedSliceDescriptor, name);
2651 }
2652 
2654  const char* name)
2655 {
2656  return m_Graph->AddLayer<GatherLayer>(gatherDescriptor, name);
2657 }
2658 
2660 {
2661  return m_Graph->AddLayer<GatherNdLayer>(name);
2662 }
2663 
2665 {
2666  return m_Graph->AddLayer<MergeLayer>(name);
2667 }
2668 
2670 {
2671  return m_Graph->AddLayer<SwitchLayer>(name);
2672 }
2673 
2675 {
2676  return m_Graph->AddLayer<PreluLayer>(name);
2677 }
2678 
2680  const ConstTensor& weights,
2681  const Optional<ConstTensor>& biases,
2682  const char* name)
2683 {
2684  if (descriptor.m_BiasEnabled && !biases.has_value())
2685  {
2686  throw InvalidArgumentException("AddTransposeConvolution2dLayer: Biases cannot be empty");
2687  }
2688 
2689  const auto layer = m_Graph->AddLayer<TransposeConvolution2dLayer>(descriptor, name);
2690 
2691  layer->m_Weight = std::make_shared<ScopedTensorHandle>(weights);
2692 
2693  if (descriptor.m_BiasEnabled)
2694  {
2695  layer->m_Bias = std::make_shared<ScopedTensorHandle>(biases.value());
2696  }
2697 
2698  return layer;
2699 }
2700 
2702  const char* name)
2703 {
2704  return m_Graph->AddLayer<TransposeLayer>(transposeDescriptor, name);
2705 }
2706 
2708  const char* name)
2709 {
2710  return m_Graph->AddLayer<StackLayer>(stackDescriptor, name);
2711 }
2712 
2713 
2715  const char* name)
2716 {
2717  return m_Graph->AddLayer<StandInLayer>(desc, name);
2718 }
2719 
2721  const char* name)
2722 {
2723  const auto layer = m_Graph->AddLayer<QuantizedLstmLayer>(name);
2724 
2725  // InputToX weights
2727  std::make_shared<ScopedTensorHandle>(params.GetInputToInputWeights());
2728  layer->m_QuantizedLstmParameters.m_InputToForgetWeights =
2729  std::make_shared<ScopedTensorHandle>(params.GetInputToForgetWeights());
2730  layer->m_QuantizedLstmParameters.m_InputToCellWeights =
2731  std::make_shared<ScopedTensorHandle>(params.GetInputToCellWeights());
2732  layer->m_QuantizedLstmParameters.m_InputToOutputWeights =
2733  std::make_shared<ScopedTensorHandle>(params.GetInputToOutputWeights());
2734 
2735  // RecurrentToX weights
2736  layer->m_QuantizedLstmParameters.m_RecurrentToInputWeights =
2737  std::make_shared<ScopedTensorHandle>(params.GetRecurrentToInputWeights());
2738  layer->m_QuantizedLstmParameters.m_RecurrentToForgetWeights =
2739  std::make_shared<ScopedTensorHandle>(params.GetRecurrentToForgetWeights());
2740  layer->m_QuantizedLstmParameters.m_RecurrentToCellWeights =
2741  std::make_shared<ScopedTensorHandle>(params.GetRecurrentToCellWeights());
2742  layer->m_QuantizedLstmParameters.m_RecurrentToOutputWeights =
2743  std::make_shared<ScopedTensorHandle>(params.GetRecurrentToOutputWeights());
2744 
2745  // Bias
2746  layer->m_QuantizedLstmParameters.m_InputGateBias =
2747  std::make_shared<ScopedTensorHandle>(params.GetInputGateBias());
2748  layer->m_QuantizedLstmParameters.m_ForgetGateBias =
2749  std::make_shared<ScopedTensorHandle>(params.GetForgetGateBias());
2750  layer->m_QuantizedLstmParameters.m_CellBias =
2751  std::make_shared<ScopedTensorHandle>(params.GetCellBias());
2752  layer->m_QuantizedLstmParameters.m_OutputGateBias =
2753  std::make_shared<ScopedTensorHandle>(params.GetOutputGateBias());
2754 
2755  return layer;
2756 }
2757 
2759  const LstmInputParams& params,
2760  const char* name)
2761 {
2762  const auto layer = m_Graph->AddLayer<QLstmLayer>(descriptor, name);
2763 
2764  // QLstm Basic Parameters
2766  std::make_shared<ScopedTensorHandle>(*(params.m_InputToForgetWeights));
2767  layer->m_BasicParameters.m_InputToCellWeights =
2768  std::make_shared<ScopedTensorHandle>(*(params.m_InputToCellWeights));
2769  layer->m_BasicParameters.m_InputToOutputWeights =
2770  std::make_shared<ScopedTensorHandle>(*(params.m_InputToOutputWeights));
2771  layer->m_BasicParameters.m_RecurrentToForgetWeights =
2772  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToForgetWeights));
2773  layer->m_BasicParameters.m_RecurrentToCellWeights =
2774  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToCellWeights));
2775  layer->m_BasicParameters.m_RecurrentToOutputWeights =
2776  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToOutputWeights));
2777  layer->m_BasicParameters.m_ForgetGateBias =
2778  std::make_shared<ScopedTensorHandle>(*(params.m_ForgetGateBias));
2779  layer->m_BasicParameters.m_CellBias =
2780  std::make_shared<ScopedTensorHandle>(*(params.m_CellBias));
2781  layer->m_BasicParameters.m_OutputGateBias =
2782  std::make_shared<ScopedTensorHandle>(*(params.m_OutputGateBias));
2783 
2784  // QLstm Cifg parameters
2785  if(!descriptor.m_CifgEnabled)
2786  {
2787  if(params.m_InputToInputWeights == nullptr)
2788  {
2789  throw InvalidArgumentException("AddQLstmLayer: Input To Input Weights cannot be NULL");
2790  }
2791 
2792  if(params.m_RecurrentToInputWeights == nullptr)
2793  {
2795  "AddQLstmLayer: Recurrent To Input Weights cannot be NULL");
2796  }
2797 
2798  if(params.m_InputGateBias == nullptr)
2799  {
2800  throw InvalidArgumentException("AddQLstmLayer: Input Gate Bias cannot be NULL");
2801  }
2802 
2803  layer->m_CifgParameters.m_InputToInputWeights =
2804  std::make_shared<ScopedTensorHandle>(*(params.m_InputToInputWeights));
2805  layer->m_CifgParameters.m_RecurrentToInputWeights =
2806  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToInputWeights));
2807  layer->m_CifgParameters.m_InputGateBias =
2808  std::make_shared<ScopedTensorHandle>(*(params.m_InputGateBias));
2809  }
2810 
2811  // QLstm Projection parameters
2812  if(descriptor.m_ProjectionEnabled)
2813  {
2814  if(params.m_ProjectionWeights == nullptr)
2815  {
2816  throw InvalidArgumentException("AddQLstmLayer: Projection Weights cannot be NULL");
2817  }
2818 
2819  layer->m_ProjectionParameters.m_ProjectionWeights =
2820  std::make_shared<ScopedTensorHandle>(*(params.m_ProjectionWeights));
2821 
2822  // Projection bias is optional even if projection is enabled
2823  if(params.m_ProjectionBias != nullptr)
2824  {
2825  layer->m_ProjectionParameters.m_ProjectionBias =
2826  std::make_shared<ScopedTensorHandle>(*(params.m_ProjectionBias));
2827  }
2828 
2829  }
2830 
2831  // QLstm Peephole params
2832  if(descriptor.m_PeepholeEnabled)
2833  {
2834  if(params.m_CellToForgetWeights == nullptr)
2835  {
2836  throw InvalidArgumentException("AddQLstmLayer: Cell To Forget Weights cannot be NULL");
2837  }
2838 
2839  if(params.m_CellToOutputWeights == nullptr)
2840  {
2841  throw InvalidArgumentException("AddQLstmLayer: Cell To Output Weights cannot be NULL");
2842  }
2843 
2844  if(!descriptor.m_CifgEnabled)
2845  {
2846  if(params.m_CellToInputWeights == nullptr)
2847  {
2848  throw InvalidArgumentException("AddQLstmLayer: Cell To Input Weights cannot be NULL");
2849  }
2850 
2851  layer->m_PeepholeParameters.m_CellToInputWeights =
2852  std::make_shared<ScopedTensorHandle>(*(params.m_CellToInputWeights));
2853  }
2854 
2855  layer->m_PeepholeParameters.m_CellToForgetWeights =
2856  std::make_shared<ScopedTensorHandle>(*(params.m_CellToForgetWeights));
2857  layer->m_PeepholeParameters.m_CellToOutputWeights =
2858  std::make_shared<ScopedTensorHandle>(*(params.m_CellToOutputWeights));
2859  }
2860 
2861  // QLstm Layer Normalization params
2862  if(descriptor.m_LayerNormEnabled)
2863  {
2864  if(params.m_ForgetLayerNormWeights == nullptr)
2865  {
2866  throw InvalidArgumentException("AddQLstmLayer: Forget layer normalization weights cannot be NULL");
2867  }
2868 
2869  if(params.m_CellLayerNormWeights == nullptr)
2870  {
2871  throw InvalidArgumentException("AddQLstmLayer: Cell layer normalization weights cannot be NULL");
2872  }
2873 
2874  if(params.m_OutputLayerNormWeights == nullptr)
2875  {
2876  throw InvalidArgumentException("AddQLstmLayer: Output layer normalization weights cannot be NULL");
2877  }
2878 
2879  if(!descriptor.m_CifgEnabled)
2880  {
2881  if(params.m_InputLayerNormWeights == nullptr)
2882  {
2883  throw InvalidArgumentException("AddQLstmLayer: Input layer normalization weights cannot be NULL");
2884  }
2885 
2886  layer->m_LayerNormParameters.m_InputLayerNormWeights =
2887  std::make_shared<ScopedTensorHandle>(*(params.m_InputLayerNormWeights));
2888  }
2889 
2890  layer->m_LayerNormParameters.m_ForgetLayerNormWeights =
2891  std::make_shared<ScopedTensorHandle>(*(params.m_ForgetLayerNormWeights));
2892  layer->m_LayerNormParameters.m_CellLayerNormWeights =
2893  std::make_shared<ScopedTensorHandle>(*(params.m_CellLayerNormWeights));
2894  layer->m_LayerNormParameters.m_OutputLayerNormWeights =
2895  std::make_shared<ScopedTensorHandle>(*(params.m_OutputLayerNormWeights));
2896  }
2897  return layer;
2898 }
2899 
2901  const char* name)
2902 {
2903  return m_Graph->AddLayer<LogicalBinaryLayer>(logicalBinaryDescriptor, name);
2904 }
2905 
2907  const UnidirectionalSequenceLstmDescriptor& descriptor,
2908  const LstmInputParams& params,
2909  const char* name)
2910 {
2911  const auto layer = m_Graph->AddLayer<UnidirectionalSequenceLstmLayer>(descriptor, name);
2912 
2913  //Lstm Basic Parameters
2915  std::make_shared<ScopedTensorHandle>(*(params.m_InputToForgetWeights));
2916  layer->m_BasicParameters.m_InputToCellWeights =
2917  std::make_shared<ScopedTensorHandle>(*(params.m_InputToCellWeights));
2918  layer->m_BasicParameters.m_InputToOutputWeights =
2919  std::make_shared<ScopedTensorHandle>(*(params.m_InputToOutputWeights));
2920  layer->m_BasicParameters.m_RecurrentToForgetWeights =
2921  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToForgetWeights));
2922  layer->m_BasicParameters.m_RecurrentToCellWeights =
2923  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToCellWeights));
2924  layer->m_BasicParameters.m_RecurrentToOutputWeights =
2925  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToOutputWeights));
2926  layer->m_BasicParameters.m_ForgetGateBias =
2927  std::make_shared<ScopedTensorHandle>(*(params.m_ForgetGateBias));
2928  layer->m_BasicParameters.m_CellBias =
2929  std::make_shared<ScopedTensorHandle>(*(params.m_CellBias));
2930  layer->m_BasicParameters.m_OutputGateBias =
2931  std::make_shared<ScopedTensorHandle>(*(params.m_OutputGateBias));
2932 
2933  //Lstm Cifg parameters
2934  if(!descriptor.m_CifgEnabled)
2935  {
2936  if(params.m_InputToInputWeights == nullptr)
2937  {
2938  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Input To Input Weights cannot be NULL "
2939  "when CIFG is disabled.");
2940  }
2941  if(params.m_RecurrentToInputWeights == nullptr)
2942  {
2944  "AddUnidirectionalSequenceLstmLayer: Recurrent To Input Weights cannot be NULL "
2945  "when CIFG is disabled.");
2946  }
2947  if(params.m_InputGateBias == nullptr)
2948  {
2949  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Input Gate Bias cannot be NULL "
2950  "when CIFG is disabled.");
2951  }
2952  layer->m_CifgParameters.m_InputToInputWeights =
2953  std::make_shared<ScopedTensorHandle>(*(params.m_InputToInputWeights));
2954  layer->m_CifgParameters.m_RecurrentToInputWeights =
2955  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToInputWeights));
2956  layer->m_CifgParameters.m_InputGateBias =
2957  std::make_shared<ScopedTensorHandle>(*(params.m_InputGateBias));
2958  }
2959 
2960  //Lstm projection parameters
2961  if(descriptor.m_ProjectionEnabled)
2962  {
2963  if(params.m_ProjectionWeights == nullptr)
2964  {
2965  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Projection Weights cannot be NULL "
2966  "when projection is enabled.");
2967  }
2968  layer->m_ProjectionParameters.m_ProjectionWeights =
2969  std::make_shared<ScopedTensorHandle>(*(params.m_ProjectionWeights));
2970  if(params.m_ProjectionBias != nullptr)
2971  {
2972  layer->m_ProjectionParameters.m_ProjectionBias =
2973  std::make_shared<ScopedTensorHandle>(*(params.m_ProjectionBias));
2974  }
2975  }
2976 
2977  //Lstm Peephole params
2978  if(descriptor.m_PeepholeEnabled)
2979  {
2980  if(!descriptor.m_CifgEnabled)
2981  {
2982  if(params.m_CellToInputWeights == nullptr)
2983  {
2984  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Cell To Input Weights "
2985  "cannot be NULL when Peephole is enabled and CIFG disabled.");
2986  }
2987 
2988  layer->m_PeepholeParameters.m_CellToInputWeights =
2989  std::make_shared<ScopedTensorHandle>(*(params.m_CellToInputWeights));
2990  }
2991 
2992  if(params.m_CellToForgetWeights == nullptr)
2993  {
2994  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Cell To Forget Weights cannot be NULL "
2995  "when Peephole is enabled.");
2996  }
2997  if(params.m_CellToOutputWeights == nullptr)
2998  {
2999  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Cell To Output Weights cannot be NULL "
3000  "when Peephole is enabled.");
3001  }
3002 
3003  layer->m_PeepholeParameters.m_CellToForgetWeights =
3004  std::make_shared<ScopedTensorHandle>(*(params.m_CellToForgetWeights));
3005  layer->m_PeepholeParameters.m_CellToOutputWeights =
3006  std::make_shared<ScopedTensorHandle>(*(params.m_CellToOutputWeights));
3007  }
3008 
3009  //Lstm Layer Normalization params
3010  if(descriptor.m_LayerNormEnabled)
3011  {
3012  if(!descriptor.m_CifgEnabled)
3013  {
3014  if(params.m_InputLayerNormWeights == nullptr)
3015  {
3016  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Input layer normalization weights "
3017  "cannot be NULL when layer normalization is enabled and CIFG disabled.");
3018  }
3019  layer->m_LayerNormParameters.m_InputLayerNormWeights =
3020  std::make_shared<ScopedTensorHandle>(*(params.m_InputLayerNormWeights));
3021  }
3022 
3023  if(params.m_ForgetLayerNormWeights == nullptr)
3024  {
3025  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Forget layer normalization weights "
3026  "cannot be NULL when layer normalization is enabled.");
3027  }
3028  if(params.m_CellLayerNormWeights == nullptr)
3029  {
3030  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Cell layer normalization weights "
3031  "cannot be NULL when layer normalization is enabled.");
3032  }
3033  if(params.m_OutputLayerNormWeights == nullptr)
3034  {
3035  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Output layer normalization weights "
3036  "cannot be NULL when layer normalization is enabled.");
3037  }
3038  layer->m_LayerNormParameters.m_ForgetLayerNormWeights =
3039  std::make_shared<ScopedTensorHandle>(*(params.m_ForgetLayerNormWeights));
3040  layer->m_LayerNormParameters.m_CellLayerNormWeights =
3041  std::make_shared<ScopedTensorHandle>(*(params.m_CellLayerNormWeights));
3042  layer->m_LayerNormParameters.m_OutputLayerNormWeights =
3043  std::make_shared<ScopedTensorHandle>(*(params.m_OutputLayerNormWeights));
3044  }
3045  return layer;
3046 }
3047 
3049 {
3050  return m_Graph->AddLayer<BatchMatMulLayer>(desc, name);
3051 }
3052 
3054 {
3055  return m_Graph->AddLayer<ReverseV2Layer>(name);
3056 }
3057 
3059 {
3060  return m_Graph->AddLayer<TileLayer>(desc, name);
3061 }
3062 
3064  CompiledBlobPtr compiledBlobPtr,
3065  const Optional<BackendId>& backend,
3066  const char* name)
3067 {
3068  // Method use is for backend users.
3069  PreCompiledLayer* layer;
3070  if (name)
3071  {
3072  layer = m_Graph->AddLayer<PreCompiledLayer>(preCompiledDescriptor, name);
3073  }
3074  else
3075  {
3076  layer = m_Graph->AddLayer<PreCompiledLayer>(preCompiledDescriptor, "pre-compiled");
3077  }
3078 
3079  // Assign the pre-compiled object to layer
3080  // Pass only one compiled network, Arm NN does not handle multiple
3081  // pre-compiled objects in a single pre-compiled layer currently
3082  layer->SetPreCompiledObject(std::move(compiledBlobPtr));
3083 
3084  if (backend.has_value())
3085  {
3086  layer->SetBackendId(backend.value());
3087  }
3088  else if (layer->GetBackendHint().has_value())
3089  {
3090  layer->SetBackendId(layer->GetBackendHint().value());
3091  }
3092 
3093  return layer;
3094 }
3095 
3097 {
3098  return m_Graph->AddLayer<BroadcastToLayer>(desc, name);
3099 }
3100 
3102 {
3103  return m_Graph->AddLayer<ScatterNdLayer>(desc, name);
3104 }
3105 
3107 {
3108  for (auto layer : GetGraph())
3109  {
3110  layer->ExecuteStrategy(strategy);
3111  };
3112 }
3113 
3115  : m_Graph(new Graph(*other.m_Graph.get()))
3116  , m_Guid(arm::pipe::IProfilingService::GetNextGuid())
3117  , m_ModelOptions(modelOptions)
3118 {
3119 }
3120 
3121 OptimizedNetworkImpl::OptimizedNetworkImpl(std::unique_ptr<Graph> graph)
3122  : m_Graph(std::move(graph)), m_Guid(arm::pipe::IProfilingService::GetNextGuid())
3123 {
3124 }
3125 
3126 OptimizedNetworkImpl::OptimizedNetworkImpl(std::unique_ptr<Graph> graph, const ModelOptions& modelOptions)
3127  : m_Graph(std::move(graph)), m_Guid(arm::pipe::IProfilingService::GetNextGuid()), m_ModelOptions(modelOptions)
3128 {
3129 }
3130 
3132 {
3133 }
3134 
3136 {
3137  pOptimizedNetworkImpl->ExecuteStrategy(strategy);
3138 }
3139 
3141 {
3142  for (auto layer : GetGraph())
3143  {
3144  layer->ExecuteStrategy(strategy);
3145  };
3146 }
3147 
3148 } // namespace armnn
armnn::INetwork::AddReshapeLayer
IConnectableLayer * AddReshapeLayer(const ReshapeDescriptor &reshapeDescriptor, const char *name=nullptr)
Adds a reshape layer to the network.
Definition: Network.cpp:474
armnn::InputLayer
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: InputLayer.hpp:13
armnn::NetworkImpl::AddDepthToSpaceLayer
IConnectableLayer * AddDepthToSpaceLayer(const DepthToSpaceDescriptor &depthToSpaceDescriptor, const char *name=nullptr)
Definition: Network.cpp:2286
armnn::BatchNormalizationDescriptor
A BatchNormalizationDescriptor for the BatchNormalizationLayer.
Definition: Descriptors.hpp:828
armnn::NetworkImpl::AddTransposeConvolution2dLayer
IConnectableLayer * AddTransposeConvolution2dLayer(const TransposeConvolution2dDescriptor &descriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr)
Definition: Network.cpp:2679
armnn::INetworkPtr
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:339
armnn::CapabilityClass::FallbackImportDisabled
@ FallbackImportDisabled
armnn::optimizations::InsertDebugToFileLayer
OptimizeForType< Layer, AddDebugToFileImpl > InsertDebugToFileLayer
Definition: AddDebug.hpp:54
armnn::INetwork::AddReverseV2Layer
IConnectableLayer * AddReverseV2Layer(const char *name=nullptr)
Add a ReverseV2 layer to the network.
Definition: Network.cpp:649
armnn::OptimizationResult::m_Error
bool m_Error
Definition: Network.hpp:266
armnn::IOptimizedNetworkPtr
std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr
Definition: INetwork.hpp:340
armnn::IOptimizedNetwork::ExecuteStrategy
void ExecuteStrategy(IStrategy &strategy) const
Definition: Network.cpp:3135
armnn::ApplyBackendOptimizations
OptimizationResult ApplyBackendOptimizations(OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, BackendsMap &backends, const ModelOptions &modelOptions, Optional< std::vector< std::string > & > errMessages)
Definition: Network.cpp:1320
armnn::QuantizedLstmParameters::m_InputToInputWeights
std::shared_ptr< ConstTensorHandle > m_InputToInputWeights
A unique pointer to represent 2D weights tensor with dimensions [outputSize, inputSize] (QAsymm8).
Definition: QuantizedLstmLayer.hpp:17
armnn::LstmInputParams::m_RecurrentToForgetWeights
const ConstTensor * m_RecurrentToForgetWeights
Definition: LstmParams.hpp:45
armnn::OptimizerOptionsOpaque::SetExportEnabled
void SetExportEnabled(bool ExportState)
Definition: Network.cpp:116
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:468
armnn::INetwork::ExecuteStrategy
void ExecuteStrategy(IStrategy &strategy) const
Definition: Network.cpp:672
armnn::NetworkImpl::AddLogicalBinaryLayer
IConnectableLayer * AddLogicalBinaryLayer(const LogicalBinaryDescriptor &logicalBinaryDescriptor, const char *name=nullptr)
Definition: Network.cpp:2900
armnn::Compute::Undefined
@ Undefined
armnn::QuantizedLstmInputParams::GetOutputGateBias
const ConstTensor & GetOutputGateBias() const
Definition: QuantizedLstmParams.hpp:113
armnn::OutputSlot::SetTensorHandleFactory
void SetTensorHandleFactory(const ITensorHandleFactory::FactoryId &id)
Definition: Layer.cpp:213
armnn::optimizations::InsertDebugLayer
OptimizeForType< Layer, AddDebugImpl > InsertDebugLayer
Definition: AddDebug.hpp:53
armnn::ViewsDescriptor
A ViewsDescriptor for the SplitterLayer.
Definition: Descriptors.hpp:244
armnn::LstmInputParams::m_OutputLayerNormWeights
const ConstTensor * m_OutputLayerNormWeights
Definition: LstmParams.hpp:60
armnn::IOptimizedNetwork::GetProfiler
const std::shared_ptr< IProfiler > & GetProfiler() const
Definition: Network.cpp:721
armnn::LayerType::Permute
@ Permute
armnn::ActivationDescriptor
An ActivationDescriptor for the ActivationLayer.
Definition: Descriptors.hpp:36
armnn::NetworkImpl::AddFullyConnectedLayer
IConnectableLayer * AddFullyConnectedLayer(const FullyConnectedDescriptor &fullyConnectedDescriptor, const char *name=nullptr)
Definition: Network.cpp:2246
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:616
armnn::optimizations::FuseBatchNormIntoConvolution2DFloat32
OptimizeForExclusiveConnection< Convolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< Convolution2dLayer, armnn::DataType::Float32 > > FuseBatchNormIntoConvolution2DFloat32
Definition: FuseBatchNorm.hpp:222
armnn::BackendSettings
Definition: BackendSettings.hpp:18
armnn::RankLayer
Definition: RankLayer.hpp:13
armnn::FullyConnectedDescriptor
A FullyConnectedDescriptor for the FullyConnectedLayer.
Definition: Descriptors.hpp:507
armnn::NetworkImpl::AddReverseV2Layer
IConnectableLayer * AddReverseV2Layer(const char *name=nullptr)
Definition: Network.cpp:3053
arm
Definition: BackendRegistry.hpp:15
armnn::INetwork::AddCastLayer
IConnectableLayer * AddCastLayer(const char *name=nullptr)
Adds a cast layer to the network.
Definition: Network.cpp:253
armnn::INetwork::AddReduceLayer
IConnectableLayer * AddReduceLayer(const ReduceDescriptor &reduceDescriptor, const char *name=nullptr)
Adds a reduce layer to the network.
Definition: Network.cpp:444
armnn::INetwork::AddMaximumLayer
IConnectableLayer * AddMaximumLayer(const char *name=nullptr)
Add a Maximum layer to the network.
Definition: Network.cpp:522
armnn::ComparisonLayer
This layer represents a comparison operation.
Definition: ComparisonLayer.hpp:14
armnn::OptimizerOptions::m_ImportEnabled
bool m_ImportEnabled
Enable Import.
Definition: INetwork.hpp:253
armnn::QLstmDescriptor
A QLstmDescriptor for the QLstmLayer.
Definition: Descriptors.hpp:1380
armnn::ITensorHandleFactory::SupportsMapUnmap
virtual bool SupportsMapUnmap() const
Definition: ITensorHandleFactory.hpp:88
armnn::Optional
Definition: Optional.hpp:270
armnn::GetLayerTypeAsCString
const char * GetLayerTypeAsCString(LayerType type)
Definition: InternalTypes.cpp:13
armnn::DepthToSpaceLayer
This layer represents a DepthToSpace operation.
Definition: DepthToSpaceLayer.hpp:14
armnn::QuantizedLstmInputParams::GetForgetGateBias
const ConstTensor & GetForgetGateBias() const
Definition: QuantizedLstmParams.hpp:103
armnn::SplitterLayer
This layer represents a split operation.
Definition: SplitterLayer.hpp:13
armnn::ConcatLayer
This layer represents a merge operation.
Definition: ConcatLayer.hpp:13
armnn::Compute::GpuAcc
@ GpuAcc
GPU Execution: OpenCL: ArmCompute.
armnn::NetworkImpl::AddTransposeLayer
IConnectableLayer * AddTransposeLayer(const TransposeDescriptor &transposeDescriptor, const char *name=nullptr)
Definition: Network.cpp:2701
armnn::INetwork::AddAdditionLayer
IConnectableLayer * AddAdditionLayer(const char *name=nullptr)
Adds an addition layer to the network.
Definition: Network.cpp:409
armnn::InsertConvertFp16ToFp32LayersBefore
std::vector< ConvertFp16ToFp32Layer * > InsertConvertFp16ToFp32LayersBefore(Graph &graph, Layer &layer, bool expectCorrectInputType)
Definition: NetworkUtils.cpp:40
SubgraphViewSelector.hpp
armnn::QLstmLayer
This layer represents a QLstm operation.
Definition: QLstmLayer.hpp:79
armnn::Graph::ForEachLayer
void ForEachLayer(Func func) const
Definition: Graph.hpp:40
armnn::OutputSlot::GetTensorInfo
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:100
armnn::NetworkImpl::AddConvolution2dLayer
IConnectableLayer * AddConvolution2dLayer(const Convolution2dDescriptor &convolution2dDescriptor, const char *name=nullptr)
Definition: Network.cpp:2264
armnn::BackendOptions::BackendOption::GetName
std::string GetName() const
Definition: BackendOptions.hpp:251
armnn::NetworkImpl::AddBroadcastToLayer
IConnectableLayer * AddBroadcastToLayer(const BroadcastToDescriptor &descriptor, const char *name=nullptr)
Definition: Network.cpp:3096
armnn::OptimizerOptionsOpaque::operator=
OptimizerOptionsOpaque & operator=(OptimizerOptionsOpaque other)
Definition: Network.cpp:96
armnn::OptimizedNetworkImpl::PrintGraph
virtual Status PrintGraph()
Definition: Network.cpp:741
armnn::INetwork::AddSliceLayer
IConnectableLayer * AddSliceLayer(const SliceDescriptor &sliceDescriptor, const char *name=nullptr)
Adds a slice layer to the network.
Definition: Network.cpp:388
DeviceSpec.hpp
armnn::LstmInputParams::m_ProjectionBias
const ConstTensor * m_ProjectionBias
Definition: LstmParams.hpp:56
armnn::NetworkImpl::AddTileLayer
IConnectableLayer * AddTileLayer(const TileDescriptor &tileDescriptor, const char *name=nullptr)
Definition: Network.cpp:3058
armnn::NormalizationLayer
This layer represents a normalization operation.
Definition: NormalizationLayer.hpp:13
armnn::BackendOptions::BackendOption::GetValue
Var GetValue() const
Definition: BackendOptions.hpp:252
armnn::Pooling3dDescriptor
A Pooling3dDescriptor for the Pooling3dLayer.
Definition: Descriptors.hpp:431
armnn::optimizations::OptimizeInversePermutes
OptimizeForConnection< PermuteLayer, PermuteLayer, OptimizeInversePermutesImpl< PermuteLayer > > OptimizeInversePermutes
Definition: OptimizeInversePermutes.hpp:43
armnn::BackendSettings::m_IgnoredBackends
BackendIdSet m_IgnoredBackends
Definition: BackendSettings.hpp:23
armnn::LstmInputParams::m_RecurrentToCellWeights
const ConstTensor * m_RecurrentToCellWeights
Definition: LstmParams.hpp:46
armnn::LogSoftmaxLayer
This layer represents a log softmax operation.
Definition: LogSoftmaxLayer.hpp:14
armnn::optimizations::TransposeAndBatchToSpaceAsDepthToSpace
OptimizeForConnection< TransposeLayer, BatchToSpaceNdLayer, PermuteAndBatchToSpaceAsDepthToSpaceImpl< TransposeLayer > > TransposeAndBatchToSpaceAsDepthToSpace
Definition: PermuteAndBatchToSpaceAsDepthToSpace.hpp:104
armnn::NetworkImpl::AddDivisionLayer
IConnectableLayer * AddDivisionLayer(const char *name=nullptr)
Definition: Network.cpp:2617
armnn::LstmInputParams::m_CellBias
const ConstTensor * m_CellBias
Definition: LstmParams.hpp:53
armnn::BroadcastToLayer
Definition: BroadcastToLayer.hpp:13
armnn::BatchNormalizationLayer::m_Mean
std::shared_ptr< ConstTensorHandle > m_Mean
A unique pointer to store Mean values.
Definition: BatchNormalizationLayer.hpp:19
armnn::ResizeDescriptor
A ResizeDescriptor for the ResizeLayer.
Definition: Descriptors.hpp:985
armnn::SubtractionLayer
This layer represents a subtraction operation.
Definition: SubtractionLayer.hpp:14
armnn::EdgeStrategy::DirectCompatibility
@ DirectCompatibility
No strategy has been defined. Used internally to verify integrity of optimizations.
armnn::CalculateSlotOption
ITensorHandleFactory::FactoryId CalculateSlotOption(BackendsMap &backends, OutputSlot &outputSlot, TensorHandleFactoryRegistry &registry, bool exportEnabled)
Definition: Network.cpp:1576
armnn::Layer::GetBackendHint
Optional< BackendId > GetBackendHint() const
Definition: Layer.hpp:355
armnn::ArgMinMaxDescriptor
An ArgMinMaxDescriptor for ArgMinMaxLayer.
Definition: Descriptors.hpp:67
armnn::optimizations::FoldPadIntoPooling2d
OptimizeForExclusiveConnection< PadLayer, Pooling2dLayer, pad_fold::FoldPadIntoPooling2dImpl > FoldPadIntoPooling2d
Definition: FoldPadIntoLayer2d.hpp:283
armnn::Compute::CpuRef
@ CpuRef
CPU Execution: Reference C++ kernels.
armnn::Pooling3dLayer
This layer represents a pooling 3d operation.
Definition: Pooling3dLayer.hpp:13
armnn::InstanceNormalizationDescriptor
An InstanceNormalizationDescriptor for InstanceNormalizationLayer.
Definition: Descriptors.hpp:847
armnn::optimizations::Fp32NetworkToFp16Converter
OptimizeForType< Layer, ConvertFp32NetworkToFp16Impl > Fp32NetworkToFp16Converter
Definition: ConvertFp32NetworkToFp16.hpp:87
armnn::Graph::EraseLayer
void EraseLayer(Iterator pos)
Deletes the layer at the specified position.
Definition: Graph.hpp:517
armnn::TensorHandleFactoryRegistry
Definition: TensorHandleFactoryRegistry.hpp:23
armnn::OutputSlot
Definition: Layer.hpp:100
armnn::DepthwiseConvolution2dLayer
This layer represents a depthwise convolution 2d operation.
Definition: DepthwiseConvolution2dLayer.hpp:15
armnn::NetworkImpl::AddAdditionLayer
IConnectableLayer * AddAdditionLayer(const char *name=nullptr)
Definition: Network.cpp:2373
armnn::OutputSlot::SetTensorInfo
void SetTensorInfo(const TensorInfo &tensorInfo) override
Definition: Layer.cpp:95
armnn::GatherDescriptor
A GatherDescriptor for the GatherLayer.
Definition: Descriptors.hpp:965
armnn::INetwork::AddMeanLayer
IConnectableLayer * AddMeanLayer(const MeanDescriptor &meanDescriptor, const char *name=nullptr)
Add a Mean layer to the network.
Definition: Network.cpp:529
armnn::Graph::SubstituteSubgraph
void SubstituteSubgraph(SubgraphView &subgraph, IConnectableLayer *substituteLayer)
Substitutes the given sub-graph with either a new layer or a new sub-graph.
Definition: Graph.cpp:475
TypesUtils.hpp
armnn::LayerType::ConvertFp16ToFp32
@ ConvertFp16ToFp32
armnn::TensorHandleFactoryRegistry::GetFactory
ITensorHandleFactory * GetFactory(ITensorHandleFactory::FactoryId id) const
Find a TensorHandleFactory by Id Returns nullptr if not found.
Definition: TensorHandleFactoryRegistry.cpp:39
armnn::FloorLayer
This layer represents a floor operation.
Definition: FloorLayer.hpp:13
armnn::OptimizedNetworkImpl::SerializeToDot
virtual Status SerializeToDot(std::ostream &stream) const
Definition: Network.cpp:747
armnn::INetwork::AddDequantizeLayer
IConnectableLayer * AddDequantizeLayer(const char *name=nullptr)
Adds a Dequantize layer to the network.
Definition: Network.cpp:300
armnn::TensorInfo
Definition: Tensor.hpp:152
armnn::IOptimizedNetwork::GetNumInputs
size_t GetNumInputs() const
Definition: Network.cpp:731
armnn::INetwork::AddTileLayer
IConnectableLayer * AddTileLayer(const TileDescriptor &descriptor, const char *name=nullptr)
Add a Tile layer to the network.
Definition: Network.cpp:654
armnn::NetworkImpl::AddSplitterLayer
IConnectableLayer * AddSplitterLayer(const ViewsDescriptor &splitterDescriptor, const char *name=nullptr)
Definition: Network.cpp:2357
armnn::optimizations::FoldPadIntoConvolution2d
OptimizeForExclusiveConnection< PadLayer, Convolution2dLayer, pad_fold::FoldPadIntoConvolution2dImpl > FoldPadIntoConvolution2d
Definition: FoldPadIntoLayer2d.hpp:277
armnn::OptimizedNetworkImpl::ExecuteStrategy
void ExecuteStrategy(IStrategy &strategy) const
Definition: Network.cpp:3140
armnn::L2NormalizationDescriptor
A L2NormalizationDescriptor for the L2NormalizationLayer.
Definition: Descriptors.hpp:809
All.hpp
armnn::FusedLayer
Definition: FusedLayer.hpp:19
armnn::MeanLayer
This layer represents a mean operation.
Definition: MeanLayer.hpp:14
Graph.hpp
armnn::OptimizerOptionsOpaque::SetReduceFp32ToFp16
void SetReduceFp32ToFp16(bool ReduceFp32ToFp16State)
Definition: Network.cpp:136
armnn::INetwork::AddSpaceToBatchNdLayer
IConnectableLayer * AddSpaceToBatchNdLayer(const SpaceToBatchNdDescriptor &spaceToBatchNdDescriptor, const char *name=nullptr)
Adds a space to batch layer to the network.
Definition: Network.cpp:480
armnn::OptimizationViews::GetFailedSubgraphs
const Subgraphs & GetFailedSubgraphs() const
Definition: OptimizationViews.hpp:59
armnn::GetDataTypeName
constexpr const char * GetDataTypeName(DataType dataType)
Definition: TypesUtils.hpp:233
armnn::INetwork::AddL2NormalizationLayer
IConnectableLayer * AddL2NormalizationLayer(const L2NormalizationDescriptor &desc, const char *name=nullptr)
Adds an L2 normalization layer to the network.
Definition: Network.cpp:456
armnn::TensorInfo::SetDataType
void SetDataType(DataType type)
Definition: Tensor.hpp:201
armnn::IOptimizedNetwork::SerializeToDot
Status SerializeToDot(std::ostream &stream) const
Definition: Network.cpp:716
armnn::NormalizationDescriptor
A NormalizationDescriptor for the NormalizationLayer.
Definition: Descriptors.hpp:769
armnn::optimizations::ConvertConstDequantisationLayersToConstLayers
OptimizeForConnection< ConstantLayer, DequantizeLayer, ConvertConstDequantisationLayersToConstLayersImpl > ConvertConstDequantisationLayersToConstLayers
Definition: ConvertConstDequantisationLayersToConstLayers.hpp:173
armnn::IOptimizedNetwork::GetGuid
arm::pipe::ProfilingGuid GetGuid() const
Definition: Network.cpp:726
armnn::OptimizerOptionsOpaque::GetExportEnabled
bool GetExportEnabled() const
Definition: Network.cpp:166
armnn::NetworkImpl::AddSubtractionLayer
IConnectableLayer * AddSubtractionLayer(const char *name=nullptr)
Definition: Network.cpp:2622
armnn::INetwork::AddComparisonLayer
IConnectableLayer * AddComparisonLayer(const ComparisonDescriptor &comparisonDescriptor, const char *name=nullptr)
Add a Comparison layer to the network.
Definition: Network.cpp:258
armnn::OptimizerOptionsOpaque::~OptimizerOptionsOpaque
~OptimizerOptionsOpaque()
armnn::IOptimizedNetwork::PrintGraph
Status PrintGraph()
Definition: Network.cpp:711
armnn::NetworkImpl::AddStridedSliceLayer
IConnectableLayer * AddStridedSliceLayer(const StridedSliceDescriptor &stridedSliceDescriptor, const char *name=nullptr)
Definition: Network.cpp:2647
armnn::optimizations::MoveTransposeUp
OptimizeForConnection< Layer, TransposeLayer, MoveTransposeUpImpl > MoveTransposeUp
Definition: MoveTransposeUp.hpp:83
armnn::ChannelShuffleDescriptor
A ChannelShuffleDescriptor for the ChannelShuffle operator.
Definition: Descriptors.hpp:1562
armnn::NetworkImpl::AddLogSoftmaxLayer
IConnectableLayer * AddLogSoftmaxLayer(const LogSoftmaxDescriptor &logSoftmaxDescriptor, const char *name=nullptr)
Definition: Network.cpp:2438
armnn::NetworkImpl::~NetworkImpl
~NetworkImpl()
Definition: Network.cpp:2191
armnn::UnidirectionalSequenceLstmLayer::m_BasicParameters
LstmBasicParameters m_BasicParameters
Definition: UnidirectionalSequenceLstmLayer.hpp:20
armnn::Graph::VerifyConstantLayerSetTensorInfo
void VerifyConstantLayerSetTensorInfo() const
For each ConstantLayer in Graph, ensures TensorInfo is set on all output slots.
Definition: Graph.cpp:622
armnn::INetwork::AddFullyConnectedLayer
IConnectableLayer * AddFullyConnectedLayer(const FullyConnectedDescriptor &fullyConnectedDescriptor, const char *name=nullptr)
Adds a fully connected layer to the network.
Definition: Network.cpp:332
armnn::DataType::Float32
@ Float32
armnn::IOptimizedNetwork
Definition: INetwork.hpp:908
armnn::NetworkImpl::AddMeanLayer
IConnectableLayer * AddMeanLayer(const MeanDescriptor &meanDescriptor, const char *name=nullptr)
Definition: Network.cpp:2627
armnn::OptimizedNetworkImpl::GetGraph
Graph & GetGraph()
Definition: OptimizedNetworkImpl.hpp:27
armnn::OptimizationResult::IsError
bool IsError() const
Definition: Network.hpp:280
armnn::TransposeConvolution2dLayer
This layer represents a 2D transpose convolution operation.
Definition: TransposeConvolution2dLayer.hpp:15
armnn::NetworkImpl::AddResizeLayer
IConnectableLayer * AddResizeLayer(const ResizeDescriptor &resizeDescriptor, const char *name=nullptr)
Definition: Network.cpp:2416
armnn::PreluLayer
Definition: PreluLayer.hpp:14
armnn::INetwork::AddBatchMatMulLayer
IConnectableLayer * AddBatchMatMulLayer(const BatchMatMulDescriptor &descriptor, const char *name=nullptr)
Add a BatchMatMul layer to the network.
Definition: Network.cpp:643
armnn::ITensorHandleFactory::GetExportFlags
virtual MemorySourceFlags GetExportFlags() const
Definition: ITensorHandleFactory.hpp:90
armnn::GatherLayer
This layer represents a Gather operator.
Definition: GatherLayer.hpp:14
armnn::QuantizedLstmInputParams::GetInputToInputWeights
const ConstTensor & GetInputToInputWeights() const
Definition: QuantizedLstmParams.hpp:58
armnn::Layer::GetOutputSlot
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:339
armnn::BackendOptions::BackendOption
Definition: BackendOptions.hpp:215
armnn::OptimizerOptionsOpaque::GetModelOptions
armnn::ModelOptions GetModelOptions() const
Definition: Network.cpp:196
armnn::AssignBackends
OptimizationResult AssignBackends(OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, Graph::Iterator &firstLayer, Graph::Iterator &lastLayer, Optional< std::vector< std::string > & > errMessages)
Definition: Network.cpp:1179
armnn::optimizations::BroadcastToOptimizationLayer
OptimizeForType< BroadcastToLayer, DeleteBroadcastToImpl > BroadcastToOptimizationLayer
Definition: DeleteBroadcastTo.hpp:38
armnn::INetwork::AddLogSoftmaxLayer
IConnectableLayer * AddLogSoftmaxLayer(const LogSoftmaxDescriptor &logSoftmaxDescriptor, const char *name=nullptr)
Adds a log softmax layer to the network.
Definition: Network.cpp:462
ARMNN_NO_DEPRECATE_WARN_BEGIN
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
Definition: Deprecated.hpp:33
armnn::NetworkImpl::AddBatchMatMulLayer
IConnectableLayer * AddBatchMatMulLayer(const BatchMatMulDescriptor &desc, const char *name=nullptr)
Definition: Network.cpp:3048
armnn::Graph::Iterator
LayerList::const_iterator Iterator
Definition: Graph.hpp:53
armnn::LstmInputParams::m_CellToOutputWeights
const ConstTensor * m_CellToOutputWeights
Definition: LstmParams.hpp:50
armnn::NetworkImpl::AddLstmLayer
IConnectableLayer * AddLstmLayer(const LstmDescriptor &descriptor, const LstmInputParams &params, const char *name=nullptr)
Definition: Network.cpp:2476
armnn::NetworkImpl::AddReduceLayer
IConnectableLayer * AddReduceLayer(const ReduceDescriptor &reduceDescriptor, const char *name=nullptr)
Definition: Network.cpp:2410
armnn::LstmInputParams::m_InputToCellWeights
const ConstTensor * m_InputToCellWeights
Definition: LstmParams.hpp:42
armnn::NetworkImpl::AddConstantLayer
IConnectableLayer * AddConstantLayer(const ConstTensor &input, const char *name=nullptr)
Definition: Network.cpp:2444
armnn::DataType::QAsymmU8
@ QAsymmU8
armnn::OptimizerOptionsOpaque::GetImportEnabled
bool GetImportEnabled() const
Definition: Network.cpp:161
armnn::ArgMinMaxLayer
This layer represents a ArgMinMax operation.
Definition: ArgMinMaxLayer.hpp:14
armnn::optimizations::PermuteAsReshape
OptimizeForType< PermuteLayer, PermuteAsReshapeImpl > PermuteAsReshape
Definition: PermuteAsReshape.hpp:66
BackendRegistry.hpp
armnn::SubgraphView::IConnectableLayerIterator
IConnectableLayers::iterator IConnectableLayerIterator
Definition: SubgraphView.hpp:64
armnn::DataType::QSymmS8
@ QSymmS8
armnn::ReportWarning
void ReportWarning(const std::string &warningMessage, Optional< std::vector< std::string > & > warningMessages)
Definition: Network.cpp:774
armnn::StackDescriptor
A StackDescriptor for the StackLayer.
Definition: Descriptors.hpp:1251
armnn::Half
half_float::half Half
Definition: Half.hpp:22
armnn::OptimizerOptionsOpaque::GetReduceFp32ToBf16
bool GetReduceFp32ToBf16() const
Definition: Network.cpp:176
IgnoreUnused.hpp
armnn::INetwork::CreateRaw
static INetwork * CreateRaw(const NetworkOptions &networkOptions={})
Definition: Network.cpp:677
armnn::StackLayer
This layer represents a stack operation.
Definition: StackLayer.hpp:13
armnn::NetworkImpl::AddDepthwiseConvolution2dLayer
IConnectableLayer * AddDepthwiseConvolution2dLayer(const DepthwiseConvolution2dDescriptor &convolution2dDescriptor, const char *name=nullptr)
Definition: Network.cpp:2292
armnn::IBackendInternal
Definition: IBackendInternal.hpp:77
armnn::Layer::GetInputSlots
const std::vector< InputSlot > & GetInputSlots() const
Definition: Layer.hpp:258
armnn::OptimizerOptions::m_ReduceFp32ToFp16
bool m_ReduceFp32ToFp16
Reduces all Fp32 operators in the model to Fp16 for faster processing.
Definition: INetwork.hpp:237
armnn::OptimizedNetworkImpl::~OptimizedNetworkImpl
virtual ~OptimizedNetworkImpl()
Definition: Network.cpp:3131
armnn::OutputSlot::Connect
int Connect(InputSlot &destination)
Definition: Layer.cpp:123
armnn::optimizations::PermuteAndBatchToSpaceAsDepthToSpace
OptimizeForConnection< PermuteLayer, BatchToSpaceNdLayer, PermuteAndBatchToSpaceAsDepthToSpaceImpl< PermuteLayer > > PermuteAndBatchToSpaceAsDepthToSpace
Definition: PermuteAndBatchToSpaceAsDepthToSpace.hpp:102
armnn::IStrategy
Definition: IStrategy.hpp:16
armnn::OptimizedNetworkImpl::OptimizedNetworkImpl
OptimizedNetworkImpl(const OptimizedNetworkImpl &other, const ModelOptions &modelOptions)
Definition: Network.cpp:3114
armnn::BatchNormalizationLayer
This layer represents a batch normalization operation.
Definition: BatchNormalizationLayer.hpp:15
Optimizer.hpp
armnn::INetwork::AddPreluLayer
IConnectableLayer * AddPreluLayer(const char *name=nullptr)
Adds a PReLU layer to the network.
Definition: Network.cpp:574
armnn::OptimizerOptionsOpaque::GetReduceFp32ToFp16
bool GetReduceFp32ToFp16() const
Definition: Network.cpp:171
armnn::SelectTensorHandleStrategy
OptimizationResult SelectTensorHandleStrategy(Graph &optGraph, BackendsMap &backends, TensorHandleFactoryRegistry &registry, bool importEnabled, bool exportEnabled, Optional< std::vector< std::string > & > errMessages)
Definition: Network.cpp:1821
TensorHandleFactoryRegistry.hpp
armnn::BatchToSpaceNdLayer
This layer represents a BatchToSpaceNd operation.
Definition: BatchToSpaceNdLayer.hpp:13
armnn::INetwork::AddOutputLayer
IConnectableLayer * AddOutputLayer(LayerBindingId id, const char *name=nullptr)
Adds an output layer to the network.
Definition: Network.cpp:496
armnn::NetworkImpl::AddComparisonLayer
IConnectableLayer * AddComparisonLayer(const ComparisonDescriptor &comparisonDescriptor, const char *name=nullptr)
Definition: Network.cpp:2222
armnn::Layer::GetInputSlot
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:337
armnn::NetworkImpl::ExecuteStrategy
void ExecuteStrategy(IStrategy &strategy) const
Definition: Network.cpp:3106
armnn::DataType::QSymmS16
@ QSymmS16
WorkloadFactory.hpp
armnn::INetwork::AddStridedSliceLayer
IConnectableLayer * AddStridedSliceLayer(const StridedSliceDescriptor &stridedSliceDescriptor, const char *name=nullptr)
Adds a strided slice layer to the network.
Definition: Network.cpp:545
armnn::OptimizedNetworkImpl
Definition: OptimizedNetworkImpl.hpp:11
armnn::INetwork::AddFusedLayer
IConnectableLayer * AddFusedLayer(const FusedDescriptor &fusedDescriptor, const char *name=nullptr)
Adds a Fused layer to the network.
Definition: Network.cpp:338
armnn::optimizations::MovePermuteUp
OptimizeForConnection< Layer, PermuteLayer, MovePermuteUpImpl > MovePermuteUp
Definition: MovePermuteUp.hpp:83
armnn::LstmInputParams::m_ForgetGateBias
const ConstTensor * m_ForgetGateBias
Definition: LstmParams.hpp:52
armnn::optimizations::OptimizeInverseConversionsFp16
OptimizeForConnection< ConvertFp16ToFp32Layer, ConvertFp32ToFp16Layer, OptimizeInverseConversionsImpl > OptimizeInverseConversionsFp16
Definition: OptimizeInverseConversions.hpp:42
armnn::NetworkImpl::AddSwitchLayer
IConnectableLayer * AddSwitchLayer(const char *name=nullptr)
Definition: Network.cpp:2669
armnn::OptimizationResult
Definition: Network.hpp:263
armnn::NetworkImpl::AddSpaceToDepthLayer
IConnectableLayer * AddSpaceToDepthLayer(const SpaceToDepthDescriptor &spaceToDepthDescriptor, const char *name=nullptr)
Definition: Network.cpp:2465
armnn::ITensorHandleFactory::LegacyFactoryId
static const FactoryId LegacyFactoryId
Definition: ITensorHandleFactory.hpp:50
armnn::NetworkImpl::AddFloorLayer
IConnectableLayer * AddFloorLayer(const char *name=nullptr)
Definition: Network.cpp:2471
armnn::INetwork::AddSoftmaxLayer
IConnectableLayer * AddSoftmaxLayer(const SoftmaxDescriptor &softmaxDescriptor, const char *name=nullptr)
Adds a softmax layer to the network.
Definition: Network.cpp:392
armnn::MinimumLayer
This layer represents a minimum operation.
Definition: MinimumLayer.hpp:14
armnn::BackendSettings::m_SelectedBackends
BackendIdSet m_SelectedBackends
Definition: BackendSettings.hpp:22
armnn::INetwork::AddPermuteLayer
IConnectableLayer * AddPermuteLayer(const PermuteDescriptor &permuteDescriptor, const char *name=nullptr)
Adds a permute layer to the network.
Definition: Network.cpp:344
armnn::Convolution2dLayer
This layer represents a convolution 2d operation.
Definition: Convolution2dLayer.hpp:15
armnn::LstmInputParams::m_CellToInputWeights
const ConstTensor * m_CellToInputWeights
Definition: LstmParams.hpp:48
armnn::Exception::what
virtual const char * what() const noexcept override
Definition: Exceptions.cpp:32
armnn::LayerType::ConvertFp32ToFp16
@ ConvertFp32ToFp16
armnn::OptimizationResult::IsOk
bool IsOk() const
Definition: Network.hpp:276
armnn::NetworkImpl::AddPermuteLayer
IConnectableLayer * AddPermuteLayer(const PermuteDescriptor &permuteDescriptor, const char *name=nullptr)
Definition: Network.cpp:2309
armnn::NetworkImpl::AddRankLayer
IConnectableLayer * AddRankLayer(const char *name=nullptr)
Definition: Network.cpp:2405
armnn::Layer
Definition: Layer.hpp:230
ARMNN_LOG
#define ARMNN_LOG(severity)
Definition: Logging.hpp:212
armnn::INetwork::AddTransposeLayer
IConnectableLayer * AddTransposeLayer(const TransposeDescriptor &transposeDescriptor, const char *name=nullptr)
Adds a transpose layer to the network.
Definition: Network.cpp:587
armnn::EdgeStrategy::CopyToTarget
@ CopyToTarget
Source backends tensor data can be exported to destination backend tensor without copy.
armnn::OptimizerOptionsOpaque::GetShapeInferenceMethod
armnn::ShapeInferenceMethod GetShapeInferenceMethod() const
Definition: Network.cpp:201
armnn::NetworkImpl::AddArgMinMaxLayer
IConnectableLayer * AddArgMinMaxLayer(const ArgMinMaxDescriptor &desc, const char *name=nullptr)
Definition: Network.cpp:2333
armnn::ITensorHandleFactory::GetCapabilities
virtual std::vector< Capability > GetCapabilities(const IConnectableLayer *layer, const IConnectableLayer *connectedLayer, CapabilityClass capabilityClass)
Definition: ITensorHandleFactory.hpp:93
armnn::TileLayer
Definition: TileLayer.hpp:13
armnn::OptimizerOptionsOpaque::SetShapeInferenceMethod
void SetShapeInferenceMethod(armnn::ShapeInferenceMethod ShapeInferenceMethodType)
Definition: Network.cpp:141
armnn::ElementwiseBinaryDescriptor
A ElementwiseBinaryDescriptor for the ElementwiseBinaryLayer.
Definition: Descriptors.hpp:109
armnn::INetwork::AddStackLayer
IConnectableLayer * AddStackLayer(const StackDescriptor &descriptor, const char *name=nullptr)
Adds a stack layer to the network.
Definition: Network.cpp:598
armnn::TransposeLayer
This layer represents a transpose operation.
Definition: TransposeLayer.hpp:15
Assert.hpp
armnn::AdditionLayer
This layer represents an addition operation.
Definition: AdditionLayer.hpp:13
armnn::CreateSupportedBackends
BackendsMap CreateSupportedBackends(TensorHandleFactoryRegistry &handleFactoryRegistry, BackendSettings &backendSettings)
Definition: Network.cpp:1302
armnn::NetworkImpl::AddBatchToSpaceNdLayer
IConnectableLayer * AddBatchToSpaceNdLayer(const BatchToSpaceNdDescriptor &batchToSpaceNdDescriptor, const char *name=nullptr)
Definition: Network.cpp:2206
armnn::NetworkImpl::AddPreluLayer
IConnectableLayer * AddPreluLayer(const char *name=nullptr)
Definition: Network.cpp:2674
armnn::OptimizerOptions::m_shapeInferenceMethod
ShapeInferenceMethod m_shapeInferenceMethod
Infer output size when not available.
Definition: INetwork.hpp:250
armnn::LstmInputParams::m_InputToOutputWeights
const ConstTensor * m_InputToOutputWeights
Definition: LstmParams.hpp:43
armnn::INetwork::AddPooling3dLayer
IConnectableLayer * AddPooling3dLayer(const Pooling3dDescriptor &pooling3dDescriptor, const char *name=nullptr)
Adds a 3D pooling layer to the network.
Definition: Network.cpp:362
armnn::SubgraphView::IConnectableLayers
std::list< IConnectableLayer * > IConnectableLayers
Definition: SubgraphView.hpp:62
armnn::NetworkImpl::AddUnidirectionalSequenceLstmLayer
IConnectableLayer * AddUnidirectionalSequenceLstmLayer(const UnidirectionalSequenceLstmDescriptor &descriptor, const LstmInputParams &params, const char *name=nullptr)
Definition: Network.cpp:2906
armnn::NetworkImpl::AddSoftmaxLayer
IConnectableLayer * AddSoftmaxLayer(const SoftmaxDescriptor &softmaxDescriptor, const char *name=nullptr)
Definition: Network.cpp:2351
armnn::NetworkOptions
std::vector< BackendOptions > NetworkOptions
Definition: BackendOptions.hpp:16
armnn::LstmInputParams::m_CellToForgetWeights
const ConstTensor * m_CellToForgetWeights
Definition: LstmParams.hpp:49
armnn::FusedDescriptor
A FusedDescriptor for the FusedLayer.
Definition: Descriptors.hpp:944
armnn::OutputSlot::GetOwningLayer
Layer & GetOwningLayer() const
Definition: Layer.hpp:132
armnn::NetworkImpl::AddBatchNormalizationLayer
IConnectableLayer * AddBatchNormalizationLayer(const BatchNormalizationDescriptor &desc, const ConstTensor &mean, const ConstTensor &variance, const ConstTensor &beta, const ConstTensor &gamma, const char *name=nullptr)
Definition: Network.cpp:2388
armnn::Graph::begin
Iterator begin()
Returns iterator pointing to the beginning of the list. Lowercase for range-based for loops.
Definition: Graph.hpp:176
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:629
armnn::INetwork::AddDepthToSpaceLayer
IConnectableLayer * AddDepthToSpaceLayer(const DepthToSpaceDescriptor &depthToSpaceDescriptor, const char *name=nullptr)
Adds a depth to space layer to the network.
Definition: Network.cpp:285
armnn::ReshapeLayer
This layer represents a reshape operation.
Definition: ReshapeLayer.hpp:15
armnn::QuantizedLstmInputParams::GetRecurrentToOutputWeights
const ConstTensor & GetRecurrentToOutputWeights() const
Definition: QuantizedLstmParams.hpp:93
armnn::DataType::Float16
@ Float16
armnn::optimizations::ConvertConstantsFloatToHalf
ConvertConstants< Float32ToFloat16, IsFloat16Layer > ConvertConstantsFloatToHalf
Definition: ConvertConstants.hpp:99
armnn::LstmInputParams::m_RecurrentToInputWeights
const ConstTensor * m_RecurrentToInputWeights
Definition: LstmParams.hpp:44
armnn::SubgraphViewSelector::SelectSubgraphs
static Subgraphs SelectSubgraphs(Graph &graph, const LayerSelectorFunction &selector)
Selects subgraphs from a graph based on the selector function and the algorithm.
Definition: SubgraphViewSelector.cpp:269
armnn::SubgraphView::GetIConnectableLayers
const IConnectableLayers & GetIConnectableLayers() const
Definition: SubgraphView.cpp:281
armnn::AttemptBackendAssignment
OptimizationResult AttemptBackendAssignment(BackendSettings &backendSettings, Graph &graph, Layer *layer, BackendId backend, DataType dataTypeIn, DataType dataTypeOut, const std::vector< BackendId > &availablePreferredBackends, std::string &reasonIfUnsupported, Optional< std::vector< std::string > & > errMessages)
Definition: Network.cpp:844
armnn::EdgeStrategy::Undefined
@ Undefined
armnn::INetwork::AddMergeLayer
IConnectableLayer * AddMergeLayer(const char *name=nullptr)
Adds a merge layer to the network.
Definition: Network.cpp:404
armnn::ConvertFp32ToFp16Layer
This layer converts data type Float 32 to Float 16.
Definition: ConvertFp32ToFp16Layer.hpp:13
armnn::BackendSettings::m_SupportedBackends
BackendIdSet m_SupportedBackends
Definition: BackendSettings.hpp:21
armnn::OptimizeForConnection
Definition: Optimization.hpp:118
armnn::BackendOptions::Var::ToString
std::string ToString()
Definition: BackendOptions.hpp:124
armnn::ConvertFp16ToFp32Layer
This layer converts data type Float 16 to Float 32.
Definition: ConvertFp16ToFp32Layer.hpp:14
armnn::LstmLayer
This layer represents a LSTM operation.
Definition: LstmLayer.hpp:16
armnn::LstmInputParams::m_InputToInputWeights
const ConstTensor * m_InputToInputWeights
Definition: LstmParams.hpp:40
armnn::OutputSlot::Disconnect
void Disconnect(InputSlot &slot)
Definition: Layer.cpp:131
armnn::NetworkImpl::AddFillLayer
IConnectableLayer * AddFillLayer(const FillDescriptor &fillDescriptor, const char *name=nullptr)
Definition: Network.cpp:2240
armnn::INetwork::AddSpaceToDepthLayer
IConnectableLayer * AddSpaceToDepthLayer(const SpaceToDepthDescriptor &spaceToDepthDescriptor, const char *name=nullptr)
Adds a space to depth layer to the network.
Definition: Network.cpp:486
armnn::OptimizerOptionsOpaque::AddModelOption
void AddModelOption(armnn::BackendOptions)
Definition: Network.cpp:151
armnn::SubgraphView::begin
IConnectableLayerIterator begin()
Definition: SubgraphView.cpp:286
armnn::LstmInputParams::m_RecurrentToOutputWeights
const ConstTensor * m_RecurrentToOutputWeights
Definition: LstmParams.hpp:47
armnn::ITensorHandleFactory::DeferredFactoryId
static const FactoryId DeferredFactoryId
Use the workload factory to create the tensor handle.
Definition: ITensorHandleFactory.hpp:51
armnn::OptimizerOptionsOpaque::OptimizerOptionsOpaque
OptimizerOptionsOpaque()
Definition: Network.cpp:49
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:368
armnn::InsertConvertFp32ToFp16LayersAfter
std::vector< ConvertFp32ToFp16Layer * > InsertConvertFp32ToFp16LayersAfter(Graph &graph, Layer &layer)
Definition: NetworkUtils.cpp:79
Logging.hpp
armnn::PadDescriptor
A PadDescriptor for the PadLayer.
Definition: Descriptors.hpp:1196
armnn::NetworkImpl::AddGatherNdLayer
IConnectableLayer * AddGatherNdLayer(const char *name=nullptr)
Definition: Network.cpp:2659
armnn::ChannelShuffleLayer
Definition: ChannelShuffleLayer.hpp:11
ARMNN_SCOPED_PROFILING_EVENT
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
Definition: Profiling.hpp:220
armnn::ReduceLayer
This layer represents a reduction operation.
Definition: ReduceLayer.hpp:14
armnn::TransposeDescriptor
A TransposeDescriptor for the TransposeLayer.
Definition: Descriptors.hpp:1490
armnn::MultiplicationLayer
This layer represents a multiplication operation.
Definition: MultiplicationLayer.hpp:14
armnn::OutputSlot::GetNumConnections
unsigned int GetNumConnections() const override
Definition: Layer.hpp:158
PolymorphicDowncast.hpp
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::SliceDescriptor
A SliceDescriptor for the SliceLayer.
Definition: Descriptors.hpp:1228
armnnUtils::FloatingPointConverter::ConvertFloat16To32
static void ConvertFloat16To32(const void *srcFloat16Buffer, size_t numElements, float *dstFloat32Buffer)
Definition: FloatingPointConverter.cpp:43
armnn::DataType
DataType
Definition: Types.hpp:48
armnn::ReportError
void ReportError(const std::string &errorMessage, Optional< std::vector< std::string > & > errorMessages)
Definition: Network.cpp:762
IBackendInternal.hpp
armnn::LayerType::Softmax
@ Softmax
armnn::CheckFp16Support
bool CheckFp16Support(BackendsMap &backends, const std::vector< BackendId > &availablePreferredBackends)
Definition: Network.cpp:1026
armnn::NetworkImpl::AddStackLayer
IConnectableLayer * AddStackLayer(const StackDescriptor &stackDescriptor, const char *name=nullptr)
Definition: Network.cpp:2707
armnn::LstmInputParams::m_InputGateBias
const ConstTensor * m_InputGateBias
Definition: LstmParams.hpp:51
armnn::INetwork::AddSplitterLayer
IConnectableLayer * AddSplitterLayer(const ViewsDescriptor &splitterDescriptor, const char *name=nullptr)
Adds a splitter layer to the network.
Definition: Network.cpp:398
armnn::INetwork::AddShapeLayer
IConnectableLayer * AddShapeLayer(const char *name=nullptr)
Adds a shape layer to the network.
Definition: Network.cpp:593
armnn::NetworkImpl::AddElementwiseUnaryLayer
IConnectableLayer * AddElementwiseUnaryLayer(const ElementwiseUnaryDescriptor &elementwiseUnaryDescriptor, const char *name=nullptr)
Definition: Network.cpp:2234
armnn::SpaceToDepthLayer
This layer represents a SpaceToDepth operation.
Definition: SpaceToDepthLayer.hpp:14
armnn::BackendRegistryInstance
BackendRegistry & BackendRegistryInstance()
Definition: BackendRegistry.cpp:15
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:423
armnn::ReshapeDescriptor
A ReshapeDescriptor for the ReshapeLayer.
Definition: Descriptors.hpp:1023
armnn::OutputLayer
A layer user-provided data can be bound to (e.g. inputs, outputs).
Definition: OutputLayer.hpp:13
armnn::NetworkImpl::AddConvertFp16ToFp32Layer
IConnectableLayer * AddConvertFp16ToFp32Layer(const char *name=nullptr)
Definition: Network.cpp:2270
armnn::NetworkImpl::AddOutputLayer
IConnectableLayer * AddOutputLayer(LayerBindingId id, const char *name=nullptr)
Definition: Network.cpp:2383
armnn::QuantizedLstmInputParams::GetInputToCellWeights
const ConstTensor & GetInputToCellWeights() const
Definition: QuantizedLstmParams.hpp:68
armnn::InvalidArgumentException
Definition: Exceptions.hpp:80
armnn::OptimizerOptions::m_Debug
bool m_Debug
Add debug data for easier troubleshooting.
Definition: INetwork.hpp:240
armnn::QuantizedLstmInputParams::GetRecurrentToCellWeights
const ConstTensor & GetRecurrentToCellWeights() const
Definition: QuantizedLstmParams.hpp:88
armnn::optimizations::FusePermuteIntoConstLayer
OptimizeForConnection< ConstantLayer, PermuteLayer, ConvertConstPermuteLayersToConstLayers > FusePermuteIntoConstLayer
Definition: ConvertConstPermuteLayersToConstLayers.hpp:124
armnn::LayerBindingId
int LayerBindingId
Type of identifiers for bindable layers (inputs, outputs).
Definition: Types.hpp:309
armnn::NetworkImpl::AddReshapeLayer
IConnectableLayer * AddReshapeLayer(const ReshapeDescriptor &reshapeDescriptor, const char *name=nullptr)
Definition: Network.cpp:2453
armnn::NetworkImpl::AddQLstmLayer
IConnectableLayer * AddQLstmLayer(const QLstmDescriptor &descriptor, const LstmInputParams &params, const char *name=nullptr)
Definition: Network.cpp:2758
armnn::L2NormalizationLayer
This layer represents a L2 normalization operation.
Definition: L2NormalizationLayer.hpp:13
armnn::OptimizerOptions::m_ExportEnabled
bool m_ExportEnabled
Enable Export.
Definition: INetwork.hpp:262
armnn::INetwork::AddMinimumLayer
IConnectableLayer * AddMinimumLayer(const char *name=nullptr)
Add a Minimum layer to the network.
Definition: Network.cpp:551
armnn::NetworkImpl::PrintGraph
Status PrintGraph()
Definition: Network.cpp:2195
armnn::BackendId::Get
const std::string & Get() const
Definition: BackendId.hpp:138
armnn::INetwork::AddConvolution2dLayer
IConnectableLayer * AddConvolution2dLayer(const Convolution2dDescriptor &convolution2dDescriptor, const char *name=nullptr)
Adds a 2D convolution layer to the network.
Definition: Network.cpp:272
armnn::EdgeStrategy
EdgeStrategy
Definition: ITensorHandleFactory.hpp:104
armnn::NetworkImpl::AddScatterNdLayer
IConnectableLayer * AddScatterNdLayer(const ScatterNdDescriptor &scatterDescriptor, const char *name=nullptr)
Definition: Network.cpp:3101
armnn::QuantizedLstmInputParams::GetRecurrentToInputWeights
const ConstTensor & GetRecurrentToInputWeights() const
Definition: QuantizedLstmParams.hpp:78
armnn::Layer::GetNumOutputSlots
unsigned int GetNumOutputSlots() const override
Returns the number of connectable output slots.
Definition: Layer.hpp:335
armnn::MakeOptimizations
Optimizer::Optimizations MakeOptimizations(Args &&... args)
Definition: Optimizer.hpp:43
armnn::NetworkImpl::AddInputLayer
IConnectableLayer * AddInputLayer(LayerBindingId id, const char *name=nullptr)
Definition: Network.cpp:2201
armnn::NetworkImpl::GetGraph
const Graph & GetGraph() const
Definition: Network.hpp:38
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:306
armnn::PermuteDescriptor
A PermuteDescriptor for the PermuteLayer.
Definition: Descriptors.hpp:149
armnn::DequantizeLayer
This layer dequantizes the input tensor.
Definition: DequantizeLayer.hpp:13
armnn::BatchMatMulDescriptor
A BatchMatMulDescriptor for the BatchMatMul operator.
Definition: Descriptors.hpp:1584
armnn::ReverseV2Layer
This layer represents a ReverseV2 operation.
Definition: ReverseV2Layer.hpp:14
armnn::INetwork::AddLogicalBinaryLayer
IConnectableLayer * AddLogicalBinaryLayer(const LogicalBinaryDescriptor &descriptor, const char *name=nullptr)
Adds a Logical Binary layer to the network.
Definition: Network.cpp:623
armnn::SpaceToBatchNdLayer
This layer represents a SpaceToBatchNd operation.
Definition: SpaceToBatchNdLayer.hpp:14
armnn::NetworkImpl::AddMinimumLayer
IConnectableLayer * AddMinimumLayer(const char *name=nullptr)
Definition: Network.cpp:2368
armnn::ITensorHandleFactory
Definition: ITensorHandleFactory.hpp:46
armnn::Graph::GetProfiler
const std::shared_ptr< IProfiler > & GetProfiler() const
Definition: Graph.cpp:733
armnn::OptimizedNetworkImpl::GetNumInputs
virtual size_t GetNumInputs() const
Definition: Network.cpp:752
armnn::RequiresCopy
bool RequiresCopy(ITensorHandleFactory::FactoryId src, ITensorHandleFactory::FactoryId dst, TensorHandleFactoryRegistry &registry)
Definition: Network.cpp:1454
armnn::SubgraphView
The SubgraphView class represents a subgraph of a Graph.
Definition: SubgraphView.hpp:31
armnn::FullyConnectedLayer
This layer represents a fully connected operation.
Definition: FullyConnectedLayer.hpp:15
armnn::OptimizationViews
Definition: OptimizationViews.hpp:17
armnn::INetwork::AddDivisionLayer
IConnectableLayer * AddDivisionLayer(const char *name=nullptr)
Adds a division layer to the network.
Definition: Network.cpp:508
Filesystem.hpp
armnn::StandInLayer
This layer represents an unknown operation in the input graph.
Definition: StandInLayer.hpp:14
armnn::ReturnWithError
OptimizationResult ReturnWithError(OptimizationResult res, const Layer *layer, const BackendSettings &backendSettings, Optional< std::vector< std::string > & > errMessages)
Definition: Network.cpp:786
armnn::SliceLayer
Definition: SliceLayer.hpp:13
armnn::ITensorHandleFactory::GetImportFlags
virtual MemorySourceFlags GetImportFlags() const
Definition: ITensorHandleFactory.hpp:91
armnn::NetworkImpl::AddElementwiseBinaryLayer
IConnectableLayer * AddElementwiseBinaryLayer(const ElementwiseBinaryDescriptor &elementwiseBinaryDescriptor, const char *name=nullptr)
Definition: Network.cpp:2228
armnn::OptimizerOptionsOpaque::GetDebugToFileEnabled
bool GetDebugToFileEnabled() const
Definition: Network.cpp:186
armnn::SpaceToBatchNdDescriptor
A SpaceToBatchNdDescriptor for the SpaceToBatchNdLayer.
Definition: Descriptors.hpp:1043
armnn::INetwork::AddRankLayer
IConnectableLayer * AddRankLayer(const char *name=nullptr)
Adds a rank layer to the network.
Definition: Network.cpp:433
armnn::INetwork::AddPadLayer
IConnectableLayer * AddPadLayer(const PadDescriptor &padDescriptor, const char *name=nullptr)
Adds a fully pad layer to the network.
Definition: Network.cpp:534
armnn::Status::Success
@ Success
armnn::Convolution3dDescriptor
A Convolution3dDescriptor for the Convolution3dLayer.
Definition: Descriptors.hpp:588
armnn::Exception
Base class for all ArmNN exceptions so that users can filter to just those.
Definition: Exceptions.hpp:46
armnn::QuantizedLstmLayer
This layer represents a QuantizedLstm operation.
Definition: QuantizedLstmLayer.hpp:45
armnn::ElementwiseBinaryLayer
This layer represents a elementwiseBinary operation.
Definition: ElementwiseBinaryLayer.hpp:14
armnn::Pooling2dLayer
This layer represents a pooling 2d operation.
Definition: Pooling2dLayer.hpp:13
armnn::NetworkImpl::AddQuantizeLayer
IConnectableLayer * AddQuantizeLayer(const char *name=nullptr)
Definition: Network.cpp:2637
armnn::RuntimeException
Definition: Exceptions.hpp:120
armnn::SwitchLayer
This layer calculates both true and false outputs for input.
Definition: SwitchLayer.hpp:13
armnn::NetworkImpl::AddNormalizationLayer
IConnectableLayer * AddNormalizationLayer(const NormalizationDescriptor &normalizationDescriptor, const char *name=nullptr)
Definition: Network.cpp:2339
armnn::DivisionLayer
This layer represents a division operation.
Definition: DivisionLayer.hpp:14
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:501
armnn::NetworkImpl
Private implementation of INetwork.
Definition: Network.hpp:32
armnn::QuantizeLayer
Definition: QuantizeLayer.hpp:16
armnn::IOptimizedNetwork::GetNumOutputs
size_t GetNumOutputs() const
Definition: Network.cpp:736
armnn::GetLayerInOutDatatype
std::vector< DataType > GetLayerInOutDatatype(const Layer *layer)
Definition: Network.cpp:1017
armnn::QuantizedLstmInputParams::GetCellBias
const ConstTensor & GetCellBias() const
Definition: QuantizedLstmParams.hpp:108
armnn::BackendSettings::GetAvailablePreferredBackends
BackendIdVector GetAvailablePreferredBackends() const
Definition: BackendSettings.hpp:67
armnn::Graph::InferTensorInfos
void InferTensorInfos()
Definition: Graph.cpp:645
armnn::BoostLogSeverityMapping::info
@ info
armnn::OptimizerOptions::m_ProfilingEnabled
bool m_ProfilingEnabled
Enable profiling dump of the optimizer phase.
Definition: INetwork.hpp:259
armnn::NetworkImpl::AddMergeLayer
IConnectableLayer * AddMergeLayer(const char *name=nullptr)
Definition: Network.cpp:2664
armnn::OptimizerOptionsOpaque::SetAllowExpandedDims
void SetAllowExpandedDims(bool ExpandedDimsAllowed)
Definition: Network.cpp:146
armnn::NetworkImpl::AddShapeLayer
IConnectableLayer * AddShapeLayer(const char *name=nullptr)
Definition: Network.cpp:2421
BackendSettings.hpp
armnn::TensorInfo::GetDataType
DataType GetDataType() const
Definition: Tensor.hpp:200
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:604
armnn::ScatterNdLayer
This layer represents a ScatterNd operator.
Definition: ScatterNdLayer.hpp:14
armnn::IWorkloadFactory::IsLayerSupported
static bool IsLayerSupported(const BackendId &backendId, const IConnectableLayer &layer, Optional< DataType > dataType, std::string &outReasonIfUnsupported)
Definition: WorkloadFactory.cpp:1629
armnn::FillLayer
This layer represents a fill operation.
Definition: FillLayer.hpp:13
armnn::NetworkImpl::AddConcatLayer
IConnectableLayer * AddConcatLayer(const ConcatDescriptor &concatDescriptor, const char *name=nullptr)
Definition: Network.cpp:2258
armnn::OptimizerOptionsOpaque::GetDebugEnabled
bool GetDebugEnabled() const
Definition: Network.cpp:181
armnn::Layer::GetNumInputSlots
unsigned int GetNumInputSlots() const override
Returns the number of connectable input slots.
Definition: Layer.hpp:334
armnn::QuantizedLstmInputParams::GetInputToOutputWeights
const ConstTensor & GetInputToOutputWeights() const
Definition: QuantizedLstmParams.hpp:73
armnn::InputSlot
Definition: Layer.hpp:42
armnn::InstanceNormalizationLayer
This layer represents an instance normalization operation.
Definition: InstanceNormalizationLayer.hpp:13
armnn::IOptimizedNetwork::~IOptimizedNetwork
~IOptimizedNetwork()
armnn::NetworkImpl::AddCastLayer
IConnectableLayer * AddCastLayer(const char *name=nullptr)
Definition: Network.cpp:2212
armnn::INetwork::AddSwitchLayer
IConnectableLayer * AddSwitchLayer(const char *name=nullptr)
Adds a switch layer to the network.
Definition: Network.cpp:569
armnn::LstmInputParams::m_InputLayerNormWeights
const ConstTensor * m_InputLayerNormWeights
Definition: LstmParams.hpp:57
armnn::INetwork::AddElementwiseBinaryLayer
IConnectableLayer * AddElementwiseBinaryLayer(const ElementwiseBinaryDescriptor &elementwiseBinaryDescriptor, const char *name=nullptr)
Add an ElementwiseBinary layer to the network.
Definition: Network.cpp:314
armnn::QuantizedLstmInputParams::GetRecurrentToForgetWeights
const ConstTensor & GetRecurrentToForgetWeights() const
Definition: QuantizedLstmParams.hpp:83
armnn::DetectionPostProcessLayer::m_Anchors
std::shared_ptr< ConstTensorHandle > m_Anchors
A unique pointer to store Anchor values.
Definition: DetectionPostProcessLayer.hpp:20
armnn::ShapeInferenceMethod::ValidateOnly
@ ValidateOnly
Validate all output shapes.
armnn::CastLayer
This layer represents a cast operation.
Definition: CastLayer.hpp:14
armnn::UnidirectionalSequenceLstmLayer
This layer represents a LSTM operation.
Definition: UnidirectionalSequenceLstmLayer.hpp:16
armnn::INetwork::AddFillLayer
IConnectableLayer * AddFillLayer(const FillDescriptor &fillDescriptor, const char *name=nullptr)
Add an Fill layer to the network.
Definition: Network.cpp:326
armnn::BatchToSpaceNdDescriptor
A BatchToSpaceNdDescriptor for the BatchToSpaceNdLayer.
Definition: Descriptors.hpp:875
armnn::Convolution2dDescriptor
A Convolution2dDescriptor for the Convolution2dLayer.
Definition: Descriptors.hpp:534
armnn::OptimizeForType
Definition: Optimization.hpp:67
armnn::NetworkImpl::AddFusedLayer
IConnectableLayer * AddFusedLayer(const FusedDescriptor &fusedDescriptor, const char *name=nullptr)
Definition: Network.cpp:2252
armnn::NetworkImpl::AddStandInLayer
IConnectableLayer * AddStandInLayer(const StandInDescriptor &descriptor, const char *name=nullptr)
Definition: Network.cpp:2714
armnn::ComparisonDescriptor
A ComparisonDescriptor for the ComparisonLayer.
Definition: Descriptors.hpp:89
armnn::FillDescriptor
A FillDescriptor for the FillLayer.
Definition: Descriptors.hpp:925
armnn::INetwork::AddSubtractionLayer
IConnectableLayer * AddSubtractionLayer(const char *name=nullptr)
Adds a subtraction layer to the network.
Definition: Network.cpp:515
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:247
armnn::DataType::QAsymmS8
@ QAsymmS8
armnn::CapabilityClass::PaddingRequired
@ PaddingRequired
armnn::NetworkImpl::AddQuantizedLstmLayer
IConnectableLayer * AddQuantizedLstmLayer(const QuantizedLstmInputParams &params, const char *name=nullptr)
Definition: Network.cpp:2720
armnn::ParseOptions
void ParseOptions(const std::vector< BackendOptions > &options, BackendId backend, F f)
Definition: BackendOptions.hpp:297
armnn::StandInDescriptor
A StandInDescriptor for the StandIn layer.
Definition: Descriptors.hpp:1281
armnn::QuantizedLstmLayer::m_QuantizedLstmParameters
QuantizedLstmParameters m_QuantizedLstmParameters
Definition: QuantizedLstmLayer.hpp:49
armnn::OptimizerOptions::m_ModelOptions
ModelOptions m_ModelOptions
Enable Model Options.
Definition: INetwork.hpp:256
armnn::INetwork::AddQuantizedLstmLayer
IConnectableLayer * AddQuantizedLstmLayer(const QuantizedLstmInputParams &params, const char *name=nullptr)
Add a QuantizedLstm layer to the network.
Definition: Network.cpp:610
armnn::StridedSliceLayer
This layer represents a strided slice operation.
Definition: StridedSliceLayer.hpp:13
armnn::LstmInputParams::m_ForgetLayerNormWeights
const ConstTensor * m_ForgetLayerNormWeights
Definition: LstmParams.hpp:58
armnn::LstmLayer::m_BasicParameters
LstmBasicParameters m_BasicParameters
Definition: LstmLayer.hpp:20
armnn::OptimizationViews::Validate
bool Validate(const SubgraphView &originalSubgraph) const
Definition: OptimizationViews.cpp:11
armnn::optimizations::OptimizeInverseConversionsFp32
OptimizeForConnection< ConvertFp32ToFp16Layer, ConvertFp16ToFp32Layer, OptimizeInverseConversionsImpl > OptimizeInverseConversionsFp32
Definition: OptimizeInverseConversions.hpp:44
armnn::BackendSettings::IsCpuRefUsed
bool IsCpuRefUsed() const
Definition: BackendSettings.hpp:61
armnn::BackendOptions
Struct for the users to pass backend specific options.
Definition: BackendOptions.hpp:22
armnn::NetworkImpl::AddDequantizeLayer
IConnectableLayer * AddDequantizeLayer(const char *name=nullptr)
Definition: Network.cpp:2642
armnn::Layer::GetType
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
Definition: Layer.hpp:286
armnn::Graph::AddCompatibilityLayers
void AddCompatibilityLayers(std::map< BackendId, std::unique_ptr< class IBackendInternal >> &backends, TensorHandleFactoryRegistry &registry)
Modifies the graph in-place, removing edges connecting layers using different compute devices,...
Definition: Graph.cpp:330
armnn::LstmBasicParameters::m_InputToForgetWeights
std::shared_ptr< ConstTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [input_size, num_units].
Definition: LstmParameters.hpp:57
armnn::LstmDescriptor
An LstmDescriptor for the LstmLayer.
Definition: Descriptors.hpp:1102
armnn::StridedSliceDescriptor
A StridedSliceDescriptor for the StridedSliceLayer.
Definition: Descriptors.hpp:1303
armnn::CalculateSlotOptionForOutput
ITensorHandleFactory::FactoryId CalculateSlotOptionForOutput(BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry &registry)
Definition: Network.cpp:1566
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:579
armnn::INetwork::INetwork
INetwork(NetworkOptions networkOptions={})
Definition: Network.cpp:45
TensorHandle.hpp
armnn::Status
Status
Definition: Types.hpp:42
armnn::optimizations::TransposeAsReshape
OptimizeForType< TransposeLayer, TransposeAsReshapeImpl > TransposeAsReshape
Definition: TransposeAsReshape.hpp:77
armnn::TransposeConvolution2dLayer::m_Weight
std::shared_ptr< ConstTensorHandle > m_Weight
A unique pointer to store weight values.
Definition: TransposeConvolution2dLayer.hpp:19
armnn::Graph::end
Iterator end()
Returns iterator pointing to the end of the list. Lowercase for range-based for loops.
Definition: Graph.hpp:178
armnn::LogicalBinaryDescriptor
A LogicalBinaryDescriptor for the LogicalBinaryLayer.
Definition: Descriptors.hpp:1518
armnn::ActivationLayer
This layer represents an activation operation with the specified activation function.
Definition: ActivationLayer.hpp:12
armnn::OptimizerOptionsOpaque::GetAllowExpandedDims
bool GetAllowExpandedDims() const
Definition: Network.cpp:191
armnn::SoftmaxLayer
This layer represents a softmax operation.
Definition: SoftmaxLayer.hpp:13
Network.hpp
armnn::CalculateSlotOptionForInput
ITensorHandleFactory::FactoryId CalculateSlotOptionForInput(BackendsMap &backends, OutputSlot &slot, TensorHandleFactoryRegistry &registry, bool importEnabled)
Definition: Network.cpp:1474
ARMNN_NO_DEPRECATE_WARN_END
#define ARMNN_NO_DEPRECATE_WARN_END
Definition: Deprecated.hpp:34
armnn::INetwork::AddDepthwiseConvolution2dLayer
IConnectableLayer * AddDepthwiseConvolution2dLayer(const DepthwiseConvolution2dDescriptor &convolution2dDescriptor, const char *name=nullptr)
Adds a 2D depthwise convolution layer to the network.
Definition: Network.cpp:292
armnn::INetwork::AddPooling2dLayer
IConnectableLayer * AddPooling2dLayer(const Pooling2dDescriptor &pooling2dDescriptor, const char *name=nullptr)
Adds a 2D pooling layer to the network.
Definition: Network.cpp:356
armnn::BoostLogSeverityMapping::debug
@ debug
armnn::optimizations::FuseBatchNormIntoConvolution2DFloat16
OptimizeForExclusiveConnection< Convolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< Convolution2dLayer, armnn::DataType::Float16 > > FuseBatchNormIntoConvolution2DFloat16
Definition: FuseBatchNorm.hpp:227
armnn::ConstantLayer::m_LayerOutput
std::shared_ptr< ConstTensorHandle > m_LayerOutput
Definition: ConstantLayer.hpp:46
armnn::INetwork::AddNormalizationLayer
IConnectableLayer * AddNormalizationLayer(const NormalizationDescriptor &normalizationDescriptor, const char *name=nullptr)
Adds a normalization layer to the network.
Definition: Network.cpp:382
std
Definition: BackendId.hpp:149
armnn::OptimizerOptionsOpaque::ToString
const std::string ToString() const
Definition: Network.cpp:206
armnn::GatherNdLayer
This layer represents a GatherNd operator.
Definition: GatherNdLayer.hpp:14
armnn::BatchMatMulLayer
Definition: BatchMatMulLayer.hpp:13
armnn::IgnoreUnused
void IgnoreUnused(Ts &&...)
Definition: IgnoreUnused.hpp:14
armnn::ShapeLayer
Definition: ShapeLayer.hpp:13
armnn::INetwork::AddQuantizeLayer
IConnectableLayer * AddQuantizeLayer(const char *name=nullptr)
Add a quantize layer to the network.
Definition: Network.cpp:540
armnn::PreCompiledLayer
Definition: PreCompiledLayer.hpp:22
armnn::EdgeStrategy::ExportToTarget
@ ExportToTarget
Destination backend can work directly with tensors on source backend.
armnn::INetwork::Destroy
static void Destroy(INetwork *network)
Definition: Network.cpp:687
armnn::OutputSlot::GetConnections
const std::vector< InputSlot * > & GetConnections() const
Definition: Layer.hpp:145
armnn::OutputSlot::SetEdgeStrategy
void SetEdgeStrategy(unsigned int connectionIndex, EdgeStrategy strategy)
Definition: Layer.cpp:223
armnn::OptimizationViews::GetSubstitutions
const Substitutions & GetSubstitutions() const
Definition: OptimizationViews.hpp:58
armnn::INetwork::pNetworkImpl
std::unique_ptr< NetworkImpl > pNetworkImpl
Definition: INetwork.hpp:895
armnn::SubgraphView::end
IConnectableLayerIterator end()
Definition: SubgraphView.cpp:291
armnn::OptimizerOptions
Definition: INetwork.hpp:151
armnn::IOptimizedNetwork::Destroy
static void Destroy(IOptimizedNetwork *network)
Definition: Network.cpp:706
armnn::OptimizationViews::GetDeletedSubgraphs
const Subgraphs & GetDeletedSubgraphs() const
Definition: OptimizationViews.hpp:61
armnn::AssignBackends
OptimizationResult AssignBackends(OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, SubgraphView &subgraph, Optional< std::vector< std::string > & > errMessages)
Definition: Network.cpp:1288
armnn::LstmInputParams::m_OutputGateBias
const ConstTensor * m_OutputGateBias
Definition: LstmParams.hpp:54
armnn::Layer::GetBackendId
const BackendId & GetBackendId() const
Definition: Layer.hpp:290
armnn::BackendId
Definition: BackendId.hpp:75
armnn::NetworkImpl::AddL2NormalizationLayer
IConnectableLayer * AddL2NormalizationLayer(const L2NormalizationDescriptor &desc, const char *name=nullptr)
Definition: Network.cpp:2432
armnn::Convolution3dLayer
This layer represents a convolution 3d operation.
Definition: Convolution3dLayer.hpp:16
armnn::NetworkImpl::AddActivationLayer
IConnectableLayer * AddActivationLayer(const ActivationDescriptor &activationDescriptor, const char *name=nullptr)
Definition: Network.cpp:2327
armnn::optimizations::FuseBatchNormIntoDepthwiseConvolution2DFloat16
OptimizeForExclusiveConnection< DepthwiseConvolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< DepthwiseConvolution2dLayer, armnn::DataType::Float16 > > FuseBatchNormIntoDepthwiseConvolution2DFloat16
Definition: FuseBatchNorm.hpp:237
armnn::OriginsDescriptor
An OriginsDescriptor for the ConcatLayer.
Definition: Descriptors.hpp:201
armnn::BackendsMap
std::map< BackendId, std::unique_ptr< class IBackendInternal > > BackendsMap
Definition: Network.hpp:285
armnn::Compute::CpuAcc
@ CpuAcc
CPU Execution: NEON: ArmCompute.
armnn::LstmInputParams::m_ProjectionWeights
const ConstTensor * m_ProjectionWeights
Definition: LstmParams.hpp:55
armnn::NetworkImpl::AddPooling3dLayer
IConnectableLayer * AddPooling3dLayer(const Pooling3dDescriptor &pooling3dDescriptor, const char *name=nullptr)
Definition: Network.cpp:2321
armnn::OptimizerOptionsOpaque::GetProfilingEnabled
bool GetProfilingEnabled() const
Definition: Network.cpp:156
armnn::LstmInputParams::m_InputToForgetWeights
const ConstTensor * m_InputToForgetWeights
Definition: LstmParams.hpp:41
armnn::InputSlot::GetConnectedOutputSlot
const OutputSlot * GetConnectedOutputSlot() const
Definition: Layer.hpp:56
armnn::LayerType::MemCopy
@ MemCopy
armnn::optimizations::SquashEqualTransposeSiblings
OptimizeForConnection< Layer, TransposeLayer, SquashEqualSiblingsImpl< TransposeLayer > > SquashEqualTransposeSiblings
Definition: SquashEqualSiblings.hpp:69
armnn::ConstantLayer
A layer that the constant data can be bound to.
Definition: ConstantLayer.hpp:15
Exceptions.hpp
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::ElementwiseUnaryDescriptor
A ElementwiseUnaryDescriptor for the ElementwiseUnaryLayer.
Definition: Descriptors.hpp:129
armnn::TransposeConvolution2dDescriptor
A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer.
Definition: Descriptors.hpp:1440
armnn::optimizations::ConvertConstantsHalfToFloat
ConvertConstants< Float16ToFloat32, IsFloat32Layer > ConvertConstantsHalfToFloat
Definition: ConvertConstants.hpp:98
ArmNN.hpp
armnn::PreCompiledLayer::SetPreCompiledObject
void SetPreCompiledObject(PreCompiledObjectPtr preCompiledObject)
Definition: PreCompiledLayer.cpp:47
Layer.hpp
armnn::Layer::SetBackendId
void SetBackendId(const BackendId &id) override
Set the backend of the IConnectableLayer.
Definition: Layer.hpp:291
armnn::NetworkImpl::AddPooling2dLayer
IConnectableLayer * AddPooling2dLayer(const Pooling2dDescriptor &pooling2dDescriptor, const char *name=nullptr)
Definition: Network.cpp:2315
armnn::ElementwiseUnaryLayer
This layer represents a elementwiseUnary operation.
Definition: ElementwiseUnaryLayer.hpp:14
armnn::DetectionPostProcessLayer
This layer represents a detection postprocess operator.
Definition: DetectionPostProcessLayer.hpp:16
armnn::OptimizerOptionsOpaque::SetProfilingEnabled
void SetProfilingEnabled(bool ProfilingState)
Definition: Network.cpp:121
armnn::IOptimizedNetwork::IOptimizedNetwork
IOptimizedNetwork(const IOptimizedNetwork &other, const ModelOptions &modelOptions)
Creates a copy of the IOptimizedNetwork.
Definition: Network.cpp:692
armnn::INetwork::AddConcatLayer
IConnectableLayer * AddConcatLayer(const ConcatDescriptor &concatDescriptor, const char *name=nullptr)
Adds a concatenation layer to the network.
Definition: Network.cpp:265
armnn::optimizations::SquashEqualPermuteSiblings
OptimizeForConnection< Layer, PermuteLayer, SquashEqualSiblingsImpl< PermuteLayer > > SquashEqualPermuteSiblings
Definition: SquashEqualSiblings.hpp:67
armnn::OptimizerOptionsOpaque::SetDebugToFileEnabled
void SetDebugToFileEnabled(bool DebugFileState)
Definition: Network.cpp:131
armnn::LogicalBinaryLayer
This layer represents a Logical Binary operation.
Definition: LogicalBinaryLayer.hpp:14
armnn::OptimizerOptions::m_DebugToFile
bool m_DebugToFile
Pass debug data to separate output files for easier troubleshooting.
Definition: INetwork.hpp:243
armnn::ITensorHandleFactory::FactoryId
std::string FactoryId
Definition: ITensorHandleFactory.hpp:49
armnn::INetwork::AddMultiplicationLayer
IConnectableLayer * AddMultiplicationLayer(const char *name=nullptr)
Adds a multiplication layer to the network.
Definition: Network.cpp:416
armnn::QuantizedLstmInputParams::GetInputToForgetWeights
const ConstTensor & GetInputToForgetWeights() const
Definition: QuantizedLstmParams.hpp:63
armnn::INetwork::AddConvolution3dLayer
IConnectableLayer * AddConvolution3dLayer(const Convolution3dDescriptor &convolution3dDescriptor, const char *name=nullptr)
Adds a 3D convolution layer to the network.
Definition: Network.cpp:278
armnn::BoostLogSeverityMapping::warning
@ warning
armnn::INetwork::AddScatterNdLayer
IConnectableLayer * AddScatterNdLayer(const ScatterNdDescriptor &descriptor, const char *name=nullptr)
Add a ScatterNd layer to the network.
Definition: Network.cpp:666
armnn::ConstTensor
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:329
armnn::IConnectableLayer
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:80
armnn::PermuteLayer
This layer represents a permutation operation.
Definition: PermuteLayer.hpp:15
armnn::Optimizer::Pass
static void Pass(Graph &graph, const Optimizations &optimizations)
Definition: Optimizer.cpp:16
armnn::IDeviceSpec
Device specific knowledge to be passed to the optimizer.
Definition: Types.hpp:299
armnn::NetworkImpl::AddMultiplicationLayer
IConnectableLayer * AddMultiplicationLayer(const char *name=nullptr)
Definition: Network.cpp:2378
armnn::LayerType::Input
@ Input
armnn::IBackendInternal::GetHandleFactoryPreferences
virtual std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences() const
(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.
Definition: IBackendInternal.cpp:143
armnn::ModelOptions
std::vector< BackendOptions > ModelOptions
Definition: BackendOptions.hpp:18
armnn::optimizations::FoldPadIntoDepthwiseConvolution2d
OptimizeForExclusiveConnection< PadLayer, DepthwiseConvolution2dLayer, pad_fold::FoldPadIntoDepthwiseConvolution2dImpl > FoldPadIntoDepthwiseConvolution2d
Definition: FoldPadIntoLayer2d.hpp:281
armnn::INetwork::AddElementwiseUnaryLayer
IConnectableLayer * AddElementwiseUnaryLayer(const ElementwiseUnaryDescriptor &elementwiseUnaryDescriptor, const char *name=nullptr)
Add an ElementwiseUnary layer to the network.
Definition: Network.cpp:320
armnn::TransposeConvolution2dDescriptor::m_BiasEnabled
bool m_BiasEnabled
Enable/disable bias.
Definition: Descriptors.hpp:1481
armnn::DetectionPostProcessDescriptor
Definition: Descriptors.hpp:713
Timer.hpp
armnn::PreCompiledDescriptor
A PreCompiledDescriptor for the PreCompiledLayer.
Definition: Descriptors.hpp:1367
armnn::NetworkImpl::AddConvertFp32ToFp16Layer
IConnectableLayer * AddConvertFp32ToFp16Layer(const char *name=nullptr)
Definition: Network.cpp:2275
armnnUtils::Filesystem::CreateDirectory
std::string CreateDirectory(std::string sPath)
Returns full path to temporary folder.
Definition: Filesystem.cpp:47
armnn::NetworkImpl::AddInstanceNormalizationLayer
IConnectableLayer * AddInstanceNormalizationLayer(const InstanceNormalizationDescriptor &desc, const char *name=nullptr)
Definition: Network.cpp:2426
armnn::optimizations::MaxMinIntoBoundedRelu
OptimizeForExclusiveConnection< ElementwiseBinaryLayer, ElementwiseBinaryLayer, MaxMinIntoBoundedReluImpl > MaxMinIntoBoundedRelu
Definition: MaxMinIntoBoundedRelu.hpp:134
armnn::ScopedTensorHandle
Definition: TensorHandle.hpp:115
armnn::INetwork::AddChannelShuffleLayer
IConnectableLayer * AddChannelShuffleLayer(const ChannelShuffleDescriptor &descriptor, const char *name=nullptr)
Add a ChannelShuffle layer to the network.
Definition: Network.cpp:637
armnn::INetwork::AddInstanceNormalizationLayer
IConnectableLayer * AddInstanceNormalizationLayer(const InstanceNormalizationDescriptor &desc, const char *name=nullptr)
Adds an instance normalization layer to the network.
Definition: Network.cpp:450
armnn::BackendSettings::IsBackendSupported
bool IsBackendSupported(const BackendId &backend) const
Definition: BackendSettings.hpp:46
armnn::optimizations::SquashEqualReshapeSiblings
OptimizeForConnection< Layer, ReshapeLayer, SquashEqualSiblingsImpl< ReshapeLayer > > SquashEqualReshapeSiblings
Definition: SquashEqualSiblings.hpp:70
armnn::QuantizedLstmInputParams::GetInputGateBias
const ConstTensor & GetInputGateBias() const
Definition: QuantizedLstmParams.hpp:98
armnn::INetwork::AddFloorLayer
IConnectableLayer * AddFloorLayer(const char *name=nullptr)
Adds a floor layer to the network.
Definition: Network.cpp:492
armnn::NetworkImpl::AddConvolution3dLayer
IConnectableLayer * AddConvolution3dLayer(const Convolution3dDescriptor &convolution3dDescriptor, const char *name=nullptr)
Definition: Network.cpp:2280
armnn::ResizeLayer
This layer represents a resize operation.
Definition: ResizeLayer.hpp:13
armnn::MaximumLayer
This layer represents a maximum operation.
Definition: MaximumLayer.hpp:14
armnn::CalculateEdgeStrategy
EdgeStrategy CalculateEdgeStrategy(BackendsMap &backends, ITensorHandleFactory::FactoryId srcFactoryId, const Layer &layer, const Layer &connectedLayer, TensorHandleFactoryRegistry &registry, bool importEnabled)
Definition: Network.cpp:1729
armnn::Pooling2dDescriptor
A Pooling2dDescriptor for the Pooling2dLayer.
Definition: Descriptors.hpp:371
armnn::Optimize
IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptionsOpaque &options=OptimizerOptionsOpaque(), Optional< std::vector< std::string > & > messages=EmptyOptional())
Create an optimized version of the network.
Definition: Network.cpp:2145
armnn::NetworkImpl::AddChannelShuffleLayer
IConnectableLayer * AddChannelShuffleLayer(const ChannelShuffleDescriptor &channelShuffleDescriptor, const char *name=nullptr)
Definition: Network.cpp:2216
armnn::BroadcastToDescriptor
Definition: Descriptors.hpp:1659
armnn::DepthwiseConvolution2dDescriptor
A DepthwiseConvolution2dDescriptor for the DepthwiseConvolution2dLayer.
Definition: Descriptors.hpp:659
armnn::ShapeInferenceMethod
ShapeInferenceMethod
The ShapeInferenceMethod modify how the output shapes are treated.
Definition: Types.hpp:235
armnn::OptimizerOptions::m_AllowExpandedDims
bool m_AllowExpandedDims
When calculating tensor sizes, dimensions of size == 1 will be ignored.
Definition: INetwork.hpp:265
armnn::INetwork::AddGatherLayer
IConnectableLayer * AddGatherLayer(const GatherDescriptor &descriptor, const char *name=nullptr)
Add Gather layer to the network.
Definition: Network.cpp:558
armnn::optimizations::OptimizeInverseTransposes
OptimizeForConnection< TransposeLayer, TransposeLayer, OptimizeInversePermutesImpl< TransposeLayer > > OptimizeInverseTransposes
Definition: OptimizeInversePermutes.hpp:45
armnn::ScatterNdDescriptor
A ScatterNdDescriptor for the ScatterNdLayer.
Definition: Descriptors.hpp:1679
armnn::QLstmLayer::m_BasicParameters
QLstmBasicParameters m_BasicParameters
Definition: QLstmLayer.hpp:83
armnn::ReduceDescriptor
A ReduceDescriptor for the REDUCE operators.
Definition: Descriptors.hpp:1538
armnn::NetworkImpl::AddSpaceToBatchNdLayer
IConnectableLayer * AddSpaceToBatchNdLayer(const SpaceToBatchNdDescriptor &spaceToBatchNdDescriptor, const char *name=nullptr)
Definition: Network.cpp:2459
armnn::NetworkImpl::AddSliceLayer
IConnectableLayer * AddSliceLayer(const SliceDescriptor &sliceDescriptor, const char *name=nullptr)
Definition: Network.cpp:2346
armnn::INetwork::AddBroadcastToLayer
IConnectableLayer * AddBroadcastToLayer(const BroadcastToDescriptor &descriptor, const char *name=nullptr)
Add a BroadcastTo layer to the network.
Definition: Network.cpp:660
armnn::INetwork::Create
static INetworkPtr Create(const NetworkOptions &networkOptions={})
Definition: Network.cpp:682
armnn::OptimizerOptionsOpaqueImpl
Definition: Network.hpp:310
armnn::optimizations::AddBroadcastReshapeLayer
OptimizeForType< Layer, AddBroadcastReshapeLayerImpl > AddBroadcastReshapeLayer
Definition: AddBroadcastReshapeLayer.hpp:94
armnn::NullPointerException
Definition: Exceptions.hpp:146
armnn::LstmInputParams
Definition: LstmParams.hpp:13
armnn::optimizations::FuseBatchNormIntoDepthwiseConvolution2DFloat32
OptimizeForExclusiveConnection< DepthwiseConvolution2dLayer, BatchNormalizationLayer, FuseBatchNorm< DepthwiseConvolution2dLayer, armnn::DataType::Float32 > > FuseBatchNormIntoDepthwiseConvolution2DFloat32
Definition: FuseBatchNorm.hpp:232
armnn::LstmInputParams::m_CellLayerNormWeights
const ConstTensor * m_CellLayerNormWeights
Definition: LstmParams.hpp:59
armnn::LayerType
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
Definition: Types.hpp:491
armnn::OutputSlot::GetConnection
const InputSlot * GetConnection(unsigned int index) const override
Definition: Layer.cpp:83
armnn::optimizations::OptimizeConsecutiveReshapes
OptimizeForConnection< ReshapeLayer, ReshapeLayer, OptimizeConsecutiveReshapesImpl > OptimizeConsecutiveReshapes
Definition: OptimizeConsecutiveReshapes.hpp:61
armnn::OptimizedNetworkImpl::GetNumOutputs
virtual size_t GetNumOutputs() const
Definition: Network.cpp:757
armnn::MeanDescriptor
A MeanDescriptor for the MeanLayer.
Definition: Descriptors.hpp:1172
armnn::QuantizedLstmInputParams
Definition: QuantizedLstmParams.hpp:13
armnn::CompiledBlobPtr
std::unique_ptr< void, CompiledBlobDeleter > CompiledBlobPtr
Definition: INetwork.hpp:343
armnn::SubgraphViewSelector::Subgraphs
std::vector< SubgraphView::SubgraphViewPtr > Subgraphs
Definition: SubgraphViewSelector.hpp:24
armnn::Graph
Definition: Graph.hpp:30
armnn::NetworkImpl::AddGatherLayer
IConnectableLayer * AddGatherLayer(const GatherDescriptor &gatherDescriptor, const char *name=nullptr)
Definition: Network.cpp:2653
armnn::NetworkImpl::AddPrecompiledLayer
IConnectableLayer * AddPrecompiledLayer(const PreCompiledDescriptor &preCompiledDescriptor, CompiledBlobPtr compiledBlobPtr, const Optional< BackendId > &backend, const char *name=nullptr)
Definition: Network.cpp:3063
armnn::CheckScaleSetOnQuantizedType
bool CheckScaleSetOnQuantizedType(Layer *layer, Optional< std::vector< std::string > & > errMessages)
Definition: Network.cpp:801
armnn::OptionalReferenceSwitch< std::is_reference< T >::value, T >::value
const T & value() const
Definition: Optional.hpp:146
armnn::OptimizerOptionsOpaque::SetDebugEnabled
void SetDebugEnabled(bool DebugState)
Definition: Network.cpp:126
armnn::TileDescriptor
Definition: Descriptors.hpp:1640
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:350
armnn::INetwork::PrintGraph
Status PrintGraph()
Definition: Network.cpp:237
armnn::PadLayer
This layer represents a pad operation.
Definition: PadLayer.hpp:14
armnn::NetworkImpl::AddPadLayer
IConnectableLayer * AddPadLayer(const PadDescriptor &padDescriptor, const char *name=nullptr)
Definition: Network.cpp:2632
armnn::SoftmaxDescriptor
A SoftmaxDescriptor for the SoftmaxLayer.
Definition: Descriptors.hpp:177
armnn::BackendSettings::m_PreferredBackends
BackendIdVector m_PreferredBackends
Definition: BackendSettings.hpp:20
armnn::QLstmBasicParameters::m_InputToForgetWeights
std::shared_ptr< ConstTensorHandle > m_InputToForgetWeights
A unique pointer to represent 2D weights tensor with dimensions [num_units, inputSize] (QSymmS8).
Definition: QLstmLayer.hpp:17
armnn::INetwork::AddResizeLayer
IConnectableLayer * AddResizeLayer(const ResizeDescriptor &resizeDescriptor, const char *name=nullptr)
Adds a resize layer to the network.
Definition: Network.cpp:438
armnn::INetwork::AddInputLayer
IConnectableLayer * AddInputLayer(LayerBindingId id, const char *name=nullptr)
Adds an input layer to the network.
Definition: Network.cpp:242
armnn::SpaceToDepthDescriptor
A SpaceToDepthDescriptor for the SpaceToDepthLayer.
Definition: Descriptors.hpp:1075
armnn::OptionalBase::has_value
bool has_value() const noexcept
Definition: Optional.hpp:53
armnn::NetworkImpl::AddMaximumLayer
IConnectableLayer * AddMaximumLayer(const char *name=nullptr)
Definition: Network.cpp:2363
armnn::INetwork::~INetwork
~INetwork()
armnn::NetworkImpl::AddDetectionPostProcessLayer
IConnectableLayer * AddDetectionPostProcessLayer(const DetectionPostProcessDescriptor &descriptor, const ConstTensor &anchors, const char *name=nullptr)
Definition: Network.cpp:2299
armnn::MergeLayer
This layer dequantizes the input tensor.
Definition: MergeLayer.hpp:13
armnn::LayerType::Output
@ Output
armnn::LayerType::Constant
@ Constant
armnn::INetwork::AddArgMinMaxLayer
IConnectableLayer * AddArgMinMaxLayer(const ArgMinMaxDescriptor &desc, const char *name=nullptr)
Adds an ArgMinMax layer to the network.
Definition: Network.cpp:247
armnn::IOptimizedNetwork::pOptimizedNetworkImpl
std::unique_ptr< OptimizedNetworkImpl > pOptimizedNetworkImpl
Definition: INetwork.hpp:953
armnn::AssignBackendsIConnectable
void AssignBackendsIConnectable(OptimizedNetworkImpl *optNetObjPtr, IConnectableLayer *it, Optional< std::vector< std::string > & > errMessages, OptimizationResult &result, BackendSettings &backendSettings, std::vector< BackendId > &availablePreferredBackends)
Definition: Network.cpp:1073
armnn::INetwork::AddGatherNdLayer
IConnectableLayer * AddGatherNdLayer(const char *name=nullptr)
Add GatherNd layer to the network.
Definition: Network.cpp:564
armnn::INetwork::AddActivationLayer
IConnectableLayer * AddActivationLayer(const ActivationDescriptor &activationDescriptor, const char *name=nullptr)
Adds an activation layer to the network.
Definition: Network.cpp:376
armnn::HasMatchingCapability
bool HasMatchingCapability(const BackendOptions::BackendOption &capability, const BackendCapabilities &capabilities)
Convenience function to check if a given capability matches a capability in a BackendCapabilities str...
Definition: BackendHelper.cpp:85
armnn::INetwork
Main network class which provides the interface for building up a neural network.
Definition: INetwork.hpp:347
armnn::OptimizerOptionsOpaque::SetImportEnabled
void SetImportEnabled(bool ImportState)
Definition: Network.cpp:111
armnn::OptimizerOptionsOpaque
Definition: INetwork.hpp:272