ArmNN
 23.05
ClBackend.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017-2023 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "ClBackend.hpp"
7 #include "ClBackendContext.hpp"
9 #include "ClBackendId.hpp"
12 #include "ClLayerSupport.hpp"
14 #include "ClWorkloadFactory.hpp"
15 
17 #include <armnn/Descriptors.hpp>
18 
22 
26 
36 
37 #include <Optimizer.hpp>
38 
39 #include <arm_compute/core/Types.h>
40 #include <arm_compute/runtime/CL/CLBufferAllocator.h>
41 
42 namespace armnn
43 {
44 
46 {
47  static const BackendId s_Id{ClBackendId()};
48  return s_Id;
49 }
50 
52 {
54  {
55  return std::make_unique<ClMemoryManager>(m_CustomAllocator);
56  }
57  return std::make_unique<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
58 }
59 
61  const IBackendInternal::IMemoryManagerSharedPtr& memoryManager) const
62 {
63  return std::make_unique<ClWorkloadFactory>(
64  PolymorphicPointerDowncast<ClMemoryManager>(memoryManager));
65 }
66 
68  const IBackendInternal::IMemoryManagerSharedPtr& memoryManager, const ModelOptions& modelOptions) const
69 {
70  return std::make_unique<ClWorkloadFactory>(
71  PolymorphicPointerDowncast<ClMemoryManager>(memoryManager), CreateBackendSpecificModelContext(modelOptions));
72 }
73 
75  TensorHandleFactoryRegistry& registry) const
76 {
77  std::shared_ptr<ClMemoryManager> memoryManager;
79  {
80  memoryManager = std::make_shared<ClMemoryManager>(m_CustomAllocator);
81  }
82  else
83  {
84  memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
85  }
86 
87  std::unique_ptr<ITensorHandleFactory> factory = std::make_unique<ClTensorHandleFactory>(memoryManager);
88  std::unique_ptr<ITensorHandleFactory> importFactory = std::make_unique<ClImportTensorHandleFactory>(
90 
91  registry.RegisterCopyAndImportFactoryPair(factory->GetId(), importFactory->GetId());
92  registry.RegisterCopyAndImportFactoryPair(importFactory->GetId(), factory->GetId());
93 
94  registry.RegisterMemoryManager(memoryManager);
95  registry.RegisterFactory(std::move(factory));
96  registry.RegisterFactory(std::move(importFactory));
97 
98  return std::make_unique<ClWorkloadFactory>(
99  PolymorphicPointerDowncast<ClMemoryManager>(memoryManager));
100 }
101 
103  TensorHandleFactoryRegistry& registry, const ModelOptions& modelOptions) const
104 {
105  std::shared_ptr<ClMemoryManager> memoryManager;
107  {
108  memoryManager = std::make_shared<ClMemoryManager>(m_CustomAllocator);
109  }
110  else
111  {
112  memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
113  }
114 
115  std::unique_ptr<ITensorHandleFactory> factory = std::make_unique<ClTensorHandleFactory>(memoryManager);
116  std::unique_ptr<ITensorHandleFactory> importFactory = std::make_unique<ClImportTensorHandleFactory>(
118 
119  registry.RegisterCopyAndImportFactoryPair(factory->GetId(), importFactory->GetId());
120  registry.RegisterCopyAndImportFactoryPair(importFactory->GetId(), factory->GetId());
121 
122  registry.RegisterMemoryManager(memoryManager);
123  registry.RegisterFactory(std::move(factory));
124  registry.RegisterFactory(std::move(importFactory));
125 
126  return std::make_unique<ClWorkloadFactory>(
127  PolymorphicPointerDowncast<ClMemoryManager>(memoryManager), CreateBackendSpecificModelContext(modelOptions));
128 }
129 
131  TensorHandleFactoryRegistry& registry,
132  const ModelOptions& modelOptions,
133  MemorySourceFlags inputFlags,
134  MemorySourceFlags outputFlags) const
135 {
136  // To allow force import if inputFlags/outputFlags are Undefined, set it as Malloc
137  if (inputFlags == static_cast<MemorySourceFlags>(MemorySource::Undefined))
138  {
139  inputFlags = static_cast<MemorySourceFlags>(MemorySource::Malloc);
140  }
141  if (outputFlags == static_cast<MemorySourceFlags>(MemorySource::Undefined))
142  {
143  outputFlags = static_cast<MemorySourceFlags>(MemorySource::Malloc);
144  }
145  std::shared_ptr<ClMemoryManager> memoryManager;
147  {
148  memoryManager = std::make_shared<ClMemoryManager>(m_CustomAllocator);
149  }
150  else
151  {
152  memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
153  }
154 
155  std::unique_ptr<ITensorHandleFactory> factory = std::make_unique<ClTensorHandleFactory>(memoryManager);
156  std::unique_ptr<ITensorHandleFactory> importFactory = std::make_unique<ClImportTensorHandleFactory>(
157  inputFlags, outputFlags);
158 
159  registry.RegisterCopyAndImportFactoryPair(factory->GetId(), importFactory->GetId());
160  registry.RegisterCopyAndImportFactoryPair(importFactory->GetId(), factory->GetId());
161 
162  registry.RegisterMemoryManager(memoryManager);
163  registry.RegisterFactory(std::move(factory));
164  registry.RegisterFactory(std::move(importFactory));
165 
166  return std::make_unique<ClWorkloadFactory>(
167  PolymorphicPointerDowncast<ClMemoryManager>(memoryManager), CreateBackendSpecificModelContext(modelOptions));
168 }
169 
170 std::vector<ITensorHandleFactory::FactoryId> ClBackend::GetHandleFactoryPreferences() const
171 {
172  return std::vector<ITensorHandleFactory::FactoryId> {ClTensorHandleFactory::GetIdStatic(),
174 }
175 
177 {
178  std::shared_ptr<ClMemoryManager> memoryManager;
180  {
181  memoryManager = std::make_shared<ClMemoryManager>(m_CustomAllocator);
182  }
183  else
184  {
185  memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
186  }
187 
188  std::unique_ptr<ITensorHandleFactory> factory = std::make_unique<ClTensorHandleFactory>(memoryManager);
189  std::unique_ptr<ITensorHandleFactory> importFactory = std::make_unique<ClImportTensorHandleFactory>(
191 
192  registry.RegisterCopyAndImportFactoryPair(factory->GetId(), importFactory->GetId());
193  registry.RegisterCopyAndImportFactoryPair(importFactory->GetId(), factory->GetId());
194 
195  registry.RegisterMemoryManager(memoryManager);
196  registry.RegisterFactory(std::move(factory));
197  registry.RegisterFactory(std::move(importFactory));
198 
199 }
200 
202  MemorySourceFlags inputFlags,
203  MemorySourceFlags outputFlags)
204 {
205  // To allow force import if inputFlags/outputFlags are Undefined, set it as Malloc
206  if (inputFlags == static_cast<MemorySourceFlags>(MemorySource::Undefined))
207  {
208  inputFlags = static_cast<MemorySourceFlags>(MemorySource::Malloc);
209  }
210  if (outputFlags == static_cast<MemorySourceFlags>(MemorySource::Undefined))
211  {
212  outputFlags = static_cast<MemorySourceFlags>(MemorySource::Malloc);
213  }
214  std::shared_ptr<ClMemoryManager> memoryManager;
216  {
217  memoryManager = std::make_shared<ClMemoryManager>(m_CustomAllocator);
218  }
219  else
220  {
221  memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
222  }
223 
224  std::unique_ptr<ITensorHandleFactory> factory = std::make_unique<ClTensorHandleFactory>(memoryManager);
225  std::unique_ptr<ITensorHandleFactory> importFactory = std::make_unique<ClImportTensorHandleFactory>(
226  inputFlags, outputFlags);
227 
228  registry.RegisterCopyAndImportFactoryPair(factory->GetId(), importFactory->GetId());
229  registry.RegisterCopyAndImportFactoryPair(importFactory->GetId(), factory->GetId());
230 
231  registry.RegisterMemoryManager(memoryManager);
232  registry.RegisterFactory(std::move(factory));
233  registry.RegisterFactory(std::move(importFactory));
234 }
235 
237 {
238  return IBackendContextPtr{new ClBackendContext{options}};
239 }
240 
243 {
245 }
246 
248  const ModelOptions& modelOptions) const
249 {
250  return IBackendSpecificModelContextPtr{new ClBackendModelContext{modelOptions}};
251 }
252 
254 {
255  static ILayerSupportSharedPtr layerSupport
256  {
258  };
259  return layerSupport;
260 }
261 
263 {
264  static ILayerSupportSharedPtr layerSupport
265  {
267  };
268  return layerSupport;
269 }
270 
271 std::unique_ptr<ICustomAllocator> ClBackend::GetDefaultAllocator() const
272 {
273  return std::make_unique<ClBackendDefaultAllocator>();
274 }
275 
277  const ModelOptions& modelOptions) const
278 {
279  OptimizationViews optimizationViews(modelOptions);
280 
281  auto it = subgraph.endIConnectable();
282  bool isFastMathEnabled = false;
283  std::map<LayerGuid, Layer*> untouched;
284 
285  while (it != subgraph.beginIConnectable())
286  {
287  --it;
288  Layer& base = *(PolymorphicDowncast<Layer*>(*it));
289  untouched.insert({base.GetGuid(), &base});
290  }
291 
292  it = subgraph.endIConnectable();
293 #if defined(ARMCOMPUTECL_ENABLED)
295 
296  if (modelContextPtr)
297  {
298  auto clModelOptions = dynamic_cast<ClBackendModelContext*>(modelContextPtr.get());
299  if (clModelOptions)
300  {
301  isFastMathEnabled = clModelOptions->IsFastMathEnabled();
302  }
303  }
304 #endif
305  while (it != subgraph.beginIConnectable())
306  {
307  --it;
308  Layer& base = *(PolymorphicDowncast<Layer*>(*it));
309 
310  // Fuse activation into previous layer if supported by backend
316  && (base.GetAdditionalInformation<ActivationDescriptor>() == nullptr))
317  {
318  for (auto output = base.BeginOutputSlots(); output != base.EndOutputSlots(); ++output)
319  {
320  if (output->GetNumConnections() == 1)
321  {
322  for (auto&& childInput : output->GetConnections())
323  {
324  if ((childInput->GetOwningLayer().GetType() == LayerType::Activation) &&
325  (checkDataTypeInputandOutput(childInput->GetOwningLayer())))
326  {
327  Layer& child = childInput->GetOwningLayer();
328 
329  auto* activationLayer = PolymorphicDowncast<ActivationLayer*>(&child);
330 
331  const std::string name = std::string("fused-") + child.GetName() + std::string("-into-") +
332  base.GetName();
333 
334  // Get params from activation layer
335  ActivationDescriptor activationDesc = activationLayer->GetParameters();
336 
337  if (base.GetType() == LayerType::Convolution2d)
338  {
339  Convolution2dLayer* baseLayer = PolymorphicDowncast<Convolution2dLayer*>(&base);
340 
341  Optional<TensorInfo> biases;
342 
343  if (baseLayer->GetParameters().m_BiasEnabled)
344  {
345  biases = baseLayer->GetInputSlot(2).GetConnectedOutputSlot()->GetTensorInfo();
346  }
347 
350  activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
351  baseLayer->GetParameters(),
353  biases,
354  isFastMathEnabled,
355  &activationDesc);
356 
357  if (status)
358  {
359  FuseConvolution2dLayer<Convolution2dLayer>(optimizationViews,
360  baseLayer,
361  activationLayer,
362  activationDesc,
363  name);
364  untouched.erase(baseLayer->GetGuid());
365  untouched.erase(activationLayer->GetGuid());
366  }
367  }
368  else if (base.GetType() == LayerType::DepthwiseConvolution2d)
369  {
370  DepthwiseConvolution2dLayer* baseLayer =
371  PolymorphicDowncast<DepthwiseConvolution2dLayer*>(&base);
372 
373  Optional<TensorInfo> biases;
374 
375  if (baseLayer->GetParameters().m_BiasEnabled)
376  {
377  biases = baseLayer->GetInputSlot(2).GetConnectedOutputSlot()->GetTensorInfo();
378  }
379 
382  activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
383  baseLayer->GetParameters(),
385  biases,
386  &activationDesc);
387 
388  if (status)
389  {
390  FuseDepthwiseConvolution2dLayer<DepthwiseConvolution2dLayer>(optimizationViews,
391  baseLayer,
392  activationLayer,
393  activationDesc,
394  name);
395  untouched.erase(baseLayer->GetGuid());
396  untouched.erase(activationLayer->GetGuid());
397  }
398  }
399  else if (base.GetType() == LayerType::FullyConnected)
400  {
401  FullyConnectedLayer* baseLayer = PolymorphicDowncast<FullyConnectedLayer*>(&base);
402  FullyConnectedDescriptor descriptor = baseLayer->GetParameters();
403 
404  // As bias is optional only try to get TensorInfo from input if bias is enabled.
405  Optional<TensorInfo> biases;
406  if (descriptor.m_BiasEnabled)
407  {
408  biases = baseLayer->GetInputSlot(2).GetConnectedOutputSlot()->GetTensorInfo();
409  }
410 
413  activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
415  biases,
416  baseLayer->GetParameters(),
417  &activationDesc);
418 
419  if (status)
420  {
421  FuseFullyConnectedLayer<FullyConnectedLayer>(optimizationViews,
422  baseLayer,
423  activationLayer,
424  activationDesc,
425  name);
426  untouched.erase(baseLayer->GetGuid());
427  untouched.erase(activationLayer->GetGuid());
428  }
429  }
430  else if (base.GetType() == LayerType::BatchNormalization)
431  {
432  BatchNormalizationLayer* baseLayer =
433  PolymorphicDowncast<BatchNormalizationLayer*>(&base);
434 
437  activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
438  baseLayer->m_Mean->GetTensorInfo(),
439  baseLayer->m_Variance->GetTensorInfo(),
440  baseLayer->m_Beta->GetTensorInfo(),
441  baseLayer->m_Gamma->GetTensorInfo(),
442  baseLayer->GetParameters(),
443  &activationDesc);
444 
445  if (status)
446  {
447  BatchNormalizationLayer* replacementLayer =
448  FuseBatchNormalizationLayer<BatchNormalizationLayer>(optimizationViews,
449  baseLayer,
450  activationLayer,
451  activationDesc,
452  name);
453 
454  replacementLayer->m_Beta = std::move(baseLayer->m_Beta);
455  replacementLayer->m_Gamma = std::move(baseLayer->m_Gamma);
456  replacementLayer->m_Mean = std::move(baseLayer->m_Mean);
457  replacementLayer->m_Variance = std::move(baseLayer->m_Variance);
458  untouched.erase(baseLayer->GetGuid());
459  untouched.erase(activationLayer->GetGuid());
460  }
461  }
462  else if (base.GetType() == LayerType::Addition)
463  {
464  AdditionLayer* baseLayer = PolymorphicDowncast<AdditionLayer*>(&base);
465 
469  activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
470  &activationDesc);
471 
472  if (status)
473  {
474  FuseAdditionLayer<AdditionLayer>(optimizationViews,
475  baseLayer,
476  activationLayer,
477  activationDesc,
478  name);
479  untouched.erase(baseLayer->GetGuid());
480  untouched.erase(activationLayer->GetGuid());
481  }
482  }
483  else if (base.GetType() == LayerType::Division)
484  {
485  DivisionLayer* baseLayer = PolymorphicDowncast<DivisionLayer*>(&base);
486 
490  activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
491  &activationDesc);
492 
493  if (status)
494  {
495  FuseDivisionLayer<DivisionLayer>(optimizationViews,
496  baseLayer,
497  activationLayer,
498  activationDesc,
499  name);
500  untouched.erase(baseLayer->GetGuid());
501  untouched.erase(activationLayer->GetGuid());
502  }
503  }
504  else if (base.GetType() == LayerType::Multiplication)
505  {
506  MultiplicationLayer* baseLayer = PolymorphicDowncast<MultiplicationLayer*>(&base);
507 
511  activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
512  &activationDesc);
513 
514  if (status)
515  {
516  FuseMultiplicationLayer<MultiplicationLayer>(optimizationViews,
517  baseLayer,
518  activationLayer,
519  activationDesc,
520  name);
521  untouched.erase(baseLayer->GetGuid());
522  untouched.erase(activationLayer->GetGuid());
523  }
524  }
525  else if (base.GetType() == LayerType::Subtraction)
526  {
527  SubtractionLayer* baseLayer = PolymorphicDowncast<SubtractionLayer*>(&base);
528 
532  activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
533  &activationDesc);
534 
535  if (status)
536  {
537  FuseSubtractionLayer<SubtractionLayer>(optimizationViews,
538  baseLayer,
539  activationLayer,
540  activationDesc,
541  name);
542  untouched.erase(baseLayer->GetGuid());
543  untouched.erase(activationLayer->GetGuid());
544  }
545  }
546  else if (base.GetType() == LayerType::ElementwiseBinary)
547  {
548  ElementwiseBinaryLayer* baseLayer = PolymorphicDowncast<ElementwiseBinaryLayer*>(&base);
549 
550  if (baseLayer->GetParameters().m_Operation == BinaryOperation::Add)
551  {
555  activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
556  &activationDesc);
557 
558  if (status)
559  {
560  FuseElementwiseBinaryLayer<ElementwiseBinaryLayer>(optimizationViews,
561  baseLayer,
562  activationLayer,
563  activationDesc,
565  name);
566  untouched.erase(baseLayer->GetGuid());
567  untouched.erase(activationLayer->GetGuid());
568  }
569  }
570  else if (baseLayer->GetParameters().m_Operation == BinaryOperation::Div)
571  {
575  activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
576  &activationDesc);
577 
578  if (status)
579  {
580  FuseElementwiseBinaryLayer<ElementwiseBinaryLayer>(optimizationViews,
581  baseLayer,
582  activationLayer,
583  activationDesc,
585  name);
586  untouched.erase(baseLayer->GetGuid());
587  untouched.erase(activationLayer->GetGuid());
588  }
589  }
590  else if (baseLayer->GetParameters().m_Operation == BinaryOperation::Mul)
591  {
595  activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
596  &activationDesc);
597 
598  if (status)
599  {
600  FuseElementwiseBinaryLayer<ElementwiseBinaryLayer>(optimizationViews,
601  baseLayer,
602  activationLayer,
603  activationDesc,
605  name);
606  untouched.erase(baseLayer->GetGuid());
607  untouched.erase(activationLayer->GetGuid());
608  }
609  }
610  else if (baseLayer->GetParameters().m_Operation == BinaryOperation::Sub)
611  {
615  activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
616  &activationDesc);
617 
618  if (status)
619  {
620  FuseElementwiseBinaryLayer<ElementwiseBinaryLayer>(optimizationViews,
621  baseLayer,
622  activationLayer,
623  activationDesc,
625  name);
626  }
627  }
628  // No fusion available for other BinaryOperations
629  }
630  }
631  }
632  }
633  }
634  }
635 
636  // Separate reduce layer with multiple axes into multiple reduce layers with 1 axis.
637  if (base.GetType() == LayerType::Reduce)
638  {
639  ReduceLayer* baseLayer = PolymorphicDowncast<ReduceLayer*>(&base);
640  ReduceDescriptor reduceDescriptor = baseLayer->GetParameters();
641 
642  if (!reduceDescriptor.m_vAxis.empty() && reduceDescriptor.m_vAxis.size() > 1)
643  {
644  // Add new layers to the graph and connect them.
645  std::vector<IConnectableLayer*> layers = ChainReduceLayers<ReduceLayer>(optimizationViews,
646  baseLayer,
647  reduceDescriptor);
648 
649  // Replace existing baselayer with new subgraph.
650  ReplaceLayers<ReduceLayer>(optimizationViews, baseLayer, layers);
651  untouched.erase(baseLayer->GetGuid());
652  }
653  }
654 
655  // Special case to fuse padding into average pooling 2d for quantized datatype.
656  // Required to be done as a backend specific optimization as Neon does not support this special case.
657  if (base.GetType() == LayerType::Pooling2d)
658  {
659  Pooling2dLayer* baseLayer = PolymorphicDowncast<Pooling2dLayer*>(&base);
660  Pooling2dDescriptor poolingDescriptor = baseLayer->GetParameters();
661 
663  {
664  PadLayer* padLayer = PolymorphicDowncast<PadLayer*>(
666  if (padLayer->GetOutputSlot(0).GetNumConnections() == 1 &&
668  poolingDescriptor,
669  padLayer->GetOutputSlot().GetTensorInfo(),
670  true))
671  {
672  FoldPadIntoAveragePool2d<Pooling2dLayer>(optimizationViews, baseLayer,
673  poolingDescriptor, padLayer);
674  untouched.erase(baseLayer->GetGuid());
675  untouched.erase(padLayer->GetGuid());
676  }
677  }
678  }
679  }
680 
681  if (optimizationViews.GetSubstitutions().empty())
682  {
683  optimizationViews.AddUntouchedSubgraph(SubgraphView(subgraph));
684  }
685  else
686  {
687  ReportUntouchedLayers(optimizationViews, untouched);
688  }
689 
690  return optimizationViews;
691 }
692 
693 } // namespace armnn
armnn::ClDivisionWorkloadValidate
arm_compute::Status ClDivisionWorkloadValidate(const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
Definition: ClDivisionWorkload.cpp:18
IMemoryManager.hpp
armnn::BatchNormalizationLayer::m_Mean
std::shared_ptr< ConstTensorHandle > m_Mean
A unique pointer to store Mean values.
Definition: BatchNormalizationLayer.hpp:19
armnn::BackendId
Definition: BackendId.hpp:75
armnn::ElementwiseBinaryLayer
This layer represents a elementwiseBinary operation.
Definition: ElementwiseBinaryLayer.hpp:14
armnn::LayerType::FullyConnected
@ FullyConnected
armnn::Convolution2dDescriptor::m_BiasEnabled
bool m_BiasEnabled
Enable/disable bias.
Definition: Descriptors.hpp:570
armnn::FullyConnectedDescriptor::m_BiasEnabled
bool m_BiasEnabled
Enable/disable bias.
Definition: Descriptors.hpp:514
armnn::MemorySource::Undefined
@ Undefined
armnn::BatchNormalizationLayer
This layer represents a batch normalization operation.
Definition: BatchNormalizationLayer.hpp:15
armnn::InputSlot::GetConnectedOutputSlot
const OutputSlot * GetConnectedOutputSlot() const
Definition: Layer.hpp:56
armnn::ActivationDescriptor
An ActivationDescriptor for the ActivationLayer.
Definition: Descriptors.hpp:36
armnn::TensorHandleFactoryRegistry
Definition: TensorHandleFactoryRegistry.hpp:23
armnn::LayerType::ElementwiseBinary
@ ElementwiseBinary
ClSubtractionWorkload.hpp
armnn::FullyConnectedDescriptor
A FullyConnectedDescriptor for the FullyConnectedLayer.
Definition: Descriptors.hpp:495
armnn::ClBackend::GetLayerSupport
IBackendInternal::ILayerSupportSharedPtr GetLayerSupport() const override
Definition: ClBackend.cpp:253
IBackendContext.hpp
armnn::SubgraphView::beginIConnectable
IConnectableLayerIterator beginIConnectable()
Definition: SubgraphView.cpp:324
armnn::MemorySource::Malloc
@ Malloc
armnn::ClBackend::GetIdStatic
static const BackendId & GetIdStatic()
Definition: ClBackend.cpp:45
armnn::LayerType::Subtraction
@ Subtraction
armnn::IBackendInternal::IWorkloadFactoryPtr
std::unique_ptr< IWorkloadFactory > IWorkloadFactoryPtr
Definition: IBackendInternal.hpp:89
armnn::LayerType::Convolution2d
@ Convolution2d
armnn::ReduceDescriptor::m_vAxis
std::vector< uint32_t > m_vAxis
The indices of the dimensions to reduce.
Definition: Descriptors.hpp:1523
ClDepthwiseConvolutionWorkload.hpp
armnn::ReduceDescriptor
A ReduceDescriptor for the REDUCE operators.
Definition: Descriptors.hpp:1505
armnn::IRuntime::CreationOptions
Definition: IRuntime.hpp:85
armnn::MultiplicationLayer
This layer represents a multiplication operation.
Definition: MultiplicationLayer.hpp:14
PolymorphicDowncast.hpp
armnn::Layer
Definition: Layer.hpp:217
armnn::ModelOptions
std::vector< BackendOptions > ModelOptions
Definition: BackendOptions.hpp:18
armnn::ClBackend::m_UsingCustomAllocator
bool m_UsingCustomAllocator
Definition: ClBackend.hpp:300
armnn::ClBatchNormalizationValidate
arm_compute::Status ClBatchNormalizationValidate(const TensorInfo &input, const TensorInfo &output, const TensorInfo &mean, const TensorInfo &var, const TensorInfo &beta, const TensorInfo &gamma, const BatchNormalizationDescriptor &descriptor, const ActivationDescriptor *activationDescriptor)
Definition: ClBatchNormalizationFloatWorkload.cpp:19
ArmComputeSubgraphUtils.hpp
armnn::DepthwiseConvolution2dDescriptor::m_BiasEnabled
bool m_BiasEnabled
Enable/disable bias.
Definition: Descriptors.hpp:696
ClAdditionWorkload.hpp
armnn::ClBackend::CreateMemoryManager
IBackendInternal::IMemoryManagerUniquePtr CreateMemoryManager() const override
Definition: ClBackend.cpp:51
ClTensorHandleFactory.hpp
armnn::LayerType::Pad
@ Pad
armnn::LayerType::Addition
@ Addition
armnn::ClTensorHandleFactory::GetIdStatic
static const FactoryId & GetIdStatic()
Definition: ClTensorHandleFactory.cpp:93
armnn::LayerType::BatchNormalization
@ BatchNormalization
ClBackendModelContext.hpp
armnn::LayerType::Reduce
@ Reduce
armnn::ClBackendContext
Definition: ClBackendContext.hpp:17
armnn::TensorHandleFactoryRegistry::RegisterFactory
void RegisterFactory(std::unique_ptr< ITensorHandleFactory > allocator)
Register a TensorHandleFactory and transfer ownership.
Definition: TensorHandleFactoryRegistry.cpp:12
ClFullyConnectedWorkload.hpp
armnn::LayerType::Division
@ Division
armnn::IBackendInternal::IMemoryManagerSharedPtr
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
Definition: IBackendInternal.hpp:99
armnn::ReportUntouchedLayers
void ReportUntouchedLayers(OptimizationViews &optimizationViews, std::map< LayerGuid, Layer * > untouched)
Definition: SubgraphUtils.hpp:52
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::IBackendInternal::IMemoryManagerUniquePtr
std::unique_ptr< IMemoryManager > IMemoryManagerUniquePtr
Definition: IBackendInternal.hpp:98
armnn::SubgraphView::endIConnectable
IConnectableLayerIterator endIConnectable()
Definition: SubgraphView.cpp:329
armnn::optimizations::pad_fold::TryFoldPadIntoLayer2d
bool TryFoldPadIntoLayer2d(const PadDescriptor &padDescriptor, Descriptor &layerDescriptor, const TensorInfo &tensorInfo)
Definition: FoldPadIntoLayer2d.hpp:88
armnn::OutputSlot::GetTensorInfo
const TensorInfo & GetTensorInfo() const override
Definition: Layer.cpp:92
armnn::OptimizationViews
Definition: OptimizationViews.hpp:17
ClMultiplicationWorkload.hpp
ClLayerSupport.hpp
armnn::ClBackend::RegisterTensorHandleFactories
void RegisterTensorHandleFactories(TensorHandleFactoryRegistry &registry) override
(Optional) Register TensorHandleFactories Either this method or CreateMemoryManager() and IWorkloadFa...
Definition: ClBackend.cpp:176
ClConvolution2dWorkload.hpp
armnn::LayerType::Activation
@ Activation
ClBackendContext.hpp
armnn::BinaryOperation::Sub
@ Sub
armnn::ClMultiplicationWorkloadValidate
arm_compute::Status ClMultiplicationWorkloadValidate(const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
Definition: ClMultiplicationWorkload.cpp:18
armnn::ClBackendModelContext
The ClBackendModelContext is used to pass in CL specific backend ModelOptions.
Definition: ClBackendModelContext.hpp:28
armnn::ClBackendId
constexpr const char * ClBackendId()
Definition: ClBackendId.hpp:10
ClDivisionWorkload.hpp
armnn::ClSubtractionValidate
arm_compute::Status ClSubtractionValidate(const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
Definition: ClSubtractionWorkload.cpp:46
ClWorkloadFactory.hpp
armnn::IBackendInternal::IBackendSpecificModelContextPtr
std::shared_ptr< IBackendModelContext > IBackendSpecificModelContextPtr
Definition: IBackendInternal.hpp:96
armnn::LayerType::DepthwiseConvolution2d
@ DepthwiseConvolution2d
BaseMemoryManager.hpp
armnn::ClFullyConnectedWorkloadValidate
arm_compute::Status ClFullyConnectedWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const TensorInfo &weights, const Optional< TensorInfo > &biases, const FullyConnectedDescriptor &descriptor, const ActivationDescriptor *activationDescriptor)
Definition: ClFullyConnectedWorkload.cpp:19
armnn::Layer::GetOutputSlot
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
Definition: Layer.hpp:326
armnn::OptimizationViews::AddUntouchedSubgraph
void AddUntouchedSubgraph(SubgraphView &&subgraph)
Definition: OptimizationViews.hpp:48
armnn::ClBackend::GetDefaultAllocator
std::unique_ptr< ICustomAllocator > GetDefaultAllocator() const override
Returns the default memory allocator for the backend.
Definition: ClBackend.cpp:271
ClReduceWorkload.hpp
armnn::SubtractionLayer
This layer represents a subtraction operation.
Definition: SubtractionLayer.hpp:14
armnn::TensorHandleFactoryRegistry::RegisterCopyAndImportFactoryPair
void RegisterCopyAndImportFactoryPair(ITensorHandleFactory::FactoryId copyFactoryId, ITensorHandleFactory::FactoryId importFactoryId)
Register a pair of TensorHandleFactory Id for Memory Copy and TensorHandleFactory Id for Memory Impor...
Definition: TensorHandleFactoryRegistry.cpp:66
armnn::ClDepthwiseConvolutionWorkloadValidate
arm_compute::Status ClDepthwiseConvolutionWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const DepthwiseConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, const ActivationDescriptor *activationDescriptor)
Definition: ClDepthwiseConvolutionWorkload.cpp:26
armnn::BinaryOperation::Mul
@ Mul
Optimizer.hpp
armnn::Layer::GetType
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
Definition: Layer.hpp:273
armnn::LayerType::Pooling2d
@ Pooling2d
armnn::SubgraphView
The SubgraphView class represents a subgraph of a Graph.
Definition: SubgraphView.hpp:31
armnn::IBackendInternal::IBackendProfilingContextPtr
std::shared_ptr< arm::pipe::IBackendProfilingContext > IBackendProfilingContextPtr
This is the bridge between backend and backend profiling we'll keep it in the backend namespace.
Definition: IBackendInternal.hpp:92
ArmComputeUtils.hpp
armnn::Layer::BeginOutputSlots
std::vector< OutputSlot >::iterator BeginOutputSlots()
Definition: Layer.hpp:253
armnn::Status
Status
Definition: Types.hpp:42
ClBackend.hpp
armnn::ReduceLayer
This layer represents a reduction operation.
Definition: ReduceLayer.hpp:14
armnn::ClImportTensorHandleFactory::GetIdStatic
static const FactoryId & GetIdStatic()
Definition: ClImportTensorHandleFactory.cpp:93
armnn::OutputSlot::GetOwningLayer
Layer & GetOwningLayer() const
Definition: Layer.hpp:119
armnn::IBackendInternal::ILayerSupportSharedPtr
std::shared_ptr< ILayerSupport > ILayerSupportSharedPtr
Definition: IBackendInternal.hpp:94
armnn::ClBackend::OptimizeSubgraphView
OptimizationViews OptimizeSubgraphView(const SubgraphView &subgraph, const ModelOptions &modelOptions) const override
Definition: ClBackend.cpp:276
armnn::FullyConnectedLayer
This layer represents a fully connected operation.
Definition: FullyConnectedLayer.hpp:15
BackendRegistry.hpp
armnn::PadLayer
This layer represents a pad operation.
Definition: PadLayer.hpp:14
armnn::BatchNormalizationLayer::m_Beta
std::shared_ptr< ConstTensorHandle > m_Beta
A unique pointer to store Beta values.
Definition: BatchNormalizationLayer.hpp:23
armnn::ClBackend::CreateWorkloadFactory
IBackendInternal::IWorkloadFactoryPtr CreateWorkloadFactory(const IBackendInternal::IMemoryManagerSharedPtr &memoryManager=nullptr) const override
Definition: ClBackend.cpp:60
armnn::ClBackend::CreateBackendSpecificModelContext
IBackendInternal::IBackendSpecificModelContextPtr CreateBackendSpecificModelContext(const ModelOptions &modelOptions) const override
Definition: ClBackend.cpp:247
armnn::Pooling2dLayer
This layer represents a pooling 2d operation.
Definition: Pooling2dLayer.hpp:13
armnn::Layer::EndOutputSlots
std::vector< OutputSlot >::iterator EndOutputSlots()
Definition: Layer.hpp:254
armnn::Layer::GetInputSlot
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
Definition: Layer.hpp:324
armnn::ClBackend::GetHandleFactoryPreferences
std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences() const override
(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.
Definition: ClBackend.cpp:170
armnn::Layer::GetAdditionalInformation
std::shared_ptr< T > GetAdditionalInformation() const
Definition: Layer.hpp:355
armnn::BinaryOperation::Add
@ Add
armnn::ClBackendModelContext::IsFastMathEnabled
bool IsFastMathEnabled() const
Definition: ClBackendModelContext.cpp:66
armnn::DepthwiseConvolution2dLayer
This layer represents a depthwise convolution 2d operation.
Definition: DepthwiseConvolution2dLayer.hpp:15
armnn::Layer::GetGuid
LayerGuid GetGuid() const final
Returns the unique id of the layer.
Definition: Layer.hpp:330
armnn::ClBackend::m_CustomAllocator
std::shared_ptr< ClBackendCustomAllocatorWrapper > m_CustomAllocator
Definition: ClBackend.hpp:299
ClBatchNormalizationFloatWorkload.hpp
armnn::ElementwiseBinaryDescriptor::m_Operation
BinaryOperation m_Operation
Specifies the elementwiseBinary operation to execute.
Definition: Descriptors.hpp:125
armnn::ClBackend::CreateBackendContext
IBackendInternal::IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions &) const override
Create the runtime context of the backend.
Definition: ClBackend.cpp:236
armnn::Pooling2dDescriptor
A Pooling2dDescriptor for the Pooling2dLayer.
Definition: Descriptors.hpp:359
armnn::AdditionLayer
This layer represents an addition operation.
Definition: AdditionLayer.hpp:13
armnn::OutputSlot::GetNumConnections
unsigned int GetNumConnections() const override
Definition: Layer.hpp:145
armnn::Optional
Definition: Optional.hpp:270
Descriptors.hpp
armnn::IBackendInternal::IBackendContextPtr
std::unique_ptr< IBackendContext > IBackendContextPtr
Definition: IBackendInternal.hpp:90
ClBackendDefaultAllocator.hpp
armnn::IBackendInternal::IBackendProfilingPtr
std::unique_ptr< arm::pipe::IBackendProfiling > IBackendProfilingPtr
Definition: IBackendInternal.hpp:93
armnn::OptimizationViews::GetSubstitutions
const Substitutions & GetSubstitutions() const
Definition: OptimizationViews.hpp:53
armnn::TensorHandleFactoryRegistry::RegisterMemoryManager
void RegisterMemoryManager(std::shared_ptr< IMemoryManager > memoryManger)
Register a memory manager with shared ownership.
Definition: TensorHandleFactoryRegistry.cpp:34
armnn::ClConvolution2dWorkloadValidate
arm_compute::Status ClConvolution2dWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const Convolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, bool isFastMathEnabled, const ActivationDescriptor *activationDescriptor)
Definition: ClConvolution2dWorkload.cpp:23
armnn::Layer::GetName
const char * GetName() const override
Returns the name of the layer.
Definition: Layer.hpp:319
armnn::DivisionLayer
This layer represents a division operation.
Definition: DivisionLayer.hpp:14
armnn::Convolution2dLayer
This layer represents a convolution 2d operation.
Definition: Convolution2dLayer.hpp:15
armnn::ClAdditionValidate
arm_compute::Status ClAdditionValidate(const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
Definition: ClAdditionWorkload.cpp:45
armnn::BatchNormalizationLayer::m_Gamma
std::shared_ptr< ConstTensorHandle > m_Gamma
A unique pointer to store Gamma values.
Definition: BatchNormalizationLayer.hpp:25
armnn::LayerWithParameters::GetParameters
const Parameters & GetParameters() const override
If the layer has a descriptor return it.
Definition: LayerWithParameters.hpp:19
armnn::MemorySourceFlags
unsigned int MemorySourceFlags
Definition: MemorySources.hpp:15
armnn::LayerType::Multiplication
@ Multiplication
armnn::ClLayerSupport
Definition: ClLayerSupport.hpp:14
armnn::BinaryOperation::Div
@ Div
armnn::BatchNormalizationLayer::m_Variance
std::shared_ptr< ConstTensorHandle > m_Variance
A unique pointer to store Variance values.
Definition: BatchNormalizationLayer.hpp:21
armnn::ClBackend::CreateBackendProfilingContext
IBackendInternal::IBackendProfilingContextPtr CreateBackendProfilingContext(const IRuntime::CreationOptions &, IBackendProfilingPtr &backendProfiling) override
Create context specifically used for profiling interaction from backends.
Definition: ClBackend.cpp:241
ClBackendId.hpp
ClImportTensorHandleFactory.hpp