39 #include <arm_compute/core/Types.h> 40 #include <arm_compute/runtime/CL/CLBufferAllocator.h> 57 return std::make_unique<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
63 return std::make_unique<ClWorkloadFactory>(
64 PolymorphicPointerDowncast<ClMemoryManager>(memoryManager));
70 return std::make_unique<ClWorkloadFactory>(
77 std::shared_ptr<ClMemoryManager> memoryManager;
84 memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
88 registry.
RegisterFactory(std::make_unique<ClTensorHandleFactory>(memoryManager));
92 return std::make_unique<ClWorkloadFactory>(
93 PolymorphicPointerDowncast<ClMemoryManager>(memoryManager));
99 std::shared_ptr<ClMemoryManager> memoryManager;
106 memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
110 registry.
RegisterFactory(std::make_unique<ClTensorHandleFactory>(memoryManager));
111 registry.
RegisterFactory(std::make_unique<ClImportTensorHandleFactory>(
114 return std::make_unique<ClWorkloadFactory>(
124 std::shared_ptr<ClMemoryManager> memoryManager;
131 memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
135 registry.
RegisterFactory(std::make_unique<ClTensorHandleFactory>(memoryManager));
136 registry.
RegisterFactory(std::make_unique<ClImportTensorHandleFactory>(inputFlags, outputFlags));
138 return std::make_unique<ClWorkloadFactory>(
150 std::shared_ptr<ClMemoryManager> memoryManager;
157 memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
161 registry.
RegisterFactory(std::make_unique<ClTensorHandleFactory>(memoryManager));
162 registry.
RegisterFactory(std::make_unique<ClImportTensorHandleFactory>(
170 std::shared_ptr<ClMemoryManager> memoryManager;
177 memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
181 registry.
RegisterFactory(std::make_unique<ClTensorHandleFactory>(memoryManager));
182 registry.
RegisterFactory(std::make_unique<ClImportTensorHandleFactory>(inputFlags, outputFlags));
222 return std::make_unique<ClBackendDefaultAllocator>();
230 auto it = subgraph.
end();
231 bool isFastMathEnabled =
false;
232 std::map<LayerGuid, Layer*> untouched;
234 while (it != subgraph.
begin())
238 untouched.insert({base.
GetGuid(), &base});
242 #if defined(ARMCOMPUTECL_ENABLED) 254 while (it != subgraph.
begin())
268 if (output->GetNumConnections() == 1)
270 for (
auto&& childInput : output->GetConnections())
273 (checkDataTypeInputandOutput(childInput->GetOwningLayer())))
275 Layer& child = childInput->GetOwningLayer();
277 auto* activationLayer = PolymorphicDowncast<ActivationLayer*>(&child);
279 const std::string name = std::string(
"fused-") + child.
GetName() + std::string(
"-into-") +
293 biases = baseLayer->
m_Bias->GetTensorInfo();
298 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
300 baseLayer->
m_Weight->GetTensorInfo(),
307 FuseLayerWithWeightsAndBiases<Convolution2dLayer>(optimizationViews,
312 untouched.erase(baseLayer->GetGuid());
313 untouched.erase(activationLayer->GetGuid());
319 PolymorphicDowncast<DepthwiseConvolution2dLayer*>(&base);
325 biases = baseLayer->
m_Bias->GetTensorInfo();
330 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
332 baseLayer->
m_Weight->GetTensorInfo(),
338 FuseLayerWithWeightsAndBiases<DepthwiseConvolution2dLayer>(optimizationViews,
343 untouched.erase(baseLayer->GetGuid());
344 untouched.erase(activationLayer->GetGuid());
353 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
354 baseLayer->
m_Weight->GetTensorInfo(),
355 baseLayer->
m_Bias->GetTensorInfo(),
361 FuseLayerWithWeightsAndBiases<FullyConnectedLayer>(optimizationViews,
366 untouched.erase(baseLayer->GetGuid());
367 untouched.erase(activationLayer->GetGuid());
373 PolymorphicDowncast<BatchNormalizationLayer*>(&base);
377 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
378 baseLayer->
m_Mean->GetTensorInfo(),
380 baseLayer->
m_Beta->GetTensorInfo(),
381 baseLayer->
m_Gamma->GetTensorInfo(),
388 FuseLayerWithParameters<BatchNormalizationLayer>(optimizationViews,
394 replacementLayer->
m_Beta = std::move(baseLayer->m_Beta);
395 replacementLayer->
m_Gamma = std::move(baseLayer->m_Gamma);
396 replacementLayer->
m_Mean = std::move(baseLayer->m_Mean);
397 replacementLayer->
m_Variance = std::move(baseLayer->m_Variance);
398 untouched.erase(baseLayer->GetGuid());
399 untouched.erase(activationLayer->GetGuid());
404 AdditionLayer* baseLayer = PolymorphicDowncast<AdditionLayer*>(&base);
409 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
414 FuseLayerWithoutParameters<AdditionLayer>(optimizationViews,
419 untouched.erase(baseLayer->GetGuid());
420 untouched.erase(activationLayer->GetGuid());
425 DivisionLayer* baseLayer = PolymorphicDowncast<DivisionLayer*>(&base);
430 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
435 FuseLayerWithoutParameters<DivisionLayer>(optimizationViews,
440 untouched.erase(baseLayer->GetGuid());
441 untouched.erase(activationLayer->GetGuid());
451 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
456 FuseLayerWithoutParameters<MultiplicationLayer>(optimizationViews,
461 untouched.erase(baseLayer->GetGuid());
462 untouched.erase(activationLayer->GetGuid());
467 SubtractionLayer* baseLayer = PolymorphicDowncast<SubtractionLayer*>(&base);
472 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
477 FuseLayerWithoutParameters<SubtractionLayer>(optimizationViews,
482 untouched.erase(baseLayer->GetGuid());
483 untouched.erase(activationLayer->GetGuid());
495 ReduceLayer* baseLayer = PolymorphicDowncast<ReduceLayer*>(&base);
498 if (!reduceDescriptor.m_vAxis.empty() && reduceDescriptor.m_vAxis.size() > 1)
501 std::vector<Layer*> layers = ChainReduceLayers<ReduceLayer>(optimizationViews,
506 ReplaceLayers<ReduceLayer>(optimizationViews, baseLayer, layers);
507 untouched.erase(baseLayer->GetGuid());
521 return optimizationViews;
arm_compute::Status ClAdditionValidate(const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
bool m_BiasEnabled
Enable/disable bias.
void RegisterMemoryManager(std::shared_ptr< IMemoryManager > memoryManger)
Register a memory manager with shared ownership.
arm_compute::Status ClFullyConnectedWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const TensorInfo &weights, const TensorInfo &biases, const FullyConnectedDescriptor &descriptor, const ActivationDescriptor *activationDescriptor)
static const FactoryId & GetIdStatic()
This layer represents a batch normalization operation.
std::unique_ptr< IWorkloadFactory > IWorkloadFactoryPtr
bool m_BiasEnabled
Enable/disable bias.
arm_compute::Status ClDivisionWorkloadValidate(const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
const Parameters & GetParameters() const
This layer represents a depthwise convolution 2d operation.
constexpr const char * ClBackendId()
std::vector< BackendOptions > ModelOptions
void RegisterFactory(std::unique_ptr< ITensorHandleFactory > allocator)
Register a TensorHandleFactory and transfer ownership.
void ReportUntouchedLayers(OptimizationViews &optimizationViews, std::map< LayerGuid, Layer *> untouched)
arm_compute::Status ClSubtractionValidate(const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
std::shared_ptr< ConstTensorHandle > m_Weight
A unique pointer to store Weight values.
std::shared_ptr< ConstTensorHandle > m_Mean
A unique pointer to store Mean values.
std::shared_ptr< ClBackendCustomAllocatorWrapper > m_CustomAllocator
unsigned int MemorySourceFlags
Copyright (c) 2021 ARM Limited and Contributors.
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)
std::unique_ptr< IMemoryManager > IMemoryManagerUniquePtr
IBackendInternal::IMemoryManagerUniquePtr CreateMemoryManager() const override
This layer represents a reduction operation.
std::shared_ptr< ConstTensorHandle > m_Beta
A unique pointer to store Beta values.
void RegisterTensorHandleFactories(TensorHandleFactoryRegistry ®istry) override
(Optional) Register TensorHandleFactories Either this method or CreateMemoryManager() and IWorkloadFa...
The SubgraphView class represents a subgraph of a Graph.
IBackendInternal::IBackendSpecificModelContextPtr CreateBackendSpecificModelContext(const ModelOptions &modelOptions) const override
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
std::unique_ptr< armnn::profiling::IBackendProfiling > IBackendProfilingPtr
OptimizationViews OptimizeSubgraphView(const SubgraphView &subgraph, const ModelOptions &modelOptions) const override
This layer represents a fully connected operation.
std::shared_ptr< ConstTensorHandle > m_Weight
A unique pointer to store Weight values.
std::shared_ptr< IBackendModelContext > IBackendSpecificModelContextPtr
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
A ReduceDescriptor for the REDUCE operators.
IBackendInternal::IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions &) const override
Create the runtime context of the backend.
std::shared_ptr< ConstTensorHandle > m_Bias
A unique pointer to store Bias values.
arm_compute::Status ClMultiplicationWorkloadValidate(const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences() const override
(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
bool IsFastMathEnabled() const
std::shared_ptr< ConstTensorHandle > m_Gamma
A unique pointer to store Gamma values.
static const FactoryId & GetIdStatic()
An ActivationDescriptor for the ActivationLayer.
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)
void AddUntouchedSubgraph(SubgraphView &&subgraph)
std::shared_ptr< ConstTensorHandle > m_Variance
A unique pointer to store Variance values.
std::shared_ptr< ConstTensorHandle > m_Bias
A unique pointer to store Bias values.
IBackendInternal::IWorkloadFactoryPtr CreateWorkloadFactory(const IBackendInternal::IMemoryManagerSharedPtr &memoryManager=nullptr) const override
This layer represents an addition operation.
std::shared_ptr< ILayerSupport > ILayerSupportSharedPtr
const Substitutions & GetSubstitutions() const
This layer represents a subtraction operation.
std::vector< OutputSlot >::iterator BeginOutputSlots()
IBackendInternal::ILayerSupportSharedPtr GetLayerSupport() const override
std::shared_ptr< ConstTensorHandle > m_Bias
A unique pointer to store Bias values.
std::shared_ptr< ConstTensorHandle > m_Weight
A unique pointer to store Weight values.
IBackendInternal::IBackendProfilingContextPtr CreateBackendProfilingContext(const IRuntime::CreationOptions &, IBackendProfilingPtr &backendProfiling) override
Create context specifically used for profiling interaction from backends.
bool m_UsingCustomAllocator
This layer represents a division operation.
std::vector< OutputSlot >::iterator EndOutputSlots()
const char * GetName() const override
Returns the name of the layer.
This layer represents a convolution 2d operation.
The ClBackendModelContext is used to pass in CL specific backend ModelOptions.
This layer represents a multiplication operation.
std::unique_ptr< ICustomAllocator > GetDefaultAllocator() const override
Returns the default memory allocator for the backend.
const TensorInfo & GetTensorInfo() const override
static const BackendId & GetIdStatic()
arm_compute::Status ClDepthwiseConvolutionWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const DepthwiseConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, const ActivationDescriptor *activationDescriptor)
std::shared_ptr< armnn::profiling::IBackendProfilingContext > IBackendProfilingContextPtr
This is the bridge between backend and backend profiling we'll keep it in the backend namespace...
std::shared_ptr< T > GetAdditionalInformation() const
LayerGuid GetGuid() const final
Returns the unique id of the layer.
std::unique_ptr< IBackendContext > IBackendContextPtr