38 #include <arm_compute/core/Types.h> 39 #include <arm_compute/runtime/CL/CLBufferAllocator.h> 56 return std::make_unique<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
62 return std::make_unique<ClWorkloadFactory>(
63 PolymorphicPointerDowncast<ClMemoryManager>(memoryManager));
69 return std::make_unique<ClWorkloadFactory>(
76 std::shared_ptr<ClMemoryManager> memoryManager;
83 memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
87 registry.
RegisterFactory(std::make_unique<ClTensorHandleFactory>(memoryManager));
91 return std::make_unique<ClWorkloadFactory>(
92 PolymorphicPointerDowncast<ClMemoryManager>(memoryManager));
98 std::shared_ptr<ClMemoryManager> memoryManager;
105 memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
109 registry.
RegisterFactory(std::make_unique<ClTensorHandleFactory>(memoryManager));
110 registry.
RegisterFactory(std::make_unique<ClImportTensorHandleFactory>(
113 return std::make_unique<ClWorkloadFactory>(
123 std::shared_ptr<ClMemoryManager> memoryManager;
130 memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
134 registry.
RegisterFactory(std::make_unique<ClTensorHandleFactory>(memoryManager));
135 registry.
RegisterFactory(std::make_unique<ClImportTensorHandleFactory>(inputFlags, outputFlags));
137 return std::make_unique<ClWorkloadFactory>(
149 std::shared_ptr<ClMemoryManager> memoryManager;
156 memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
160 registry.
RegisterFactory(std::make_unique<ClTensorHandleFactory>(memoryManager));
161 registry.
RegisterFactory(std::make_unique<ClImportTensorHandleFactory>(
169 std::shared_ptr<ClMemoryManager> memoryManager;
176 memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
180 registry.
RegisterFactory(std::make_unique<ClTensorHandleFactory>(memoryManager));
181 registry.
RegisterFactory(std::make_unique<ClImportTensorHandleFactory>(inputFlags, outputFlags));
229 auto it = subgraph.
end();
230 bool isFastMathEnabled =
false;
231 std::map<LayerGuid, Layer*> untouched;
233 while (it != subgraph.
begin())
237 untouched.insert({base.
GetGuid(), &base});
241 #if defined(ARMCOMPUTECL_ENABLED) 253 while (it != subgraph.
begin())
267 if (output->GetNumConnections() == 1)
269 for (
auto&& childInput : output->GetConnections())
272 (checkDataTypeInputandOutput(childInput->GetOwningLayer())))
274 Layer& child = childInput->GetOwningLayer();
276 auto* activationLayer = PolymorphicDowncast<ActivationLayer*>(&child);
278 const std::string name = std::string(
"fused-") + child.
GetName() + std::string(
"-into-") +
292 biases = baseLayer->
m_Bias->GetTensorInfo();
297 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
299 baseLayer->
m_Weight->GetTensorInfo(),
306 FuseLayerWithWeightsAndBiases<Convolution2dLayer>(optimizationViews,
311 untouched.erase(baseLayer->GetGuid());
312 untouched.erase(activationLayer->GetGuid());
318 PolymorphicDowncast<DepthwiseConvolution2dLayer*>(&base);
324 biases = baseLayer->
m_Bias->GetTensorInfo();
329 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
331 baseLayer->
m_Weight->GetTensorInfo(),
337 FuseLayerWithWeightsAndBiases<DepthwiseConvolution2dLayer>(optimizationViews,
342 untouched.erase(baseLayer->GetGuid());
343 untouched.erase(activationLayer->GetGuid());
352 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
353 baseLayer->
m_Weight->GetTensorInfo(),
354 baseLayer->
m_Bias->GetTensorInfo(),
360 FuseLayerWithWeightsAndBiases<FullyConnectedLayer>(optimizationViews,
365 untouched.erase(baseLayer->GetGuid());
366 untouched.erase(activationLayer->GetGuid());
372 PolymorphicDowncast<BatchNormalizationLayer*>(&base);
376 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
377 baseLayer->
m_Mean->GetTensorInfo(),
379 baseLayer->
m_Beta->GetTensorInfo(),
380 baseLayer->
m_Gamma->GetTensorInfo(),
387 FuseLayerWithParameters<BatchNormalizationLayer>(optimizationViews,
393 replacementLayer->
m_Beta = std::move(baseLayer->m_Beta);
394 replacementLayer->
m_Gamma = std::move(baseLayer->m_Gamma);
395 replacementLayer->
m_Mean = std::move(baseLayer->m_Mean);
396 replacementLayer->
m_Variance = std::move(baseLayer->m_Variance);
397 untouched.erase(baseLayer->GetGuid());
398 untouched.erase(activationLayer->GetGuid());
403 AdditionLayer* baseLayer = PolymorphicDowncast<AdditionLayer*>(&base);
408 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
413 FuseLayerWithoutParameters<AdditionLayer>(optimizationViews,
418 untouched.erase(baseLayer->GetGuid());
419 untouched.erase(activationLayer->GetGuid());
424 DivisionLayer* baseLayer = PolymorphicDowncast<DivisionLayer*>(&base);
429 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
434 FuseLayerWithoutParameters<DivisionLayer>(optimizationViews,
439 untouched.erase(baseLayer->GetGuid());
440 untouched.erase(activationLayer->GetGuid());
450 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
455 FuseLayerWithoutParameters<MultiplicationLayer>(optimizationViews,
460 untouched.erase(baseLayer->GetGuid());
461 untouched.erase(activationLayer->GetGuid());
466 SubtractionLayer* baseLayer = PolymorphicDowncast<SubtractionLayer*>(&base);
471 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
476 FuseLayerWithoutParameters<SubtractionLayer>(optimizationViews,
481 untouched.erase(baseLayer->GetGuid());
482 untouched.erase(activationLayer->GetGuid());
494 ReduceLayer* baseLayer = PolymorphicDowncast<ReduceLayer*>(&base);
497 if (!reduceDescriptor.m_vAxis.empty() && reduceDescriptor.m_vAxis.size() > 1)
500 std::vector<Layer*> layers = ChainReduceLayers<ReduceLayer>(optimizationViews,
505 ReplaceLayers<ReduceLayer>(optimizationViews, baseLayer, layers);
506 untouched.erase(baseLayer->GetGuid());
520 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.
std::vector< OptimizationPtr > Optimizations
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.
IBackendInternal::Optimizations GetOptimizations() const override
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