36 #include <arm_compute/core/Types.h> 37 #include <arm_compute/runtime/CL/CLBufferAllocator.h> 50 return std::make_unique<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
56 return std::make_unique<ClWorkloadFactory>(
57 PolymorphicPointerDowncast<ClMemoryManager>(memoryManager));
63 return std::make_unique<ClWorkloadFactory>(
70 auto memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
73 registry.
RegisterFactory(std::make_unique<ClTensorHandleFactory>(memoryManager));
75 return std::make_unique<ClWorkloadFactory>(
76 PolymorphicPointerDowncast<ClMemoryManager>(memoryManager));
82 auto memoryManager = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
85 registry.
RegisterFactory(std::make_unique<ClTensorHandleFactory>(memoryManager));
87 return std::make_unique<ClWorkloadFactory>(
98 auto mgr = std::make_shared<ClMemoryManager>(std::make_unique<arm_compute::CLBufferAllocator>());
101 registry.
RegisterFactory(std::make_unique<ClTensorHandleFactory>(mgr));
149 auto it = subgraph.
end();
150 bool isFastMathEnabled =
false;
151 std::map<LayerGuid, Layer*> untouched;
153 while (it != subgraph.
begin())
157 untouched.insert({base.
GetGuid(), &base});
161 #if defined(ARMCOMPUTECL_ENABLED) 173 while (it != subgraph.
begin())
186 if (output->GetNumConnections() == 1)
188 for (
auto&& childInput : output->GetConnections())
191 (checkDataTypeInputandOutput(childInput->GetOwningLayer())))
193 Layer& child = childInput->GetOwningLayer();
195 auto* activationLayer = PolymorphicDowncast<ActivationLayer*>(&child);
197 const std::string name = std::string(
"fused-") + child.
GetName() + std::string(
"-into-") +
211 biases = baseLayer->
m_Bias->GetTensorInfo();
216 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
218 baseLayer->
m_Weight->GetTensorInfo(),
225 FuseLayerWithWeightsAndBiases<Convolution2dLayer>(optimizationViews,
230 untouched.erase(baseLayer->GetGuid());
231 untouched.erase(activationLayer->GetGuid());
237 PolymorphicDowncast<DepthwiseConvolution2dLayer*>(&base);
243 biases = baseLayer->
m_Bias->GetTensorInfo();
248 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
250 baseLayer->
m_Weight->GetTensorInfo(),
256 FuseLayerWithWeightsAndBiases<DepthwiseConvolution2dLayer>(optimizationViews,
261 untouched.erase(baseLayer->GetGuid());
262 untouched.erase(activationLayer->GetGuid());
271 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
272 baseLayer->
m_Weight->GetTensorInfo(),
273 baseLayer->
m_Bias->GetTensorInfo(),
279 FuseLayerWithWeightsAndBiases<FullyConnectedLayer>(optimizationViews,
284 untouched.erase(baseLayer->GetGuid());
285 untouched.erase(activationLayer->GetGuid());
291 PolymorphicDowncast<BatchNormalizationLayer*>(&base);
295 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
296 baseLayer->
m_Mean->GetTensorInfo(),
298 baseLayer->
m_Beta->GetTensorInfo(),
299 baseLayer->
m_Gamma->GetTensorInfo(),
306 FuseLayerWithParameters<BatchNormalizationLayer>(optimizationViews,
312 replacementLayer->
m_Beta = std::move(baseLayer->m_Beta);
313 replacementLayer->
m_Gamma = std::move(baseLayer->m_Gamma);
314 replacementLayer->
m_Mean = std::move(baseLayer->m_Mean);
315 replacementLayer->
m_Variance = std::move(baseLayer->m_Variance);
316 untouched.erase(baseLayer->GetGuid());
317 untouched.erase(activationLayer->GetGuid());
322 AdditionLayer* baseLayer = PolymorphicDowncast<AdditionLayer*>(&base);
327 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
332 FuseLayerWithoutParameters<AdditionLayer>(optimizationViews,
337 untouched.erase(baseLayer->GetGuid());
338 untouched.erase(activationLayer->GetGuid());
343 DivisionLayer* baseLayer = PolymorphicDowncast<DivisionLayer*>(&base);
348 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
353 FuseLayerWithoutParameters<DivisionLayer>(optimizationViews,
358 untouched.erase(baseLayer->GetGuid());
359 untouched.erase(activationLayer->GetGuid());
369 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
374 FuseLayerWithoutParameters<MultiplicationLayer>(optimizationViews,
379 untouched.erase(baseLayer->GetGuid());
380 untouched.erase(activationLayer->GetGuid());
385 SubtractionLayer* baseLayer = PolymorphicDowncast<SubtractionLayer*>(&base);
390 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
395 FuseLayerWithoutParameters<SubtractionLayer>(optimizationViews,
400 untouched.erase(baseLayer->GetGuid());
401 untouched.erase(activationLayer->GetGuid());
420 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
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
This layer represents a depthwise convolution 2d operation.
std::unique_ptr< ScopedCpuTensorHandle > m_Bias
A unique pointer to store Bias values.
constexpr const char * ClBackendId()
std::unique_ptr< ScopedCpuTensorHandle > m_Bias
A unique pointer to store Bias values.
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::unique_ptr< ScopedCpuTensorHandle > m_Gamma
A unique pointer to store Gamma values.
std::unique_ptr< ScopedCpuTensorHandle > m_Variance
A unique pointer to store Variance values.
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
void RegisterTensorHandleFactories(TensorHandleFactoryRegistry ®istry) override
(Optional) Register TensorHandleFactories Either this method or CreateMemoryManager() and IWorkloadFa...
std::unique_ptr< ScopedCpuTensorHandle > m_Beta
A unique pointer to store Beta values.
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::unique_ptr< ScopedCpuTensorHandle > m_Mean
A unique pointer to store Mean values.
std::shared_ptr< IBackendModelContext > IBackendSpecificModelContextPtr
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
IBackendInternal::IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions &) const override
Create the runtime context of the backend.
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight 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
An ActivationDescriptor for the ActivationLayer.
void AddUntouchedSubgraph(SubgraphView &&subgraph)
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
IBackendInternal::IBackendProfilingContextPtr CreateBackendProfilingContext(const IRuntime::CreationOptions &, IBackendProfilingPtr &backendProfiling) override
Create context specifically used for profiling interaction from backends.
std::unique_ptr< ScopedCpuTensorHandle > m_Bias
A unique pointer to store Bias values.
This layer represents a division operation.
std::vector< OutputSlot >::iterator EndOutputSlots()
arm_compute::Status ClBatchNormalizationValidate(const TensorInfo &input, const TensorInfo &output, const TensorInfo &mean, const TensorInfo &var, const TensorInfo &beta, const TensorInfo &gamma, const BatchNormalizationDescriptor &desc, const ActivationDescriptor *activationDescriptor)
const char * GetName() const override
Returns the name of the layer.
This layer represents a convolution 2d operation.
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
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