ArmNN
 24.02
Network.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017-2023 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 {
668  return pNetworkImpl->ExecuteStrategy(strategy);
669 }
670 
672 {
673  return new INetwork(networkOptions);
674 }
675 
677 {
678  return INetworkPtr(CreateRaw(networkOptions), &INetwork::Destroy);
679 }
680 
682 {
683  delete network;
684 }
685 
687  : pOptimizedNetworkImpl(new OptimizedNetworkImpl(*other.pOptimizedNetworkImpl.get(), modelOptions)) {}
688 
689 IOptimizedNetwork::IOptimizedNetwork(std::unique_ptr<Graph> graph)
690  : pOptimizedNetworkImpl(new OptimizedNetworkImpl(std::move(graph))) {}
691 
692 IOptimizedNetwork::IOptimizedNetwork(std::unique_ptr<OptimizedNetworkImpl> impl)
693  : pOptimizedNetworkImpl(std::move(impl)) {}
694 
695 IOptimizedNetwork::IOptimizedNetwork(std::unique_ptr<Graph> graph, const ModelOptions& modelOptions)
696  : pOptimizedNetworkImpl(new OptimizedNetworkImpl(std::move(graph), modelOptions)) {}
697 
699 
701 {
702  delete network;
703 }
704 
706 {
707  return pOptimizedNetworkImpl->PrintGraph();
708 }
709 
710 Status IOptimizedNetwork::SerializeToDot(std::ostream& stream) const
711 {
712  return pOptimizedNetworkImpl->SerializeToDot(stream);
713 }
714 
715 const std::shared_ptr<IProfiler>& IOptimizedNetwork::GetProfiler() const
716 {
717  return pOptimizedNetworkImpl->GetGraph().GetProfiler();
718 }
719 
720 arm::pipe::ProfilingGuid IOptimizedNetwork::GetGuid() const
721 {
722  return pOptimizedNetworkImpl->GetGuid();
723 }
724 
726 {
727  return pOptimizedNetworkImpl->GetNumInputs();
728 }
729 
731 {
732  return pOptimizedNetworkImpl->GetNumOutputs();
733 }
734 
736 {
737  m_Graph->Print();
738  return Status::Success;
739 }
740 
741 Status OptimizedNetworkImpl::SerializeToDot(std::ostream& stream) const
742 {
743  return m_Graph->SerializeToDot(stream);
744 }
745 
747 {
748  return m_Graph->GetNumInputs();
749 }
750 
752 {
753  return m_Graph->GetNumOutputs();
754 }
755 
756 void ReportError(const std::string& errorMessage,
757  Optional<std::vector<std::string>&> errorMessages)
758 {
759  std::stringstream fullErrorMessage;
760  fullErrorMessage << "ERROR: " << errorMessage;
761  ARMNN_LOG(warning) << fullErrorMessage.str();
762  if (errorMessages)
763  {
764  errorMessages.value().push_back(fullErrorMessage.str());
765  }
766 }
767 
768 void ReportWarning(const std::string& warningMessage,
769  Optional<std::vector<std::string>&> warningMessages)
770 {
771  std::stringstream fullWarningMessage;
772  fullWarningMessage << "WARNING: " << warningMessage;
773  ARMNN_LOG(warning) << fullWarningMessage.str();
774  if (warningMessages)
775  {
776  warningMessages.value().push_back(fullWarningMessage.str());
777  }
778 }
779 
781  const Layer* layer,
782  const BackendSettings& backendSettings,
783  Optional<std::vector<std::string>&> errMessages)
784 {
785  std::stringstream failureMsg;
786  failureMsg << "Layer of type " << GetLayerTypeAsCString(layer->GetType())
787  << " is not supported on any preferred backend " << backendSettings.m_PreferredBackends;
788  ReportError(failureMsg.str(), errMessages);
789 
790  res.m_Error = true;
791  return res;
792 }
793 
794 
795 bool CheckScaleSetOnQuantizedType(Layer* layer, Optional<std::vector<std::string>&> errMessages)
796 {
797  bool noErrors = true;
798  unsigned int numOutputs = layer->GetNumOutputSlots();
799  for (unsigned int i = 0; i < numOutputs; i++) {
800  OutputSlot& outputSlot = layer->GetOutputSlot(i);
801  TensorInfo info = outputSlot.GetTensorInfo();
802  auto quantizationDataType = info.GetDataType();
803  auto quantizationScales = info.GetQuantizationScales();
804  // For any Quantized Tensor ensure scale(s) are set
805  switch(quantizationDataType) {
806  case DataType::QAsymmU8:
807  case DataType::QSymmS16:
808  case DataType::QSymmS8:
809  case DataType::QAsymmS8:
810  if ((quantizationDataType == DataType::QAsymmU8 || quantizationDataType == DataType::QAsymmS8)
811  && info.HasPerAxisQuantization()) {
812  throw InvalidArgumentException("Per Axis Quantization is not supported in "
813  "Asymmetric Quantization Datatype.");
814  }
815  if ((!info.HasPerAxisQuantization() && info.GetQuantizationScale() == 0.f)
816  || (info.HasPerAxisQuantization() && (quantizationScales.end() !=
817  std::find(quantizationScales.begin(), quantizationScales.end(), 0.f)))) {
818  noErrors = false;
819  std::stringstream ss;
820  ss << "output " << i << " of layer " << GetLayerTypeAsCString(layer->GetType())
821  << " (" << layer->GetNameStr() << ") is of type"
822  << " Quantized value but the scale parameter has not been set";
823  ReportError(ss.str(), errMessages);
824  }
825  // Softmax under QuantisedAsymm8 must always be scale (1.0f/256.0f) and offset 0
826  if (!info.HasPerAxisQuantization() && quantizationDataType == DataType::QAsymmU8 &&
827  (info.GetQuantizationScale() != (1.0f / 256.0f) ||
828  info.GetQuantizationOffset() != 0) &&
829  layer->GetType() == armnn::LayerType::Softmax) {
830  std::stringstream ss;
831  ss << "Quantization parameters for Softmax layer (Scale: " <<
832  info.GetQuantizationScale() << " and Offset: " << info.GetQuantizationOffset() <<
833  ") are incorrect and have been updated to Scale: 0.00390625 and Offset: 0";
834  ARMNN_LOG(warning) << ss.str();
835  info.SetQuantizationScale((1.0f / 256.0f));
836  info.SetQuantizationOffset(0);
837  outputSlot.SetTensorInfo(info);
838  }
839  break;
840  default:
841  break;
842  }
843  }
844  return noErrors;
845 }
846 
848  Graph& graph,
849  Layer* layer,
850  BackendId backend,
851  DataType dataTypeIn,
852  DataType dataTypeOut,
853  const std::vector<BackendId>& availablePreferredBackends,
854  std::string& reasonIfUnsupported,
855  Optional<std::vector<std::string>&> errMessages)
856 {
857  OptimizationResult result;
858 
859  // Helper lambda to compose meaningful error message before returning with error
860  auto ReturnError = [&](const Layer* layer)
861  {
862  return ReturnWithError(result, layer, backendSettings, errMessages);
863  };
864 
865  // need to set the compute device on the layer
866  // before we can check if it is supported
867  layer->SetBackendId(backend);
868  std::string currentReasonIfUnsupported;
869 
870  // To run FP16 operations on CpuAcc we need at least v8.2 architecture. If the available architecture
871  // is older than v8.2, we can check if the operator is supported by changing operator inputs & outputs
872  // to be FP32 and inserting convert layers around the FP32 operator.
873  bool isLayerSupported = IWorkloadFactory::IsLayerSupported(*layer, EmptyOptional(), currentReasonIfUnsupported);
874  reasonIfUnsupported += currentReasonIfUnsupported;
875  // This string matches the error message that is produced by acl when attempting to run FP16 kernels on
876  // a cpu or build that does not have fp16 support. We use this to check if we should add
877  // conversion layers or not.
878  std::string checkStr = "This CPU architecture does not support F16 data type, you need v8.2 or above";
879  if (!isLayerSupported || currentReasonIfUnsupported.find(checkStr) != std::string::npos)
880  {
881  if (dataTypeIn == DataType::Float16 || dataTypeOut == DataType::Float16)
882  {
883  if (IWorkloadFactory::IsLayerSupported(*layer, DataType::Float32, reasonIfUnsupported)
885  && layer->GetType() != LayerType::ConvertFp16ToFp32)
886  {
887  auto ConstantLayerFromFp16ToFp32 = [](Layer& layer)
888  {
889  if (layer.GetType() == LayerType::Constant)
890  {
891  ConstantLayer* constantLayer = PolymorphicDowncast<ConstantLayer*>(&layer);
892 
893  auto& info = constantLayer->m_LayerOutput->GetTensorInfo();
894 
895  if (info.GetDataType() == DataType::Float16)
896  {
897  std::vector<float> newValues(info.GetNumElements());
898 
900  constantLayer->m_LayerOutput->GetConstTensor<Half>(),
901  info.GetNumElements(),
902  newValues.data());
903 
904  TensorInfo newInfo(info);
906  ConstTensor newInput(newInfo, newValues);
907  constantLayer->m_LayerOutput.reset(new ScopedTensorHandle(newInput));
908 
909  layer.GetOutputSlot(0).SetTensorInfo(newInfo);
910  }
911  }
912  };
913 
914  bool checkType = false;
915 
916  for (auto inputSlot : layer->GetInputSlots())
917  {
918  auto connectedOutputSlot = inputSlot.GetConnectedOutputSlot();
919  if (connectedOutputSlot->GetOwningLayer().GetType() == LayerType::Constant)
920  {
921  if (connectedOutputSlot->GetNumConnections() == 1)
922  {
923  checkType = true;
924  ConstantLayerFromFp16ToFp32(connectedOutputSlot->GetOwningLayer());
925  }
926  }
927  }
928 
929  // Insert FP16 -> FP32 conversion layer before current layer
930  std::vector<ConvertFp16ToFp32Layer*> convertFp16ToFp32Layers;
931  if (dataTypeIn == DataType::Float16)
932  {
933  convertFp16ToFp32Layers =
934  InsertConvertFp16ToFp32LayersBefore(graph, *layer, checkType);
935  }
936 
937  // Insert FP32 -> FP16 conversion layer after current layer
938  std::vector<ConvertFp32ToFp16Layer*> convertFp32ToFp16Layers;
939  if (dataTypeOut == DataType::Float16)
940  {
941  convertFp32ToFp16Layers =
942  InsertConvertFp32ToFp16LayersAfter(graph, *layer);
943  }
944 
945  // Assign a supported backend to the newly introduced conversion layers
946  auto AssignFirstSupportedBackend = [&](Layer* layer, BackendId preferredBackend)
947  {
948  bool supportedBackendFound = false;
949  std::string reasonIfUnsupported;
950 
951  // Try preferred backend first
952  layer->SetBackendId(preferredBackend);
954  EmptyOptional(),
955  reasonIfUnsupported))
956  {
957  supportedBackendFound = true;
958  }
959  else
960  {
961  for (const auto& backend : availablePreferredBackends)
962  {
963  // Skip preferred backend (we already determined that it is not supported)
964  if (backend == preferredBackend)
965  {
966  continue;
967  }
968 
969  layer->SetBackendId(backend);
971  EmptyOptional(),
972  reasonIfUnsupported))
973  {
974  supportedBackendFound = true;
975  break;
976  }
977  }
978  }
979 
980  return supportedBackendFound;
981  };
982 
983  for (ConvertFp16ToFp32Layer* convertLayer : convertFp16ToFp32Layers)
984  {
985  if (!AssignFirstSupportedBackend(convertLayer, backend))
986  {
987  return ReturnError(convertLayer);
988  }
989  }
990 
991  for (ConvertFp32ToFp16Layer* convertLayer : convertFp32ToFp16Layers)
992  {
993  if (!AssignFirstSupportedBackend(convertLayer, backend))
994  {
995  return ReturnError(convertLayer);
996  }
997  }
998 
999  return result;
1000  }
1001  }
1002 
1003  std::stringstream warningMsg;
1004  warningMsg << "Layer of type " << GetLayerTypeAsCString(layer->GetType())
1005  << " is not supported on requested backend " << layer->GetBackendId().Get()
1006  << " for input data type " << GetDataTypeName(dataTypeIn)
1007  << " and output data type " << GetDataTypeName(dataTypeOut)
1008  << " (reason: " << reasonIfUnsupported
1009  << "), falling back to the next backend.";
1010  ReportWarning(warningMsg.str(), errMessages);
1011 
1012  return OptimizationResult(true, false);
1013  }
1014  else
1015  {
1016  return result;
1017  }
1018 }
1019 
1020 inline std::vector<DataType> GetLayerInOutDatatype(const Layer* layer)
1021 {
1022  DataType dataTypeIn = layer->GetNumInputSlots() == 0 ? DataType::Float32 :
1024  DataType dataTypeOut = layer->GetNumOutputSlots() == 0 ? DataType::Float32 :
1025  layer->GetOutputSlot(0).GetTensorInfo().GetDataType();
1026  return {dataTypeIn, dataTypeOut};
1027 }
1028 
1030  const std::vector<BackendId>& availablePreferredBackends)
1031 {
1032  bool hasFp16 = false;
1033  // Check if the first preferred backend has FP16 support
1034  auto firstBackend = availablePreferredBackends[0];
1035  auto backendObjPtr = backends.find(firstBackend)->second.get();
1036  ARMNN_ASSERT(backendObjPtr);
1037  auto hasFp16Capability = BackendOptions::BackendOption{"HasFp16", true};
1038  auto backendCapabilities = backendObjPtr->GetCapabilities();
1039 
1040  if (HasMatchingCapability(hasFp16Capability, backendCapabilities))
1041  {
1042  // First preferred backend has FP16 support. Enable reduce FP32 to FP16 when fp16-turbo-mode is enabled.
1043  hasFp16 = true;
1044  ARMNN_LOG(debug) << "The first available preferred backend: " << firstBackend
1045  << ", has FP16 support.";
1046  }
1047  else
1048  {
1049  ARMNN_LOG(warning) << "The first available preferred backend: " << firstBackend
1050  << ", does not have FP16 support. "
1051  << "The FP16 turbo mode option will be disable. It will run using FP32.";
1052  }
1053 
1054  // Check if the rest of the available preferred backends have FP16 support
1055  for (size_t i = 1; i < availablePreferredBackends.size(); ++i)
1056  {
1057  auto backend = availablePreferredBackends[i];
1058  backendObjPtr = backends.find(backend)->second.get();
1059  backendCapabilities = backendObjPtr->GetCapabilities();
1060  if (!HasMatchingCapability(hasFp16Capability, backendCapabilities))
1061  {
1062  ARMNN_LOG(warning) << "Next preferred backend: " << backend << ", does not have FP16 support. "
1063  << "It will run using FP32 when falling back to this backend.";
1064  }
1065  else
1066  {
1067  ARMNN_LOG(debug) << "Next preferred backend: " << backend << ", has FP16 support.";
1068  }
1069  }
1070 
1071  return hasFp16;
1072 }
1073 
1074 // Refactor to allow passing the IConnectableLayer* rather than Layer Iterator
1075 // on Graph and SubgraphView which are different types.
1077  IConnectableLayer* it,
1078  Optional<std::vector<std::string>&> errMessages,
1079  OptimizationResult& result,
1080  BackendSettings& backendSettings,
1081  std::vector<BackendId>& availablePreferredBackends)
1082 {
1083  auto ReturnError = [&](const Layer* layer)
1084  {
1085  return ReturnWithError(result, layer, backendSettings, errMessages);
1086  };
1087 
1088  auto layer = PolymorphicDowncast<Layer*>(it);
1089 
1090  if (layer->GetType() == LayerType::Input)
1091  {
1092  return;
1093  }
1094 
1095  std::vector<DataType> inOutDataType = GetLayerInOutDatatype(layer);
1096 
1097  std::string reasonIfUnsupported;
1098  bool found = false;
1099  if (!CheckScaleSetOnQuantizedType(layer, errMessages))
1100  {
1101  // don't bomb immediately, find all the quantized outputs
1102  // which haven't had a scale set and report them all back.
1103  result.m_Error = true;
1104  }
1105 
1106  // First try assign layer to hint backend
1107  if (layer->GetBackendHint().has_value() &&
1108  backendSettings.IsBackendSupported(layer->GetBackendHint().value()) &&
1109  AttemptBackendAssignment(backendSettings,
1110  optNetObjPtr->GetGraph(),
1111  layer,
1112  layer->GetBackendHint().value(),
1113  inOutDataType[0],
1114  inOutDataType[1],
1115  availablePreferredBackends,
1116  reasonIfUnsupported,
1117  errMessages).IsOk())
1118  {
1119  found = true;
1120  backendSettings.m_SelectedBackends.insert(layer->GetBackendHint().value());
1121  }
1122  else
1123  {
1124  // Try assign layer to prefered list of backends
1125  for (const auto& backend : availablePreferredBackends)
1126  {
1127  if (layer->GetBackendHint().has_value() &&
1128  layer->GetBackendHint().value() == backend)
1129  {
1130  continue; //Don't re-test the backend hint
1131  }
1132 
1133  OptimizationResult res = AttemptBackendAssignment(backendSettings,
1134  optNetObjPtr->GetGraph(),
1135  layer,
1136  backend,
1137  inOutDataType[0],
1138  inOutDataType[1],
1139  availablePreferredBackends,
1140  reasonIfUnsupported,
1141  errMessages);
1142 
1143  if (res.IsOk())
1144  {
1145  found = true;
1146  backendSettings.m_SelectedBackends.insert(backend);
1147  break;
1148  }
1149  else if (res.IsError())
1150  {
1151  result = res; // Cannot continue.
1152  // Note: we don't need to log the error as it would already
1153  // be logged in AttemptBackendAssignment().
1154  }
1155  else
1156  {
1157  ARMNN_ASSERT_MSG(res.IsWarningOnly(), "OptimizationResult in unexpected state.");
1158  }
1159  }
1160  }
1161 
1162  // If the layer is unsupported by any devices, log and return a null network.
1163  if (!found)
1164  {
1165  // NOTE: if the layer is not an operation queue type AND we have not got CpuRef as a
1166  // fallback we should set the compute device on the layer to CpuRef (these are not
1167  // available as accelerated operations, or are only available under certain
1168  // conditions, currently they comprise MemCopy, Constant, Permute)
1169  armnn::LayerType layerType = layer->GetType();
1170  if (!backendSettings.IsCpuRefUsed() && (layerType == armnn::LayerType::MemCopy ||
1171  layerType == armnn::LayerType::Constant ||
1172  layerType == armnn::LayerType::Permute))
1173  {
1174  BackendId cpuBackendId(armnn::Compute::CpuRef);
1175  layer->SetBackendId(cpuBackendId);
1176  backendSettings.m_SelectedBackends.insert(cpuBackendId);
1177  }
1178  else
1179  {
1180  result = ReturnError(layer);
1181  }
1182  }
1183 
1184 }
1185 
1187  BackendSettings& backendSettings,
1188  Graph::Iterator& firstLayer,
1189  Graph::Iterator& lastLayer,
1190  Optional<std::vector<std::string>&> errMessages)
1191 {
1192  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_AssignBackends");
1193  OptimizationResult result;
1194 
1195  auto availablePreferredBackends = backendSettings.GetAvailablePreferredBackends();
1196  if (availablePreferredBackends.empty())
1197  {
1198  std::stringstream failureMsg;
1199  failureMsg << "No preferred backends are available";
1200  ReportError(failureMsg.str(), errMessages);
1201 
1202  result.m_Error = true;
1203  return result;
1204  }
1205 
1206  for (auto it = firstLayer; it != lastLayer; ++it)
1207  {
1208  auto layer = PolymorphicDowncast<Layer*>(*it);
1209  std::vector<DataType> inOutDataType = GetLayerInOutDatatype(layer);
1210 
1211  // In AttemptBackendAssignment() we check:
1212  // - if input/output datatypes of the layer are float16
1213  // - if the layer is supported with these datatypes
1214  // If the layer is not supported (failing on ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED() in clframework),
1215  // we attempt to insert convertion layers either side of the new fp32 layer.
1216  bool isFloat16 = false;
1217  for (auto type : inOutDataType)
1218  {
1219  if (type == DataType::Float16)
1220  {
1221  isFloat16 = true;
1222  break;
1223  }
1224  }
1225 
1226  if (layer->GetBackendId() == "Unknown" || isFloat16)
1227  {
1228  AssignBackendsIConnectable(optNetObjPtr,
1229  *it,
1230  errMessages,
1231  result,
1232  backendSettings,
1233  availablePreferredBackends);
1234  }
1235  }
1236 
1237  for (auto it = firstLayer; it != lastLayer; ++it)
1238  {
1239  auto layer = PolymorphicDowncast<Layer*>(*it);
1240 
1241  if(layer->GetType() == LayerType::Input)
1242  {
1243  BackendId connectedBackendId = layer->GetOutputSlot(0).GetConnection(0)->GetOwningLayer().GetBackendId();
1244  layer->SetBackendId(connectedBackendId);
1245  }
1246  }
1247 
1248  return result;
1249 }
1250 
1252  BackendSettings& backendSettings,
1255  Optional<std::vector<std::string>&> errMessages)
1256 {
1257  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_AssignBackends");
1258  OptimizationResult result;
1259 
1260  auto availablePreferredBackends = backendSettings.GetAvailablePreferredBackends();
1261  if (availablePreferredBackends.empty())
1262  {
1263  std::stringstream failureMsg;
1264  failureMsg << "No preferred backends are available";
1265  ReportError(failureMsg.str(), errMessages);
1266 
1267  result.m_Error = true;
1268  return result;
1269  }
1270 
1271  for (auto it = firstLayer; it != lastLayer; ++it)
1272  {
1273  AssignBackendsIConnectable(optNetObjPtr,
1274  *it,
1275  errMessages,
1276  result,
1277  backendSettings,
1278  availablePreferredBackends);
1279  }
1280 
1281  for (auto it = firstLayer; it != lastLayer; ++it)
1282  {
1283  auto layer = PolymorphicDowncast<Layer*>(*it);
1284 
1285  if(layer->GetType() == LayerType::Input)
1286  {
1287  BackendId connectedBackendId = layer->GetOutputSlot(0).GetConnection(0)->GetOwningLayer().GetBackendId();
1288  layer->SetBackendId(connectedBackendId);
1289  }
1290  }
1291 
1292  return result;
1293 }
1294 
1296  BackendSettings& backendSettings,
1297  SubgraphView& subgraph,
1298  Optional<std::vector<std::string>&> errMessages)
1299 {
1300  SubgraphView::IConnectableLayerIterator firstLayer = subgraph.begin();
1301  SubgraphView::IConnectableLayerIterator lastLayer = subgraph.end();
1302  return AssignBackends(optNetObjPtr,
1303  backendSettings,
1304  firstLayer,
1305  lastLayer,
1306  errMessages);
1307 }
1308 
1310  BackendSettings& backendSettings)
1311 {
1312  BackendsMap backends;
1313  auto const& backendRegistry = BackendRegistryInstance();
1314  for (auto&& selectedBackend : backendSettings.m_SupportedBackends)
1315  {
1316  auto backendFactory = backendRegistry.GetFactory(selectedBackend);
1317  auto backendObjPtr = backendFactory();
1318  ARMNN_ASSERT(backendObjPtr);
1319 
1320  backendObjPtr->RegisterTensorHandleFactories(handleFactoryRegistry);
1321 
1322  backends[backendObjPtr->GetId()] = std::move(backendObjPtr);
1323  }
1324 
1325  return backends;
1326 }
1327 
1329  BackendSettings& backendSettings,
1330  BackendsMap& backends,
1331  const ModelOptions& modelOptions,
1332  Optional<std::vector<std::string>&> errMessages)
1333 {
1334  ARMNN_ASSERT(optNetObjPtr);
1335  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_ApplyBackendOptimizations")
1336  OptimizationResult result;
1337 
1338  // Get the optimized graph
1339  Graph& optGraph = optNetObjPtr->GetGraph();
1340 
1341  // Run backend specific optimizations
1342  for (auto&& selectedBackend : backendSettings.m_SelectedBackends)
1343  {
1344  auto backendObjPtr = backends.find(selectedBackend)->second.get();
1345  ARMNN_ASSERT(backendObjPtr);
1346 
1347  if (selectedBackend == armnn::Compute::GpuAcc || selectedBackend == armnn::Compute::CpuAcc)
1348  {
1351  }
1352 
1353  // Select sub-graphs based on backend
1356  // Select layers assigned to the requested backend
1357  [&backendObjPtr](const Layer& layer)
1358  {
1359 
1360  return layer.GetType() != LayerType::Input &&
1361  layer.GetType() != LayerType::Output &&
1362  layer.GetBackendId() == backendObjPtr->GetId();
1363  });
1364  if (subgraphs.empty())
1365  {
1366  // No sub-graphs found, try with next selected backend
1367  continue;
1368  }
1369 
1370  // Try to optimize each sub-graph
1371  for (auto& subgraph : subgraphs)
1372  {
1373  // Try to optimize the current sub-graph
1374  ARMNN_SCOPED_PROFILING_EVENT(backendObjPtr->GetId(), "Optimizer_OptimizeSubgraph");
1375  OptimizationViews optimizationViews = backendObjPtr->OptimizeSubgraphView(*subgraph, modelOptions);
1376  ARMNN_ASSERT(optimizationViews.Validate(*subgraph));
1377 
1378  // Optimization attempted, check the resulting optimized sub-graph
1379  for (auto& substitution : optimizationViews.GetSubstitutions())
1380  {
1381  // Sub-graph optimized, substitute the sub-graph with the new optimized one in the main optimized graph
1382  SubgraphView& replacementSubgraph = substitution.m_ReplacementSubgraph;
1383  SubgraphView& substitutableSubgraph = substitution.m_SubstitutableSubgraph;
1384  optGraph.SubstituteSubgraph(substitutableSubgraph, replacementSubgraph);
1385 
1386  // Assign the current backend to the optimized sub-graph
1387  const SubgraphView::IConnectableLayers& subgraphLayers = replacementSubgraph.GetIConnectableLayers();
1388  std::for_each(subgraphLayers.begin(), subgraphLayers.end(), [&selectedBackend](IConnectableLayer* l)
1389  {
1390  ARMNN_ASSERT(l);
1391  PolymorphicDowncast<Layer*>(l)->SetBackendId(selectedBackend);
1392  });
1393  }
1394 
1395  // Remove deleted sub-graphs
1396  for (auto& deletedSubgraph : optimizationViews.GetDeletedSubgraphs())
1397  {
1398  for (auto& l : deletedSubgraph.GetIConnectableLayers())
1399  {
1400  Layer* deletedLayer = PolymorphicDowncast<Layer*>(l);
1401  for (unsigned int in = deletedLayer->GetNumInputSlots(); in > 0; --in)
1402  {
1403  auto inputSlot = deletedLayer->GetInputSlot(in -1);
1404  OutputSlot* parentOut = inputSlot.GetConnectedOutputSlot();
1405  parentOut->Disconnect(inputSlot);
1406  for (unsigned int out = deletedLayer->GetOutputSlot(in -1).GetNumConnections(); out > 0; --out)
1407  {
1408  InputSlot* childIn = deletedLayer->GetOutputSlot(in - 1).GetConnection(out -1);
1409  deletedLayer->GetOutputSlot(in - 1).Disconnect(*childIn);
1410  parentOut->Connect(*childIn);
1411  }
1412  }
1413  optGraph.EraseLayer(deletedLayer);
1414  }
1415  }
1416 
1417  if (!optimizationViews.GetFailedSubgraphs().empty())
1418  {
1419  std::stringstream warningMsg;
1420  warningMsg << "Some sub-graph(s) failed to optimized on " << backendObjPtr->GetId() << " backend.";
1421  ReportWarning(warningMsg.str(), errMessages);
1422 
1423  // Failed to optimize the given sub-graph, re-assign the sub-graph layers to other available backends
1424  BackendSettings settingsCopy(backendSettings);
1425  if (!backendObjPtr->GetId().IsCpuRef())
1426  {
1427  // Add the current backend to the list of backends to ignore
1428  settingsCopy.m_IgnoredBackends.insert(backendObjPtr->GetId());
1429  }
1430 
1431  int count=0;
1432  for (auto& failedSubgraph : optimizationViews.GetFailedSubgraphs())
1433  {
1434  // An error occurred: the optimization was attempted but not performed, try different backends
1435  std::stringstream subgraphMsg;
1436  subgraphMsg << "Re-assigning backends to " << failedSubgraph.GetIConnectableLayers().size()
1437  << " layers inside sub-graph " << count++;
1438  ReportWarning(subgraphMsg.str(), errMessages);
1439 
1440  OptimizationResult reassignmentResult = AssignBackends(optNetObjPtr,
1441  settingsCopy,
1442  *subgraph,
1443  errMessages);
1444  if (reassignmentResult.m_Error)
1445  {
1446  // Failed to re-assign one of the remaining backends to each layer of the sub-graph
1447  result.m_Error = true;
1448  return result;
1449  }
1450  }
1451  }
1452  }
1453  }
1454 
1455  return result;
1456 }
1457 
1460  TensorHandleFactoryRegistry& registry)
1461 {
1462  if (src != dst)
1463  {
1464  ITensorHandleFactory* srcFactory = registry.GetFactory(src);
1465  ITensorHandleFactory* dstFactory = registry.GetFactory(dst);
1466 
1467  if (srcFactory && dstFactory &&
1468  (srcFactory->GetExportFlags() & dstFactory->GetImportFlags()) != 0)
1469  {
1470  return false;
1471  }
1472  return true;
1473  }
1474  return false;
1475 }
1476 
1477 // Find the handle factory for the input layer which results in fewest required copies.
1479  OutputSlot& slot,
1480  TensorHandleFactoryRegistry& registry,
1481  bool importEnabled)
1482 {
1483  Layer& layer = slot.GetOwningLayer();
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  ARMNN_ASSERT_MSG(toBackend != backends.end(), "Backend id not found for the connected layer");
1512 
1513  if (!toBackend->second.get()->SupportsTensorAllocatorAPI())
1514  {
1515  // The destination backend does not support the tensor allocator API, move to the next one
1516  continue;
1517  }
1518 
1519  auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
1520  for (auto&& dst : dstPrefs)
1521  {
1522  // Input layers use the mem copy workload or import, so the selected factory must
1523  // support either the map/unmap API or Import API
1524  ITensorHandleFactory* factory = registry.GetFactory(dst);
1525  if (importEnabled && factory->GetImportFlags() == 0)
1526  {
1527  continue;
1528  }
1529  else if (!importEnabled && !factory->SupportsMapUnmap())
1530  {
1531  continue;
1532  }
1533 
1534  auto it = factoryScores.find(dst);
1535  if (it == factoryScores.end())
1536  {
1537  // Add new score to the table
1538  factoryScores[dst] = 0;
1539  if (topChoice == ITensorHandleFactory::LegacyFactoryId)
1540  {
1541  topChoice = dst;
1542  }
1543  }
1544  else
1545  {
1546  // Increase the score
1547  factoryScores[dst]++;
1548 
1549  // Track the best option
1550  if (factoryScores[dst] > topScore)
1551  {
1552  topScore = factoryScores[dst];
1553  topChoice = dst;
1554  }
1555  }
1556  }
1557  }
1558 
1559  return topChoice;
1560 }
1561 
1562 // Find the handle factory for the output layer which results in fewest required copies.
1564  OutputSlot& slot,
1565  TensorHandleFactoryRegistry& registry)
1566 {
1567  IgnoreUnused(backends, slot, registry);
1569 }
1570 
1571 // For all handle factories supported on the source backend, we wish to find the one which requires the fewest copies
1572 // when considering all connections.
1574  OutputSlot& outputSlot,
1575  TensorHandleFactoryRegistry& registry,
1576  bool exportEnabled)
1577 {
1578  // First ensure the from backends can support the TensorHandeAPI
1579  Layer& layer = outputSlot.GetOwningLayer();
1580  auto frmBackend = backends.find(layer.GetBackendId());
1581  if (frmBackend == backends.end() ||
1582  !frmBackend->second->SupportsTensorAllocatorAPI())
1583  {
1585  }
1586 
1587  bool outputConnection = false;
1588  for (auto&& connection : outputSlot.GetConnections())
1589  {
1590  const Layer& connectedLayer = connection->GetOwningLayer();
1591  if (connectedLayer.GetType() == LayerType::Output)
1592  {
1593  outputConnection = true;
1594  }
1595  }
1596 
1597  IBackendInternal* srcBackend = frmBackend->second.get();
1598  auto srcPrefs = srcBackend->GetHandleFactoryPreferences();
1599 
1600  // Initialize the scores
1601  std::map<ITensorHandleFactory::FactoryId, int> factoryScores;
1602  for (auto&& pref : srcPrefs)
1603  {
1604  if (exportEnabled)
1605  {
1606  ITensorHandleFactory* factory = registry.GetFactory(pref);
1607  if (outputConnection)
1608  {
1609  // Check if this is fallback case
1610  bool fallbackConnection = false;
1611  for (auto&& inputSlot : layer.GetInputSlots())
1612  {
1613  if (inputSlot.GetConnectedOutputSlot()->GetOwningLayer().GetBackendId() != layer.GetBackendId())
1614  {
1615  fallbackConnection = true;
1616  }
1617  }
1618  if (fallbackConnection)
1619  {
1620  auto factoryCap = factory->GetCapabilities(&layer, &layer, CapabilityClass::FallbackImportDisabled);
1621  // Cannot use factory import if fallback import is not supported.
1622  if (!factoryCap.empty())
1623  {
1624  continue;
1625  }
1626  }
1627  else if (factory->GetExportFlags() == 0)
1628  {
1629  continue;
1630  }
1631  }
1632  if (!outputConnection)
1633  {
1634  auto factoryCap = factory->GetCapabilities(&layer, &layer, CapabilityClass::FallbackImportDisabled);
1635  // Cannot use factory import if fallback import is not supported.
1636  if (!factoryCap.empty())
1637  {
1638  continue;
1639  }
1640  }
1641 
1642  }
1643  else
1644  {
1645  // Only consider factories that support map/unmap
1646  ITensorHandleFactory* factory = registry.GetFactory(pref);
1647  if (!factory->SupportsMapUnmap())
1648  {
1649  // The current tensor handle factory does not support the map/unmap strategy, move to the next one
1650  continue;
1651  }
1652  }
1653 
1654 
1655  auto it = factoryScores.find(pref);
1656  if (it == factoryScores.end())
1657  {
1658  // Add new score to the table
1659  factoryScores[pref] = 0;
1660  }
1661  }
1662 
1663  // Score each handle factory based on how many times it requires copies on the slot connections
1664  for (auto&& connection : outputSlot.GetConnections())
1665  {
1666  const Layer& connectedLayer = connection->GetOwningLayer();
1667 
1668  auto toBackend = backends.find(connectedLayer.GetBackendId());
1669  ARMNN_ASSERT_MSG(toBackend != backends.end(), "Backend id not found for the connected layer");
1670 
1671  auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
1672  for (auto&& src : srcPrefs)
1673  {
1674  if (factoryScores.find(src) == factoryScores.end()) // Don't consider excluded factories
1675  {
1676  continue;
1677  }
1678 
1679  for (auto&& dst : dstPrefs)
1680  {
1681  if (RequiresCopy(src, dst, registry))
1682  {
1683  // Copy avoided, increase the score
1684  factoryScores[src]++;
1685  break;
1686  }
1687  }
1688  }
1689  }
1690 
1691  // Find the lowest score
1692  int minScore = std::numeric_limits<int>::max();
1693  for (auto it : factoryScores)
1694  {
1695  minScore = std::min(minScore, it.second);
1696  }
1697 
1698  // Collect factories matching the best(lowest) score
1699  std::vector<ITensorHandleFactory::FactoryId> optimalFactories;
1700  for (auto it : factoryScores)
1701  {
1702  if (it.second == minScore)
1703  {
1704  optimalFactories.push_back(it.first);
1705  }
1706  }
1707 
1708  // For all compatible Factories matching the best score, find the preferred one for the current layer.
1709  for (auto&& srcPref : srcPrefs)
1710  {
1711  for (auto&& comp : optimalFactories)
1712  {
1713  if (comp == srcPref)
1714  {
1715  return comp;
1716  }
1717  }
1718  }
1719 
1721 }
1722 
1724  ITensorHandleFactory::FactoryId srcFactoryId,
1725  const Layer& layer,
1726  const Layer& connectedLayer,
1727  TensorHandleFactoryRegistry& registry,
1728  bool importEnabled)
1729 {
1730  auto toBackend = backends.find(connectedLayer.GetBackendId());
1731  ARMNN_ASSERT_MSG(toBackend != backends.end(), "Backend id not found for the connected layer");
1732 
1733  auto dstPrefs = toBackend->second.get()->GetHandleFactoryPreferences();
1734 
1735  // Legacy API check for backward compatibility
1736  if (srcFactoryId == ITensorHandleFactory::LegacyFactoryId || dstPrefs.empty())
1737  {
1738  if (layer.GetBackendId() != connectedLayer.GetBackendId())
1739  {
1741  }
1742  else
1743  {
1745  }
1746  }
1747 
1748  // TensorHandleFactory API present, so perform more sophisticated strategies.
1749  // Dst Output layers don't require copy because they use import or map/unmap
1750  if (connectedLayer.GetType() == LayerType::Output)
1751  {
1753  }
1754 
1755  // Search for direct match in prefs
1756  for (auto&& pref : dstPrefs)
1757  {
1758  if (pref == srcFactoryId)
1759  {
1761  }
1762  }
1763 
1764  // Search for export/import options
1765  ITensorHandleFactory* srcFactory = registry.GetFactory(srcFactoryId);
1766  if (srcFactory->GetExportFlags() != 0 && importEnabled)
1767  {
1768  for (auto&& pref : dstPrefs)
1769  {
1770  ITensorHandleFactory* dstFactory = registry.GetFactory(pref);
1771 
1772  // Handles cases when a destPref is not listed in TensorHandleFactoryRegistry
1773  if (!dstFactory) {
1774  continue;
1775  }
1776  if ((dstFactory->GetImportFlags() & srcFactory->GetExportFlags()) != 0)
1777  {
1778  auto srcCapability = srcFactory->GetCapabilities(&layer, &layer, CapabilityClass::PaddingRequired);
1779  auto dstCapability = dstFactory->GetCapabilities(&connectedLayer,
1780  &connectedLayer,
1782  auto srcFallback = srcFactory->GetCapabilities(&layer, &layer, CapabilityClass::FallbackImportDisabled);
1783  auto dstFallback = dstFactory->GetCapabilities(&connectedLayer,
1784  &connectedLayer,
1786  // Do not require memory copy if the source and destination do not require padding.
1787  if (srcCapability.empty() && dstCapability.empty() && srcFallback.empty() && dstFallback.empty())
1788  {
1790  }
1791  }
1792  }
1793  }
1794 
1795  // Search for copy options via map/unmap
1796  if (srcFactory->SupportsMapUnmap())
1797  {
1798  for (auto&& pref : dstPrefs)
1799  {
1800  ITensorHandleFactory* dstFactory = registry.GetFactory(pref);
1801  if (dstFactory && dstFactory->SupportsMapUnmap())
1802  {
1804  }
1805  }
1806  }
1807 
1808  return EdgeStrategy::Undefined;
1809 }
1810 
1811 // Select the TensorHandleFactories and the corresponding memory strategy
1813  BackendsMap& backends,
1814  TensorHandleFactoryRegistry& registry,
1815  bool importEnabled,
1816  bool exportEnabled,
1817  Optional<std::vector<std::string>&> errMessages)
1818 {
1819  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_SelectTensorHandleStrategy");
1820  OptimizationResult result;
1821 
1822  optGraph.ForEachLayer([&backends, &registry, &result, &errMessages, importEnabled, exportEnabled](Layer* layer)
1823  {
1824  ARMNN_ASSERT(layer);
1825 
1826  // Lets make sure the backend is in our list of supported backends. Something went wrong during backend
1827  // assignment if this check fails
1828  ARMNN_ASSERT(backends.find(layer->GetBackendId()) != backends.end());
1829 
1830  // Check each output separately
1831  for (unsigned int slotIdx = 0; slotIdx < layer->GetNumOutputSlots(); slotIdx++)
1832  {
1833  OutputSlot& outputSlot = layer->GetOutputSlot(slotIdx);
1834 
1836 
1837  // Calculate the factory to use which results in the fewest copies being made.
1838  switch(layer->GetType())
1839  {
1840  case LayerType::Input:
1841  slotOption = CalculateSlotOptionForInput(backends, outputSlot, registry, importEnabled);
1842  break;
1843  case LayerType::Output:
1844  slotOption = CalculateSlotOptionForOutput(backends, outputSlot, registry);
1845  break;
1846  default:
1847  slotOption = CalculateSlotOption(backends, outputSlot, registry, exportEnabled);
1848  break;
1849  }
1850  outputSlot.SetTensorHandleFactory(slotOption);
1851 
1852  // Now determine the "best" edge strategy for each connection given the slotOption.
1853  unsigned int connectionIdx = 0;
1854  for (auto&& connection : outputSlot.GetConnections())
1855  {
1856  const Layer& connectedLayer = connection->GetOwningLayer();
1857 
1858  EdgeStrategy strategy = CalculateEdgeStrategy(backends, slotOption, *layer, connectedLayer,
1859  registry, importEnabled);
1860 
1861  if (strategy == EdgeStrategy::Undefined)
1862  {
1863  result.m_Error = true;
1864  if (errMessages)
1865  {
1866  errMessages.value().emplace_back("Could not find valid strategy required for compatibility"
1867  " between backends.");
1868  }
1869  return;
1870  }
1871 
1872  outputSlot.SetEdgeStrategy(connectionIdx, strategy);
1873 
1874  connectionIdx++;
1875  }
1876  }
1877  });
1878 
1879  return result;
1880 }
1881 
1882 // Forwarding function to remain backward compatible with legacy OptimizerOptions
1884  const std::vector<BackendId>& backendPreferences,
1885  const IDeviceSpec& deviceSpec,
1886  const OptimizerOptions& options,
1887  Optional<std::vector<std::string>&> messages)
1888 {
1889  return Optimize(inGraph,
1890  backendPreferences,
1891  deviceSpec,
1892  OptimizerOptionsOpaque(options),
1893  messages);
1894 }
1895 
1897  const std::vector<BackendId>& backendPreferences,
1898  const IDeviceSpec& deviceSpec,
1899  const OptimizerOptionsOpaque& options,
1900  Optional<std::vector<std::string>&> messages)
1901 {
1902  ARMNN_LOG(debug) << options.ToString();
1903 
1904  // Enable profiling
1905  auto profiler = inGraph.GetProfiler();
1907  profiler->EnableProfiling(options.GetProfilingEnabled());
1908 
1909  // Some backends don't play well together. Check here before continuing.
1910  {
1911  std::set<BackendId> backendSet(backendPreferences.begin(), backendPreferences.end());
1912  // GpuFsa cannot co-exist with GpuAcc.
1913  if (backendSet.find("GpuFsa") != backendSet.end() &&
1914  backendSet.find("GpuAcc") != backendSet.end())
1915  {
1916  throw InvalidArgumentException("The backends \"GpuAcc\" and \"GpuFsa\" cannot be specified "
1917  "for the same optimized network.");
1918  }
1919  }
1920 
1922  if (backendPreferences.empty())
1923  {
1924  throw InvalidArgumentException("Invoked Optimize with no backends specified");
1925  }
1926 
1927  if (options.GetReduceFp32ToBf16())
1928  {
1929  throw InvalidArgumentException("BFloat16 optimization is currently ignored. In order to use Bf16 optimization "
1930  "Please use the FastMathEnabled backend option for CpuAcc or GpuAcc.");
1931  }
1932 
1933  if (options.GetReduceFp32ToFp16() && options.GetReduceFp32ToBf16())
1934  {
1935  throw InvalidArgumentException("BFloat16 and Float16 optimization cannot be enabled at the same time.");
1936  }
1937 
1938  // Ensure TensorInfo is set on all output slots of ConstantLayers in the graph
1940 
1941  std::unique_ptr<Graph> graph = std::make_unique<Graph>(inGraph);
1942 
1943  // We need to pass on the information about whether import and export is enabled to the LoadNetwork phase.
1944  // The mechanism to do that is to add model options to the optimized network.
1945  armnn::BackendOptions importExport("Global",
1946  {{"ImportEnabled", options.GetImportEnabled()},
1947  {"ExportEnabled", options.GetExportEnabled()}});
1948  ModelOptions optimizedOptions(options.GetModelOptions());
1949  optimizedOptions.push_back(importExport);
1950 
1951  auto optNet = IOptimizedNetworkPtr(new IOptimizedNetwork(std::move(graph), optimizedOptions),
1953 
1954  IOptimizedNetwork* optNetObjPtr = optNet.get();
1955 
1956  // Get the optimized graph
1957  Graph& optGraph = optNetObjPtr->pOptimizedNetworkImpl->GetGraph();
1958 
1960  {
1961  // Infer the tensor infos for all output slots. Throws an exception on failure
1962  optGraph.InferTensorInfos();
1963  }
1964 
1965  // Perform BroadcastToOptimizationLayer and then AddBroadcastReshapeLayer optimisation
1966  using namespace optimizations;
1968 
1970 
1972  {
1973  // Validate the tensor infos for all output slots. Throws an exception on failure
1974  optGraph.InferTensorInfos();
1975  }
1976 
1977 
1978  // Group Constant Layer optimizations together where possible.
1979  // This is important as:
1980  // FusePermuteIntoConstantLayer must happen before FoldPadIntoDepthwiseConvolution2d and
1981  // FuseBatchNormIntoDepthwiseConvolution2D.
1982  // ConvertConstDequantisationLayersToConstLayers must happen before FoldPadIntoConvolution2d
1985  // Perform optimisation passes
1991  MovePermuteUp(),
1992  MoveTransposeUp(),
1993  PermuteAsReshape(),
2006 
2007  // Initialize backend settings
2008  BackendSettings backendSettings(backendPreferences, deviceSpec);
2009  auto availablePreferredBackends = backendSettings.GetAvailablePreferredBackends();
2010  if (availablePreferredBackends.empty())
2011  {
2012  std::stringstream failureMsg;
2013  failureMsg << "None of the preferred backends " << backendPreferences
2014  << " are supported. Current platform provides " << backendSettings.m_SupportedBackends;
2015  ReportError(failureMsg.str(), messages);
2016  throw InvalidArgumentException(failureMsg.str());
2017  }
2018 
2019  // Create a map to temporarily hold initialized backend objects
2020  TensorHandleFactoryRegistry tensorHandleFactoryRegistry;
2021  BackendsMap backends = CreateSupportedBackends(tensorHandleFactoryRegistry, backendSettings);
2022 
2023  if (options.GetReduceFp32ToFp16())
2024  {
2025  bool hasFp16 = CheckFp16Support(backends, availablePreferredBackends);
2026  if (hasFp16)
2027  {
2028  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_ReduceFp32ToFp16");
2031  }
2032  }
2033 
2034  // Assign an available backend to each layer
2035  Graph::Iterator firstLayer = optGraph.begin();
2036  Graph::Iterator lastLayer = optGraph.end();
2037  OptimizationResult assignBackendsResult = AssignBackends(optNetObjPtr->pOptimizedNetworkImpl.get(),
2038  backendSettings,
2039  firstLayer,
2040  lastLayer,
2041  messages);
2042  if (assignBackendsResult.m_Error)
2043  {
2044  // Failed to assign a backend to each layer
2045  throw InvalidArgumentException("Failed to assign a backend to each layer");
2046  }
2047 
2050 
2051  // Apply the backend-specific optimizations
2052  OptimizationResult backendOptimizationResult = ApplyBackendOptimizations(optNetObjPtr->pOptimizedNetworkImpl.get(),
2053  backendSettings,
2054  backends,
2055  options.GetModelOptions(),
2056  messages);
2057  if (backendOptimizationResult.m_Error)
2058  {
2059  // Failed to apply the backend-specific optimizations
2060  throw InvalidArgumentException("Failed to apply the backend-specific optimizations");
2061  }
2062 
2063  // Convert constants
2064  {
2065  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_ConvertConstants");
2068  }
2069 
2070  // This must occur after all topological changes to the graph and any redirection of variables
2071  // If the debug flag is set, then insert a DebugLayer after each layer
2072  // Doing this after applying the backend optimizations as they might have changed some layers
2073  if (options.GetDebugEnabled() && !options.GetDebugToFileEnabled())
2074  {
2076  }
2077  else if (options.GetDebugToFileEnabled())
2078  {
2079  // Setup the output file path
2080  try
2081  {
2082 #if !defined(ARMNN_DISABLE_FILESYSTEM)
2083  auto result = armnnUtils::Filesystem::CreateDirectory("/ArmNNIntermediateLayerOutputs");
2084  ARMNN_LOG(info) << "Intermediate tensors will be written to: " << result;
2085 #endif
2087  }
2088  catch (const armnn::RuntimeException& e)
2089  {
2090  // If we cannot create the output directory then we'll issue a warning and continue.
2091  ARMNN_LOG(warning) << "Unable to print intermediate layer outputs : " << e.what();
2092  }
2093  }
2094 
2095  // Calculate the compatibility strategies for tensor handles
2096  OptimizationResult strategyResult = SelectTensorHandleStrategy(optGraph,
2097  backends,
2098  tensorHandleFactoryRegistry,
2099  options.GetImportEnabled(),
2100  options.GetExportEnabled(),
2101  messages);
2102 
2103  if (strategyResult.m_Error)
2104  {
2105  // Failed to apply the backend-specific optimizations
2107  }
2108 
2109  // Based on the tensor handle strategy determined above, insert copy layers where required.
2110  {
2111  ARMNN_SCOPED_PROFILING_EVENT(Compute::Undefined, "Optimizer_AddCompatibilityLayers");
2112  optGraph.AddCompatibilityLayers(backends, tensorHandleFactoryRegistry);
2113  }
2114 
2115  return optNet;
2116 }
2117 
2118 // Forwarding function to remain backward compatible with legacy OptimizerOptions
2120  const std::vector<BackendId>& backendPreferences,
2121  const IDeviceSpec& deviceSpec,
2122  const OptimizerOptions& options,
2123  Optional<std::vector<std::string>&> messages)
2124 {
2125  return Optimize(inNetwork,
2126  backendPreferences,
2127  deviceSpec,
2128  OptimizerOptionsOpaque(options),
2129  messages);
2130 }
2131 
2133  const std::vector<BackendId>& backendPreferences,
2134  const IDeviceSpec& deviceSpec,
2135  const OptimizerOptionsOpaque& options,
2136  Optional<std::vector<std::string>&> messages)
2137 {
2138  return Optimize(inNetwork.pNetworkImpl->GetGraph(),
2139  backendPreferences,
2140  deviceSpec,
2141  options,
2142  messages);
2143 }
2144 
2145 bool NetworkImpl::GetShapeInferenceMethod()
2146 {
2147  bool shapeInferenceMethod = false;
2148 
2149  ParseOptions(m_NetworkOptions, "ShapeInferenceMethod", [&](std::string name, const BackendOptions::Var& value)
2150  {
2151  if (name == "InferAndValidate")
2152  {
2153  shapeInferenceMethod |= value.AsBool();
2154  }
2155  });
2156  return shapeInferenceMethod;
2157 }
2158 
2159 bool NetworkImpl::GetAllowExpandedDims()
2160 {
2161  bool allowExpandedDims = false;
2162 
2163  ParseOptions(m_NetworkOptions, "AllowExpandedDims", [&](std::string name, const BackendOptions::Var& value)
2164  {
2165  if (name == "AllowExpandedDims")
2166  {
2167  allowExpandedDims |= value.AsBool();
2168  }
2169  });
2170  return allowExpandedDims;
2171 }
2172 
2174 : m_NetworkOptions(networkOptions),
2175  m_Graph(std::make_unique<Graph>(GetShapeInferenceMethod(), GetAllowExpandedDims()))
2176 {}
2177 
2179 {
2180 }
2181 
2183 {
2184  m_Graph->Print();
2185  return Status::Success;
2186 }
2187 
2189 {
2190  return m_Graph->AddLayer<InputLayer>(id, name);
2191 }
2192 
2194  const char* name)
2195 {
2196  return m_Graph->AddLayer<BatchToSpaceNdLayer>(batchToSpaceNdDescriptor, name);
2197 }
2198 
2200 {
2201  return m_Graph->AddLayer<CastLayer>(name);
2202 }
2204  const char* name)
2205 {
2206  return m_Graph->AddLayer<ChannelShuffleLayer>(channelShuffleDescriptor, name);
2207 }
2208 
2210  const char* name)
2211 {
2212  return m_Graph->AddLayer<ComparisonLayer>(comparisonDescriptor, name);
2213 }
2214 
2216  const char* name)
2217 {
2218  return m_Graph->AddLayer<ElementwiseBinaryLayer>(elementwiseBinaryDesc, name);
2219 }
2220 
2222  const char* name)
2223 {
2224  return m_Graph->AddLayer<ElementwiseUnaryLayer>(elementwiseUnaryDescriptor, name);
2225 }
2226 
2228  const char* name)
2229 {
2230  return m_Graph->AddLayer<FillLayer>(fillDescriptor, name);
2231 }
2232 
2234  const char* name)
2235 {
2236  return m_Graph->AddLayer<FullyConnectedLayer>(fullyConnectedDescriptor, name);
2237 }
2238 
2240  const char* name)
2241 {
2242  return m_Graph->AddLayer<FusedLayer>(fusedDescriptor, name);
2243 }
2244 
2246  const char* name)
2247 {
2248  return m_Graph->AddLayer<ConcatLayer>(concatDescriptor, name);
2249 }
2250 
2252  const char* name)
2253 {
2254  return m_Graph->AddLayer<Convolution2dLayer>(convolution2dDescriptor, name);
2255 }
2256 
2258 {
2259  return m_Graph->AddLayer<ConvertFp16ToFp32Layer>(name);
2260 }
2261 
2263 {
2264  return m_Graph->AddLayer<ConvertFp32ToFp16Layer>(name);
2265 }
2266 
2268  const char* name)
2269 {
2270  return m_Graph->AddLayer<Convolution3dLayer>(convolution3dDescriptor, name);
2271 }
2272 
2274  const char* name)
2275 {
2276  return m_Graph->AddLayer<DepthToSpaceLayer>(depthToSpaceDescriptor, name);
2277 }
2278 
2280  const DepthwiseConvolution2dDescriptor& convolution2dDescriptor,
2281  const char* name)
2282 {
2283  return m_Graph->AddLayer<DepthwiseConvolution2dLayer>(convolution2dDescriptor, name);
2284 }
2285 
2287  const ConstTensor& anchors, const char* name)
2288 {
2289  const auto layer = m_Graph->AddLayer<DetectionPostProcessLayer>(descriptor, name);
2290 
2291  layer->m_Anchors = std::make_shared<ScopedTensorHandle>(anchors);
2292 
2293  return layer;
2294 }
2295 
2297  const char* name)
2298 {
2299  return m_Graph->AddLayer<PermuteLayer>(permuteDescriptor, name);
2300 }
2301 
2303  const char* name)
2304 {
2305  return m_Graph->AddLayer<Pooling2dLayer>(pooling2dDescriptor, name);
2306 }
2307 
2309  const char* name)
2310 {
2311  return m_Graph->AddLayer<Pooling3dLayer>(pooling3dDescriptor, name);
2312 }
2313 
2315  const char* name)
2316 {
2317  return m_Graph->AddLayer<ActivationLayer>(activationDescriptor, name);
2318 }
2319 
2321  const char* name)
2322 {
2323  return m_Graph->AddLayer<ArgMinMaxLayer>(argMinMaxDescriptor, name);
2324 }
2325 
2327 normalizationDescriptor,
2328  const char* name)
2329 {
2330  return m_Graph->AddLayer<NormalizationLayer>(normalizationDescriptor, name);
2331 }
2332 
2333 IConnectableLayer* NetworkImpl::AddSliceLayer(const SliceDescriptor& sliceDescriptor, const char* name)
2334 {
2335  return m_Graph->AddLayer<SliceLayer>(sliceDescriptor, name);
2336 }
2337 
2339  const char* name)
2340 {
2341  return m_Graph->AddLayer<SoftmaxLayer>(softmaxDescriptor, name);
2342 }
2343 
2345  const char* name)
2346 {
2347  return m_Graph->AddLayer<SplitterLayer>(splitterDescriptor, name);
2348 }
2349 
2351 {
2352  return m_Graph->AddLayer<MaximumLayer>(name);
2353 }
2354 
2356 {
2357  return m_Graph->AddLayer<MinimumLayer>(name);
2358 }
2359 
2361 {
2362  return m_Graph->AddLayer<AdditionLayer>(name);
2363 }
2364 
2366 {
2367  return m_Graph->AddLayer<MultiplicationLayer>(name);
2368 }
2369 
2371 {
2372  return m_Graph->AddLayer<OutputLayer>(id, name);
2373 }
2374 
2376  const ConstTensor& mean,
2377  const ConstTensor& variance,
2378  const ConstTensor& beta,
2379  const ConstTensor& gamma,
2380  const char* name)
2381 {
2382  const auto layer = m_Graph->AddLayer<BatchNormalizationLayer>(desc, name);
2383 
2384  layer->m_Mean = std::make_shared<ScopedTensorHandle>(mean);
2385  layer->m_Variance = std::make_shared<ScopedTensorHandle>(variance);
2386  layer->m_Beta = std::make_shared<ScopedTensorHandle>(beta);
2387  layer->m_Gamma = std::make_shared<ScopedTensorHandle>(gamma);
2388 
2389  return layer;
2390 }
2391 
2393 {
2394  return m_Graph->AddLayer<RankLayer>(name);
2395 }
2396 
2398  const char* name)
2399 {
2400  return m_Graph->AddLayer<ReduceLayer>(reduceDescriptor, name);
2401 }
2402 
2403 IConnectableLayer* NetworkImpl::AddResizeLayer(const ResizeDescriptor& resizeDescriptor, const char* name)
2404 {
2405  return m_Graph->AddLayer<ResizeLayer>(resizeDescriptor, name);
2406 }
2407 
2409 {
2410  return m_Graph->AddLayer<ShapeLayer>(name);
2411 }
2412 
2414  const char* name)
2415 {
2416  return m_Graph->AddLayer<InstanceNormalizationLayer>(desc, name);
2417 }
2418 
2420  const char* name)
2421 {
2422  return m_Graph->AddLayer<L2NormalizationLayer>(desc, name);
2423 }
2424 
2426  const char* name)
2427 {
2428  return m_Graph->AddLayer<LogSoftmaxLayer>(desc, name);
2429 }
2430 
2432 {
2433  auto layer = m_Graph->AddLayer<ConstantLayer>(name);
2434 
2435  layer->m_LayerOutput = std::make_shared<ScopedTensorHandle>(input);
2436 
2437  return layer;
2438 }
2439 
2441  const char* name)
2442 {
2443  return m_Graph->AddLayer<ReshapeLayer>(reshapeDescriptor, name);
2444 }
2445 
2447  const char* name)
2448 {
2449  return m_Graph->AddLayer<SpaceToBatchNdLayer>(spaceToBatchNdDescriptor, name);
2450 }
2451 
2453  const char* name)
2454 {
2455  return m_Graph->AddLayer<SpaceToDepthLayer>(spaceToDepthDescriptor, name);
2456 }
2457 
2459 {
2460  return m_Graph->AddLayer<FloorLayer>(name);
2461 }
2462 
2464  const LstmInputParams& params,
2465  const char* name)
2466 {
2467  const auto layer = m_Graph->AddLayer<LstmLayer>(descriptor, name);
2468 
2469  //Lstm Basic Parameters
2471  std::make_shared<ScopedTensorHandle>(*(params.m_InputToForgetWeights));
2472  layer->m_BasicParameters.m_InputToCellWeights =
2473  std::make_shared<ScopedTensorHandle>(*(params.m_InputToCellWeights));
2474  layer->m_BasicParameters.m_InputToOutputWeights =
2475  std::make_shared<ScopedTensorHandle>(*(params.m_InputToOutputWeights));
2476  layer->m_BasicParameters.m_RecurrentToForgetWeights =
2477  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToForgetWeights));
2478  layer->m_BasicParameters.m_RecurrentToCellWeights =
2479  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToCellWeights));
2480  layer->m_BasicParameters.m_RecurrentToOutputWeights =
2481  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToOutputWeights));
2482  layer->m_BasicParameters.m_ForgetGateBias =
2483  std::make_shared<ScopedTensorHandle>(*(params.m_ForgetGateBias));
2484  layer->m_BasicParameters.m_CellBias =
2485  std::make_shared<ScopedTensorHandle>(*(params.m_CellBias));
2486  layer->m_BasicParameters.m_OutputGateBias =
2487  std::make_shared<ScopedTensorHandle>(*(params.m_OutputGateBias));
2488 
2489  //Lstm Cifg parameters
2490  if(!descriptor.m_CifgEnabled)
2491  {
2492  if(params.m_InputToInputWeights == nullptr)
2493  {
2494  throw InvalidArgumentException("AddLstmLayer: Input To Input Weights cannot be NULL "
2495  "when CIFG is disabled.");
2496  }
2497  if(params.m_RecurrentToInputWeights == nullptr)
2498  {
2500  "AddLstmLayer: Recurrent To Input Weights cannot be NULL "
2501  "when CIFG is disabled.");
2502  }
2503  if(params.m_InputGateBias == nullptr)
2504  {
2505  throw InvalidArgumentException("AddLstmLayer: Input Gate Bias cannot be NULL "
2506  "when CIFG is disabled.");
2507  }
2508  layer->m_CifgParameters.m_InputToInputWeights =
2509  std::make_shared<ScopedTensorHandle>(*(params.m_InputToInputWeights));
2510  layer->m_CifgParameters.m_RecurrentToInputWeights =
2511  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToInputWeights));
2512  layer->m_CifgParameters.m_InputGateBias =
2513  std::make_shared<ScopedTensorHandle>(*(params.m_InputGateBias));
2514  }
2515 
2516  //Lstm projection parameters
2517  if(descriptor.m_ProjectionEnabled)
2518  {
2519  if(params.m_ProjectionWeights == nullptr)
2520  {
2521  throw InvalidArgumentException("AddLstmLayer: Projection Weights cannot be NULL "
2522  "when projection is enabled.");
2523  }
2524  layer->m_ProjectionParameters.m_ProjectionWeights =
2525  std::make_shared<ScopedTensorHandle>(*(params.m_ProjectionWeights));
2526  if(params.m_ProjectionBias != nullptr)
2527  {
2528  layer->m_ProjectionParameters.m_ProjectionBias =
2529  std::make_shared<ScopedTensorHandle>(*(params.m_ProjectionBias));
2530  }
2531  }
2532 
2533  //Lstm Peephole params
2534  if(descriptor.m_PeepholeEnabled)
2535  {
2536  if(!descriptor.m_CifgEnabled)
2537  {
2538  if(params.m_CellToInputWeights == nullptr)
2539  {
2540  throw InvalidArgumentException("AddLstmLayer: Cell To Input Weights cannot be NULL "
2541  "when Peephole is enabled and CIFG disabled.");
2542  }
2543 
2544  layer->m_PeepholeParameters.m_CellToInputWeights =
2545  std::make_shared<ScopedTensorHandle>(*(params.m_CellToInputWeights));
2546  }
2547 
2548  if(params.m_CellToForgetWeights == nullptr)
2549  {
2550  throw InvalidArgumentException("AddLstmLayer: Cell To Forget Weights cannot be NULL "
2551  "when Peephole is enabled.");
2552  }
2553  if(params.m_CellToOutputWeights == nullptr)
2554  {
2555  throw InvalidArgumentException("AddLstmLayer: Cell To Output Weights cannot be NULL "
2556  "when Peephole is enabled.");
2557  }
2558 
2559  layer->m_PeepholeParameters.m_CellToForgetWeights =
2560  std::make_shared<ScopedTensorHandle>(*(params.m_CellToForgetWeights));
2561  layer->m_PeepholeParameters.m_CellToOutputWeights =
2562  std::make_shared<ScopedTensorHandle>(*(params.m_CellToOutputWeights));
2563  }
2564 
2565  //Lstm Layer Normalization params
2566  if(descriptor.m_LayerNormEnabled)
2567  {
2568  if(!descriptor.m_CifgEnabled)
2569  {
2570  if(params.m_InputLayerNormWeights == nullptr)
2571  {
2572  throw InvalidArgumentException("AddLstmLayer: Input layer normalization weights cannot be NULL "
2573  "when layer normalization is enabled and CIFG disabled.");
2574  }
2575  layer->m_LayerNormParameters.m_InputLayerNormWeights =
2576  std::make_shared<ScopedTensorHandle>(*(params.m_InputLayerNormWeights));
2577  }
2578 
2579  if(params.m_ForgetLayerNormWeights == nullptr)
2580  {
2581  throw InvalidArgumentException("AddLstmLayer: Forget layer normalization weights cannot be NULL "
2582  "when layer normalization is enabled.");
2583  }
2584  if(params.m_CellLayerNormWeights == nullptr)
2585  {
2586  throw InvalidArgumentException("AddLstmLayer: Cell layer normalization weights cannot be NULL "
2587  "when layer normalization is enabled.");
2588  }
2589  if(params.m_OutputLayerNormWeights == nullptr)
2590  {
2591  throw InvalidArgumentException("AddLstmLayer: Output layer normalization weights cannot be NULL "
2592  "when layer normalization is enabled.");
2593  }
2594  layer->m_LayerNormParameters.m_ForgetLayerNormWeights =
2595  std::make_shared<ScopedTensorHandle>(*(params.m_ForgetLayerNormWeights));
2596  layer->m_LayerNormParameters.m_CellLayerNormWeights =
2597  std::make_shared<ScopedTensorHandle>(*(params.m_CellLayerNormWeights));
2598  layer->m_LayerNormParameters.m_OutputLayerNormWeights =
2599  std::make_shared<ScopedTensorHandle>(*(params.m_OutputLayerNormWeights));
2600  }
2601  return layer;
2602 }
2603 
2605 {
2606  return m_Graph->AddLayer<DivisionLayer>(name);
2607 }
2608 
2610 {
2611  return m_Graph->AddLayer<SubtractionLayer>(name);
2612 }
2613 
2614 IConnectableLayer* NetworkImpl::AddMeanLayer(const MeanDescriptor& meanDescriptor, const char* name)
2615 {
2616  return m_Graph->AddLayer<MeanLayer>(meanDescriptor,name);
2617 }
2618 
2619 IConnectableLayer* NetworkImpl::AddPadLayer(const PadDescriptor& padDescriptor, const char* name)
2620 {
2621  return m_Graph->AddLayer<PadLayer>(padDescriptor,name);
2622 }
2623 
2625 {
2626  return m_Graph->AddLayer<QuantizeLayer>(name);
2627 }
2628 
2630 {
2631  return m_Graph->AddLayer<DequantizeLayer>(name);
2632 }
2633 
2635  const char* name)
2636 {
2637  return m_Graph->AddLayer<StridedSliceLayer>(stridedSliceDescriptor, name);
2638 }
2639 
2641  const char* name)
2642 {
2643  return m_Graph->AddLayer<GatherLayer>(gatherDescriptor, name);
2644 }
2645 
2647 {
2648  return m_Graph->AddLayer<GatherNdLayer>(name);
2649 }
2650 
2652 {
2653  return m_Graph->AddLayer<MergeLayer>(name);
2654 }
2655 
2657 {
2658  return m_Graph->AddLayer<SwitchLayer>(name);
2659 }
2660 
2662 {
2663  return m_Graph->AddLayer<PreluLayer>(name);
2664 }
2665 
2667  const ConstTensor& weights,
2668  const Optional<ConstTensor>& biases,
2669  const char* name)
2670 {
2671  if (descriptor.m_BiasEnabled && !biases.has_value())
2672  {
2673  throw InvalidArgumentException("AddTransposeConvolution2dLayer: Biases cannot be empty");
2674  }
2675 
2676  const auto layer = m_Graph->AddLayer<TransposeConvolution2dLayer>(descriptor, name);
2677 
2678  layer->m_Weight = std::make_shared<ScopedTensorHandle>(weights);
2679 
2680  if (descriptor.m_BiasEnabled)
2681  {
2682  layer->m_Bias = std::make_shared<ScopedTensorHandle>(biases.value());
2683  }
2684 
2685  return layer;
2686 }
2687 
2689  const char* name)
2690 {
2691  return m_Graph->AddLayer<TransposeLayer>(transposeDescriptor, name);
2692 }
2693 
2695  const char* name)
2696 {
2697  return m_Graph->AddLayer<StackLayer>(stackDescriptor, name);
2698 }
2699 
2700 
2702  const char* name)
2703 {
2704  return m_Graph->AddLayer<StandInLayer>(desc, name);
2705 }
2706 
2708  const char* name)
2709 {
2710  const auto layer = m_Graph->AddLayer<QuantizedLstmLayer>(name);
2711 
2712  // InputToX weights
2714  std::make_shared<ScopedTensorHandle>(params.GetInputToInputWeights());
2715  layer->m_QuantizedLstmParameters.m_InputToForgetWeights =
2716  std::make_shared<ScopedTensorHandle>(params.GetInputToForgetWeights());
2717  layer->m_QuantizedLstmParameters.m_InputToCellWeights =
2718  std::make_shared<ScopedTensorHandle>(params.GetInputToCellWeights());
2719  layer->m_QuantizedLstmParameters.m_InputToOutputWeights =
2720  std::make_shared<ScopedTensorHandle>(params.GetInputToOutputWeights());
2721 
2722  // RecurrentToX weights
2723  layer->m_QuantizedLstmParameters.m_RecurrentToInputWeights =
2724  std::make_shared<ScopedTensorHandle>(params.GetRecurrentToInputWeights());
2725  layer->m_QuantizedLstmParameters.m_RecurrentToForgetWeights =
2726  std::make_shared<ScopedTensorHandle>(params.GetRecurrentToForgetWeights());
2727  layer->m_QuantizedLstmParameters.m_RecurrentToCellWeights =
2728  std::make_shared<ScopedTensorHandle>(params.GetRecurrentToCellWeights());
2729  layer->m_QuantizedLstmParameters.m_RecurrentToOutputWeights =
2730  std::make_shared<ScopedTensorHandle>(params.GetRecurrentToOutputWeights());
2731 
2732  // Bias
2733  layer->m_QuantizedLstmParameters.m_InputGateBias =
2734  std::make_shared<ScopedTensorHandle>(params.GetInputGateBias());
2735  layer->m_QuantizedLstmParameters.m_ForgetGateBias =
2736  std::make_shared<ScopedTensorHandle>(params.GetForgetGateBias());
2737  layer->m_QuantizedLstmParameters.m_CellBias =
2738  std::make_shared<ScopedTensorHandle>(params.GetCellBias());
2739  layer->m_QuantizedLstmParameters.m_OutputGateBias =
2740  std::make_shared<ScopedTensorHandle>(params.GetOutputGateBias());
2741 
2742  return layer;
2743 }
2744 
2746  const LstmInputParams& params,
2747  const char* name)
2748 {
2749  const auto layer = m_Graph->AddLayer<QLstmLayer>(descriptor, name);
2750 
2751  // QLstm Basic Parameters
2753  std::make_shared<ScopedTensorHandle>(*(params.m_InputToForgetWeights));
2754  layer->m_BasicParameters.m_InputToCellWeights =
2755  std::make_shared<ScopedTensorHandle>(*(params.m_InputToCellWeights));
2756  layer->m_BasicParameters.m_InputToOutputWeights =
2757  std::make_shared<ScopedTensorHandle>(*(params.m_InputToOutputWeights));
2758  layer->m_BasicParameters.m_RecurrentToForgetWeights =
2759  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToForgetWeights));
2760  layer->m_BasicParameters.m_RecurrentToCellWeights =
2761  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToCellWeights));
2762  layer->m_BasicParameters.m_RecurrentToOutputWeights =
2763  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToOutputWeights));
2764  layer->m_BasicParameters.m_ForgetGateBias =
2765  std::make_shared<ScopedTensorHandle>(*(params.m_ForgetGateBias));
2766  layer->m_BasicParameters.m_CellBias =
2767  std::make_shared<ScopedTensorHandle>(*(params.m_CellBias));
2768  layer->m_BasicParameters.m_OutputGateBias =
2769  std::make_shared<ScopedTensorHandle>(*(params.m_OutputGateBias));
2770 
2771  // QLstm Cifg parameters
2772  if(!descriptor.m_CifgEnabled)
2773  {
2774  if(params.m_InputToInputWeights == nullptr)
2775  {
2776  throw InvalidArgumentException("AddQLstmLayer: Input To Input Weights cannot be NULL");
2777  }
2778 
2779  if(params.m_RecurrentToInputWeights == nullptr)
2780  {
2782  "AddQLstmLayer: Recurrent To Input Weights cannot be NULL");
2783  }
2784 
2785  if(params.m_InputGateBias == nullptr)
2786  {
2787  throw InvalidArgumentException("AddQLstmLayer: Input Gate Bias cannot be NULL");
2788  }
2789 
2790  layer->m_CifgParameters.m_InputToInputWeights =
2791  std::make_shared<ScopedTensorHandle>(*(params.m_InputToInputWeights));
2792  layer->m_CifgParameters.m_RecurrentToInputWeights =
2793  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToInputWeights));
2794  layer->m_CifgParameters.m_InputGateBias =
2795  std::make_shared<ScopedTensorHandle>(*(params.m_InputGateBias));
2796  }
2797 
2798  // QLstm Projection parameters
2799  if(descriptor.m_ProjectionEnabled)
2800  {
2801  if(params.m_ProjectionWeights == nullptr)
2802  {
2803  throw InvalidArgumentException("AddQLstmLayer: Projection Weights cannot be NULL");
2804  }
2805 
2806  layer->m_ProjectionParameters.m_ProjectionWeights =
2807  std::make_shared<ScopedTensorHandle>(*(params.m_ProjectionWeights));
2808 
2809  // Projection bias is optional even if projection is enabled
2810  if(params.m_ProjectionBias != nullptr)
2811  {
2812  layer->m_ProjectionParameters.m_ProjectionBias =
2813  std::make_shared<ScopedTensorHandle>(*(params.m_ProjectionBias));
2814  }
2815 
2816  }
2817 
2818  // QLstm Peephole params
2819  if(descriptor.m_PeepholeEnabled)
2820  {
2821  if(params.m_CellToForgetWeights == nullptr)
2822  {
2823  throw InvalidArgumentException("AddQLstmLayer: Cell To Forget Weights cannot be NULL");
2824  }
2825 
2826  if(params.m_CellToOutputWeights == nullptr)
2827  {
2828  throw InvalidArgumentException("AddQLstmLayer: Cell To Output Weights cannot be NULL");
2829  }
2830 
2831  if(!descriptor.m_CifgEnabled)
2832  {
2833  if(params.m_CellToInputWeights == nullptr)
2834  {
2835  throw InvalidArgumentException("AddQLstmLayer: Cell To Input Weights cannot be NULL");
2836  }
2837 
2838  layer->m_PeepholeParameters.m_CellToInputWeights =
2839  std::make_shared<ScopedTensorHandle>(*(params.m_CellToInputWeights));
2840  }
2841 
2842  layer->m_PeepholeParameters.m_CellToForgetWeights =
2843  std::make_shared<ScopedTensorHandle>(*(params.m_CellToForgetWeights));
2844  layer->m_PeepholeParameters.m_CellToOutputWeights =
2845  std::make_shared<ScopedTensorHandle>(*(params.m_CellToOutputWeights));
2846  }
2847 
2848  // QLstm Layer Normalization params
2849  if(descriptor.m_LayerNormEnabled)
2850  {
2851  if(params.m_ForgetLayerNormWeights == nullptr)
2852  {
2853  throw InvalidArgumentException("AddQLstmLayer: Forget layer normalization weights cannot be NULL");
2854  }
2855 
2856  if(params.m_CellLayerNormWeights == nullptr)
2857  {
2858  throw InvalidArgumentException("AddQLstmLayer: Cell layer normalization weights cannot be NULL");
2859  }
2860 
2861  if(params.m_OutputLayerNormWeights == nullptr)
2862  {
2863  throw InvalidArgumentException("AddQLstmLayer: Output layer normalization weights cannot be NULL");
2864  }
2865 
2866  if(!descriptor.m_CifgEnabled)
2867  {
2868  if(params.m_InputLayerNormWeights == nullptr)
2869  {
2870  throw InvalidArgumentException("AddQLstmLayer: Input layer normalization weights cannot be NULL");
2871  }
2872 
2873  layer->m_LayerNormParameters.m_InputLayerNormWeights =
2874  std::make_shared<ScopedTensorHandle>(*(params.m_InputLayerNormWeights));
2875  }
2876 
2877  layer->m_LayerNormParameters.m_ForgetLayerNormWeights =
2878  std::make_shared<ScopedTensorHandle>(*(params.m_ForgetLayerNormWeights));
2879  layer->m_LayerNormParameters.m_CellLayerNormWeights =
2880  std::make_shared<ScopedTensorHandle>(*(params.m_CellLayerNormWeights));
2881  layer->m_LayerNormParameters.m_OutputLayerNormWeights =
2882  std::make_shared<ScopedTensorHandle>(*(params.m_OutputLayerNormWeights));
2883  }
2884  return layer;
2885 }
2886 
2888  const char* name)
2889 {
2890  return m_Graph->AddLayer<LogicalBinaryLayer>(logicalBinaryDescriptor, name);
2891 }
2892 
2894  const UnidirectionalSequenceLstmDescriptor& descriptor,
2895  const LstmInputParams& params,
2896  const char* name)
2897 {
2898  const auto layer = m_Graph->AddLayer<UnidirectionalSequenceLstmLayer>(descriptor, name);
2899 
2900  //Lstm Basic Parameters
2902  std::make_shared<ScopedTensorHandle>(*(params.m_InputToForgetWeights));
2903  layer->m_BasicParameters.m_InputToCellWeights =
2904  std::make_shared<ScopedTensorHandle>(*(params.m_InputToCellWeights));
2905  layer->m_BasicParameters.m_InputToOutputWeights =
2906  std::make_shared<ScopedTensorHandle>(*(params.m_InputToOutputWeights));
2907  layer->m_BasicParameters.m_RecurrentToForgetWeights =
2908  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToForgetWeights));
2909  layer->m_BasicParameters.m_RecurrentToCellWeights =
2910  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToCellWeights));
2911  layer->m_BasicParameters.m_RecurrentToOutputWeights =
2912  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToOutputWeights));
2913  layer->m_BasicParameters.m_ForgetGateBias =
2914  std::make_shared<ScopedTensorHandle>(*(params.m_ForgetGateBias));
2915  layer->m_BasicParameters.m_CellBias =
2916  std::make_shared<ScopedTensorHandle>(*(params.m_CellBias));
2917  layer->m_BasicParameters.m_OutputGateBias =
2918  std::make_shared<ScopedTensorHandle>(*(params.m_OutputGateBias));
2919 
2920  //Lstm Cifg parameters
2921  if(!descriptor.m_CifgEnabled)
2922  {
2923  if(params.m_InputToInputWeights == nullptr)
2924  {
2925  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Input To Input Weights cannot be NULL "
2926  "when CIFG is disabled.");
2927  }
2928  if(params.m_RecurrentToInputWeights == nullptr)
2929  {
2931  "AddUnidirectionalSequenceLstmLayer: Recurrent To Input Weights cannot be NULL "
2932  "when CIFG is disabled.");
2933  }
2934  if(params.m_InputGateBias == nullptr)
2935  {
2936  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Input Gate Bias cannot be NULL "
2937  "when CIFG is disabled.");
2938  }
2939  layer->m_CifgParameters.m_InputToInputWeights =
2940  std::make_shared<ScopedTensorHandle>(*(params.m_InputToInputWeights));
2941  layer->m_CifgParameters.m_RecurrentToInputWeights =
2942  std::make_shared<ScopedTensorHandle>(*(params.m_RecurrentToInputWeights));
2943  layer->m_CifgParameters.m_InputGateBias =
2944  std::make_shared<ScopedTensorHandle>(*(params.m_InputGateBias));
2945  }
2946 
2947  //Lstm projection parameters
2948  if(descriptor.m_ProjectionEnabled)
2949  {
2950  if(params.m_ProjectionWeights == nullptr)
2951  {
2952  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Projection Weights cannot be NULL "
2953  "when projection is enabled.");
2954  }
2955  layer->m_ProjectionParameters.m_ProjectionWeights =
2956  std::make_shared<ScopedTensorHandle>(*(params.m_ProjectionWeights));
2957  if(params.m_ProjectionBias != nullptr)
2958  {
2959  layer->m_ProjectionParameters.m_ProjectionBias =
2960  std::make_shared<ScopedTensorHandle>(*(params.m_ProjectionBias));
2961  }
2962  }
2963 
2964  //Lstm Peephole params
2965  if(descriptor.m_PeepholeEnabled)
2966  {
2967  if(!descriptor.m_CifgEnabled)
2968  {
2969  if(params.m_CellToInputWeights == nullptr)
2970  {
2971  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Cell To Input Weights "
2972  "cannot be NULL when Peephole is enabled and CIFG disabled.");
2973  }
2974 
2975  layer->m_PeepholeParameters.m_CellToInputWeights =
2976  std::make_shared<ScopedTensorHandle>(*(params.m_CellToInputWeights));
2977  }
2978 
2979  if(params.m_CellToForgetWeights == nullptr)
2980  {
2981  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Cell To Forget Weights cannot be NULL "
2982  "when Peephole is enabled.");
2983  }
2984  if(params.m_CellToOutputWeights == nullptr)
2985  {
2986  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Cell To Output Weights cannot be NULL "
2987  "when Peephole is enabled.");
2988  }
2989 
2990  layer->m_PeepholeParameters.m_CellToForgetWeights =
2991  std::make_shared<ScopedTensorHandle>(*(params.m_CellToForgetWeights));
2992  layer->m_PeepholeParameters.m_CellToOutputWeights =
2993  std::make_shared<ScopedTensorHandle>(*(params.m_CellToOutputWeights));
2994  }
2995 
2996  //Lstm Layer Normalization params
2997  if(descriptor.m_LayerNormEnabled)
2998  {
2999  if(!descriptor.m_CifgEnabled)
3000  {
3001  if(params.m_InputLayerNormWeights == nullptr)
3002  {
3003  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Input layer normalization weights "
3004  "cannot be NULL when layer normalization is enabled and CIFG disabled.");
3005  }
3006  layer->m_LayerNormParameters.m_InputLayerNormWeights =
3007  std::make_shared<ScopedTensorHandle>(*(params.m_InputLayerNormWeights));
3008  }
3009 
3010  if(params.m_ForgetLayerNormWeights == nullptr)
3011  {
3012  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Forget layer normalization weights "
3013  "cannot be NULL when layer normalization is enabled.");
3014  }
3015  if(params.m_CellLayerNormWeights == nullptr)
3016  {
3017  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Cell layer normalization weights "
3018  "cannot be NULL when layer normalization is enabled.");
3019  }
3020  if(params.m_OutputLayerNormWeights == nullptr)
3021  {
3022  throw InvalidArgumentException("AddUnidirectionalSequenceLstmLayer: Output layer normalization weights "
3023  "cannot be NULL when layer normalization is enabled.");
3024  }
3025  layer->m_LayerNormParameters.m_ForgetLayerNormWeights =
3026  std::make_shared<ScopedTensorHandle>(*(params.m_ForgetLayerNormWeights));
3027  layer->m_LayerNormParameters.m_CellLayerNormWeights =
3028  std::make_shared<ScopedTensorHandle>(*(params.m_CellLayerNormWeights));
3029  layer->m_LayerNormParameters.m_OutputLayerNormWeights =
3030  std::make_shared<ScopedTensorHandle>(*(params.m_OutputLayerNormWeights));
3031  }
3032  return layer;
3033 }
3034 
3036 {
3037  return m_Graph->AddLayer<BatchMatMulLayer>(desc, name);
3038 }
3039 
3041 {
3042  return m_Graph->AddLayer<ReverseV2Layer>(name);
3043 }
3044 
3046 {
3047  return m_Graph->AddLayer<TileLayer>(desc, name);
3048 }
3049 
3051  CompiledBlobPtr compiledBlobPtr,
3052  const Optional<BackendId>& backend,
3053  const char* name)
3054 {
3055  // Method use is for backend users.
3056  PreCompiledLayer* layer;
3057  if (name)
3058  {
3059  layer = m_Graph->AddLayer<PreCompiledLayer>(preCompiledDescriptor, name);
3060  }
3061  else
3062  {
3063  layer = m_Graph->AddLayer<PreCompiledLayer>(preCompiledDescriptor, "pre-compiled");
3064  }
3065 
3066  // Assign the pre-compiled object to layer
3067  // Pass only one compiled network, Arm NN does not handle multiple
3068  // pre-compiled objects in a single pre-compiled layer currently
3069  layer->SetPreCompiledObject(std::move(compiledBlobPtr));
3070 
3071  if (backend.has_value())
3072  {
3073  layer->SetBackendId(backend.value());
3074  }
3075  else if (layer->GetBackendHint().has_value())
3076  {
3077  layer->SetBackendId(layer->GetBackendHint().value());
3078  }
3079 
3080  return layer;
3081 }
3082 
3084 {
3085  return m_Graph->AddLayer<BroadcastToLayer>(desc, name);
3086 }
3087 
3089 {
3090  for (auto layer : GetGraph())
3091  {
3092  layer->ExecuteStrategy(strategy);
3093  };
3094 }
3095 
3097  : m_Graph(new Graph(*other.m_Graph.get()))
3098  , m_Guid(arm::pipe::IProfilingService::GetNextGuid())
3099  , m_ModelOptions(modelOptions)
3100 {
3101 }
3102 
3103 OptimizedNetworkImpl::OptimizedNetworkImpl(std::unique_ptr<Graph> graph)
3104  : m_Graph(std::move(graph)), m_Guid(arm::pipe::IProfilingService::GetNextGuid())
3105 {
3106 }
3107 
3108 OptimizedNetworkImpl::OptimizedNetworkImpl(std::unique_ptr<Graph> graph, const ModelOptions& modelOptions)
3109  : m_Graph(std::move(graph)), m_Guid(arm::pipe::IProfilingService::GetNextGuid()), m_ModelOptions(modelOptions)
3110 {
3111 }
3112 
3114 {
3115 }
3116 
3118 {
3119  pOptimizedNetworkImpl->ExecuteStrategy(strategy);
3120 }
3121 
3123 {
3124  for (auto layer : GetGraph())
3125  {
3126  layer->ExecuteStrategy(strategy);
3127  };
3128 }
3129 
3130 } // 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:2273
ARMNN_ASSERT
#define ARMNN_ASSERT(COND)
Definition: Assert.hpp:14
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:2666
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:263
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:3117
armnn::ApplyBackendOptimizations
OptimizationResult ApplyBackendOptimizations(OptimizedNetworkImpl *optNetObjPtr, BackendSettings &backendSettings, BackendsMap &backends, const ModelOptions &modelOptions, Optional< std::vector< std::string > & > errMessages)
Definition: Network.cpp:1328
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:666
armnn::NetworkImpl::AddLogicalBinaryLayer
IConnectableLayer * AddLogicalBinaryLayer(const LogicalBinaryDescriptor &logicalBinaryDescriptor, const char *name=nullptr)
Definition: Network.cpp:2887
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:200
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:715
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:2233
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:3040
armnn::OptimizationResult::IsWarningOnly
bool IsWarningOnly() const
Definition: Network.hpp:275
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:2688
armnn::ProfilerManager::RegisterProfiler
void RegisterProfiler(IProfiler *profiler)
Definition: Profiling.cpp:600
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:92
armnn::NetworkImpl::AddConvolution2dLayer
IConnectableLayer * AddConvolution2dLayer(const Convolution2dDescriptor &convolution2dDescriptor, const char *name=nullptr)
Definition: Network.cpp:2251
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:3083
armnn::OptimizerOptionsOpaque::operator=
OptimizerOptionsOpaque & operator=(OptimizerOptionsOpaque other)
Definition: Network.cpp:96
armnn::OptimizedNetworkImpl::PrintGraph
virtual Status PrintGraph()
Definition: Network.cpp:735
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:3045
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:2604
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:1573
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:504
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:2360
armnn::OutputSlot::SetTensorInfo
void SetTensorInfo(const TensorInfo &tensorInfo) override
Definition: Layer.cpp:87
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:461
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:741
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:725
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:2344
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:3122
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:710
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:720
armnn::OptimizerOptionsOpaque::GetExportEnabled
bool GetExportEnabled() const
Definition: Network.cpp:166
armnn::NetworkImpl::AddSubtractionLayer
IConnectableLayer * AddSubtractionLayer(const char *name=nullptr)
Definition: Network.cpp:2609
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:705
armnn::NetworkImpl::AddStridedSliceLayer
IConnectableLayer * AddStridedSliceLayer(const StridedSliceDescriptor &stridedSliceDescriptor, const char *name=nullptr)
Definition: Network.cpp:2634
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:2425
armnn::NetworkImpl::~NetworkImpl
~NetworkImpl()
Definition: Network.cpp:2178
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:581
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:901
armnn::NetworkImpl::AddMeanLayer
IConnectableLayer * AddMeanLayer(const MeanDescriptor &meanDescriptor, const char *name=nullptr)
Definition: Network.cpp:2614
armnn::OptimizedNetworkImpl::GetGraph
Graph & GetGraph()
Definition: OptimizedNetworkImpl.hpp:27
armnn::OptimizationResult::IsError
bool IsError() const
Definition: Network.hpp:277
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:2403
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:1186
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:3035
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:2463
armnn::NetworkImpl::AddReduceLayer
IConnectableLayer * AddReduceLayer(const ReduceDescriptor &reduceDescriptor, const char *name=nullptr)
Definition: Network.cpp:2397
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:2431
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:768
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:671
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:2279
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:3113
armnn::OutputSlot::Connect
int Connect(InputSlot &destination)
Definition: Layer.cpp:112
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:3096
armnn::BatchNormalizationLayer
This layer represents a batch normalization operation.
Definition: BatchNormalizationLayer.hpp:15
Optimizer.hpp
ARMNN_ASSERT_MSG
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
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:1812
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:2209
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:3088
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:2656
armnn::OptimizationResult
Definition: Network.hpp:260
armnn::NetworkImpl::AddSpaceToDepthLayer
IConnectableLayer * AddSpaceToDepthLayer(const SpaceToDepthDescriptor &spaceToDepthDescriptor, const char *name=nullptr)
Definition: Network.cpp:2452
armnn::ITensorHandleFactory::LegacyFactoryId
static const FactoryId LegacyFactoryId
Definition: ITensorHandleFactory.hpp:50
armnn::NetworkImpl::AddFloorLayer
IConnectableLayer * AddFloorLayer(const char *name=nullptr)
Definition: Network.cpp:2458
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:273
armnn::NetworkImpl::AddPermuteLayer
IConnectableLayer * AddPermuteLayer(const PermuteDescriptor &permuteDescriptor, const char *name=nullptr)
Definition: Network.cpp:2296
armnn::NetworkImpl::AddRankLayer
IConnectableLayer * AddRankLayer(const char *name=nullptr)
Definition: Network.cpp:2392
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:2320
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:1309
armnn::NetworkImpl::AddBatchToSpaceNdLayer
IConnectableLayer * AddBatchToSpaceNdLayer(const BatchToSpaceNdDescriptor &batchToSpaceNdDescriptor, const char *name=nullptr)
Definition: Network.cpp:2193
armnn::NetworkImpl::AddPreluLayer
IConnectableLayer * AddPreluLayer(const char *name=nullptr)
Definition: Network.cpp:2661
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:2893
armnn::NetworkImpl::AddSoftmaxLayer
IConnectableLayer * AddSoftmaxLayer(const SoftmaxDescriptor &softmaxDescriptor, const char *name=nullptr)
Definition: Network.cpp:2338
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:2375
armnn::Graph::begin
Iterator begin()
Returns iterator pointing to the beginning of the list. Lowercase for range-based for loops.
Definition: Graph.hpp:169
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:259
armnn::SubgraphView::GetIConnectableLayers
const IConnectableLayers & GetIConnectableLayers() const
Definition: SubgraphView.cpp:278
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:847
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:120
armnn::NetworkImpl::AddFillLayer
IConnectableLayer * AddFillLayer(const FillDescriptor &fillDescriptor, const char *name=nullptr)
Definition: Network.cpp:2227
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:283
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:2646
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:756
IBackendInternal.hpp
armnn::LayerType::Softmax
@ Softmax
armnn::CheckFp16Support
bool CheckFp16Support(BackendsMap &backends, const std::vector< BackendId > &availablePreferredBackends)
Definition: Network.cpp:1029
armnn::NetworkImpl::AddStackLayer
IConnectableLayer * AddStackLayer(const StackDescriptor &stackDescriptor, const char *name=nullptr)
Definition: Network.cpp:2694
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:2221
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:2257
armnn::NetworkImpl::AddOutputLayer
IConnectableLayer * AddOutputLayer(LayerBindingId id, const char *name=nullptr)
Definition: Network.cpp:2370
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:2440
armnn::NetworkImpl::AddQLstmLayer
IConnectableLayer * AddQLstmLayer(const QLstmDescriptor &descriptor, const LstmInputParams &params, const char *name=nullptr)
Definition: Network.cpp:2745
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:2182
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::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:2188
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:2355
armnn::ITensorHandleFactory
Definition: ITensorHandleFactory.hpp:46
armnn::Graph::GetProfiler
const std::shared_ptr< IProfiler > & GetProfiler() const
Definition: Graph.cpp:692
armnn::OptimizedNetworkImpl::GetNumInputs
virtual size_t GetNumInputs() const
Definition: Network.cpp:746
armnn::RequiresCopy
bool RequiresCopy(ITensorHandleFactory::FactoryId src, ITensorHandleFactory::FactoryId dst, TensorHandleFactoryRegistry &registry)
Definition: Network.cpp:1458
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:780
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:2215
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::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:2624
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:2326
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:730
armnn::GetLayerInOutDatatype
std::vector< DataType > GetLayerInOutDatatype(const Layer *layer)
Definition: Network.cpp:1020
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:604
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:2651
armnn::OptimizerOptionsOpaque::SetAllowExpandedDims
void SetAllowExpandedDims(bool ExpandedDimsAllowed)
Definition: Network.cpp:146
armnn::NetworkImpl::AddShapeLayer
IConnectableLayer * AddShapeLayer(const char *name=nullptr)
Definition: Network.cpp:2408
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::Layer::GetNameStr
const std::string & GetNameStr() const
Definition: Layer.hpp:240
armnn::IWorkloadFactory::IsLayerSupported
static bool IsLayerSupported(const BackendId &backendId, const IConnectableLayer &layer, Optional< DataType > dataType, std::string &outReasonIfUnsupported)
Definition: WorkloadFactory.cpp:1614
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:2245
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:2199
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::ShapeInferenceMethod::InferAndValidate
@ InferAndValidate
Infer missing output shapes and validate all output shapes.
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:2239
armnn::NetworkImpl::AddStandInLayer
IConnectableLayer * AddStandInLayer(const StandInDescriptor &descriptor, const char *name=nullptr)
Definition: Network.cpp:2701
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:2707
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:2629
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:329
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:1563
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:171
armnn::LogicalBinaryDescriptor
A LogicalBinaryDescriptor for the LogicalBinaryLayer.
Definition: Descriptors.hpp:1518
armnn::ProfilerManager::GetInstance
static ProfilerManager & GetInstance()
Definition: Profiling.cpp:593
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:1478
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:681
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:210
armnn::OptimizationViews::GetSubstitutions
const Substitutions & GetSubstitutions() const
Definition: OptimizationViews.hpp:58
armnn::INetwork::pNetworkImpl
std::unique_ptr< NetworkImpl > pNetworkImpl
Definition: INetwork.hpp:888
armnn::SubgraphView::end
IConnectableLayerIterator end()
Definition: SubgraphView.cpp:288
armnn::OptimizerOptions
Definition: INetwork.hpp:151
armnn::IOptimizedNetwork::Destroy
static void Destroy(IOptimizedNetwork *network)
Definition: Network.cpp:700
armnn::OptimizationViews::GetDeletedSubgraphs
const Subgraphs & GetDeletedSubgraphs() const
Definition: OptimizationViews.hpp:61
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:2419
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:2314
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:282
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:2308
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:2302
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:686
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::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:2365
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:2262
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:2413
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::NetworkImpl::NetworkImpl
NetworkImpl(const NetworkOptions &networkOptions={})
Definition: Network.cpp:2173
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:2267
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:1723
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:2132
armnn::NetworkImpl::AddChannelShuffleLayer
IConnectableLayer * AddChannelShuffleLayer(const ChannelShuffleDescriptor &channelShuffleDescriptor, const char *name=nullptr)
Definition: Network.cpp:2203
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::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:2446
armnn::NetworkImpl::AddSliceLayer
IConnectableLayer * AddSliceLayer(const SliceDescriptor &sliceDescriptor, const char *name=nullptr)
Definition: Network.cpp:2333
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:676
armnn::OptimizerOptionsOpaqueImpl
Definition: Network.hpp:307
armnn::optimizations::AddBroadcastReshapeLayer
OptimizeForType< Layer, AddBroadcastReshapeLayerImpl > AddBroadcastReshapeLayer
Definition: AddBroadcastReshapeLayer.hpp:94
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:75
armnn::optimizations::OptimizeConsecutiveReshapes
OptimizeForConnection< ReshapeLayer, ReshapeLayer, OptimizeConsecutiveReshapesImpl > OptimizeConsecutiveReshapes
Definition: OptimizeConsecutiveReshapes.hpp:61
armnn::OptimizedNetworkImpl::GetNumOutputs
virtual size_t GetNumOutputs() const
Definition: Network.cpp:751
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:2640
armnn::NetworkImpl::AddPrecompiledLayer
IConnectableLayer * AddPrecompiledLayer(const PreCompiledDescriptor &preCompiledDescriptor, CompiledBlobPtr compiledBlobPtr, const Optional< BackendId > &backend, const char *name=nullptr)
Definition: Network.cpp:3050
armnn::CheckScaleSetOnQuantizedType
bool CheckScaleSetOnQuantizedType(Layer *layer, Optional< std::vector< std::string > & > errMessages)
Definition: Network.cpp:795
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:2619
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:2350
armnn::INetwork::~INetwork
~INetwork()
armnn::NetworkImpl::AddDetectionPostProcessLayer
IConnectableLayer * AddDetectionPostProcessLayer(const DetectionPostProcessDescriptor &descriptor, const ConstTensor &anchors, const char *name=nullptr)
Definition: Network.cpp:2286
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:946
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:1076
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