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