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())
192 Layer& child = childInput->GetOwningLayer();
194 auto* activationLayer = PolymorphicDowncast<ActivationLayer*>(&child);
196 const std::string name = std::string(
"fused-") + child.
GetName() + std::string(
"-into-") +
210 biases = baseLayer->
m_Bias->GetTensorInfo();
215 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
217 baseLayer->
m_Weight->GetTensorInfo(),
224 FuseLayerWithWeightsAndBiases<Convolution2dLayer>(optimizationViews,
229 untouched.erase(baseLayer->GetGuid());
230 untouched.erase(activationLayer->GetGuid());
236 PolymorphicDowncast<DepthwiseConvolution2dLayer*>(&base);
242 biases = baseLayer->
m_Bias->GetTensorInfo();
247 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
249 baseLayer->
m_Weight->GetTensorInfo(),
255 FuseLayerWithWeightsAndBiases<DepthwiseConvolution2dLayer>(optimizationViews,
260 untouched.erase(baseLayer->GetGuid());
261 untouched.erase(activationLayer->GetGuid());
270 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
271 baseLayer->
m_Weight->GetTensorInfo(),
272 baseLayer->
m_Bias->GetTensorInfo(),
278 FuseLayerWithWeightsAndBiases<FullyConnectedLayer>(optimizationViews,
283 untouched.erase(baseLayer->GetGuid());
284 untouched.erase(activationLayer->GetGuid());
290 PolymorphicDowncast<BatchNormalizationLayer*>(&base);
294 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
295 baseLayer->
m_Mean->GetTensorInfo(),
297 baseLayer->
m_Beta->GetTensorInfo(),
298 baseLayer->
m_Gamma->GetTensorInfo(),
305 FuseLayerWithParameters<BatchNormalizationLayer>(optimizationViews,
311 replacementLayer->
m_Beta = std::move(baseLayer->m_Beta);
312 replacementLayer->
m_Gamma = std::move(baseLayer->m_Gamma);
313 replacementLayer->
m_Mean = std::move(baseLayer->m_Mean);
314 replacementLayer->
m_Variance = std::move(baseLayer->m_Variance);
315 untouched.erase(baseLayer->GetGuid());
316 untouched.erase(activationLayer->GetGuid());
321 AdditionLayer* baseLayer = PolymorphicDowncast<AdditionLayer*>(&base);
326 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
331 FuseLayerWithoutParameters<AdditionLayer>(optimizationViews,
336 untouched.erase(baseLayer->GetGuid());
337 untouched.erase(activationLayer->GetGuid());
342 DivisionLayer* baseLayer = PolymorphicDowncast<DivisionLayer*>(&base);
347 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
352 FuseLayerWithoutParameters<DivisionLayer>(optimizationViews,
357 untouched.erase(baseLayer->GetGuid());
358 untouched.erase(activationLayer->GetGuid());
368 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
373 FuseLayerWithoutParameters<MultiplicationLayer>(optimizationViews,
378 untouched.erase(baseLayer->GetGuid());
379 untouched.erase(activationLayer->GetGuid());
384 SubtractionLayer* baseLayer = PolymorphicDowncast<SubtractionLayer*>(&base);
389 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
394 FuseLayerWithoutParameters<SubtractionLayer>(optimizationViews,
399 untouched.erase(baseLayer->GetGuid());
400 untouched.erase(activationLayer->GetGuid());
419 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) 2020 ARM Limited.
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.
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()
LayerType GetType() const
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