38 #include <arm_compute/core/Types.h> 39 #include <arm_compute/runtime/Allocator.h> 52 return std::make_unique<NeonMemoryManager>(std::make_unique<arm_compute::Allocator>(),
59 return std::make_unique<NeonWorkloadFactory>(
60 PolymorphicPointerDowncast<NeonMemoryManager>(memoryManager));
66 return std::make_unique<NeonWorkloadFactory>(
73 auto memoryManager = std::make_shared<NeonMemoryManager>(std::make_unique<arm_compute::Allocator>(),
78 auto factory = std::make_unique<NeonTensorHandleFactory>(memoryManager);
85 return std::make_unique<NeonWorkloadFactory>(
86 PolymorphicPointerDowncast<NeonMemoryManager>(memoryManager));
92 auto memoryManager = std::make_shared<NeonMemoryManager>(std::make_unique<arm_compute::Allocator>(),
97 auto factory = std::make_unique<NeonTensorHandleFactory>(memoryManager);
103 return std::make_unique<NeonWorkloadFactory>(
148 std::map<LayerGuid, Layer*> untouched;
153 Layer& base = *(PolymorphicDowncast<Layer*>(*it));
154 untouched.insert({base.
GetGuid(), &base});
161 Layer& base = *(PolymorphicDowncast<Layer*>(*it));
172 if (output->GetNumConnections() == 1)
174 for (
auto&& childInput : output->GetConnections())
177 (checkDataTypeInputandOutput(childInput->GetOwningLayer())))
179 Layer& child = childInput->GetOwningLayer();
181 auto* activationLayer = PolymorphicDowncast<ActivationLayer*>(&child);
183 const std::string name = std::string(
"fused-") + child.
GetName() + std::string(
"-into-") +
202 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
211 FuseConvolution2dLayer<Convolution2dLayer>(optimizationViews,
216 untouched.erase(baseLayer->GetGuid());
217 untouched.erase(activationLayer->GetGuid());
223 PolymorphicDowncast<DepthwiseConvolution2dLayer*>(&base);
234 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
242 FuseDepthwiseConvolution2dLayer<DepthwiseConvolution2dLayer>(optimizationViews,
247 untouched.erase(baseLayer->GetGuid());
248 untouched.erase(activationLayer->GetGuid());
258 if (descriptor.m_BiasEnabled)
265 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
273 FuseFullyConnectedLayer<FullyConnectedLayer>(optimizationViews,
278 untouched.erase(baseLayer->GetGuid());
279 untouched.erase(activationLayer->GetGuid());
285 PolymorphicDowncast<BatchNormalizationLayer*>(&base);
289 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
290 baseLayer->
m_Mean->GetTensorInfo(),
292 baseLayer->
m_Beta->GetTensorInfo(),
293 baseLayer->
m_Gamma->GetTensorInfo(),
300 FuseBatchNormalizationLayer<BatchNormalizationLayer>(optimizationViews,
306 replacementLayer->
m_Beta = std::move(baseLayer->m_Beta);
307 replacementLayer->
m_Gamma = std::move(baseLayer->m_Gamma);
308 replacementLayer->
m_Mean = std::move(baseLayer->m_Mean);
309 replacementLayer->
m_Variance = std::move(baseLayer->m_Variance);
310 untouched.erase(baseLayer->GetGuid());
311 untouched.erase(activationLayer->GetGuid());
316 AdditionLayer* baseLayer = PolymorphicDowncast<AdditionLayer*>(&base);
321 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
326 FuseAdditionLayer<AdditionLayer>(optimizationViews,
331 untouched.erase(baseLayer->GetGuid());
332 untouched.erase(activationLayer->GetGuid());
337 DivisionLayer* baseLayer = PolymorphicDowncast<DivisionLayer*>(&base);
342 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
347 FuseDivisionLayer<DivisionLayer>(optimizationViews,
352 untouched.erase(baseLayer->GetGuid());
353 untouched.erase(activationLayer->GetGuid());
363 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
368 FuseMultiplicationLayer<MultiplicationLayer>(optimizationViews,
373 untouched.erase(baseLayer->GetGuid());
374 untouched.erase(activationLayer->GetGuid());
379 SubtractionLayer* baseLayer = PolymorphicDowncast<SubtractionLayer*>(&base);
384 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
389 FuseSubtractionLayer<SubtractionLayer>(optimizationViews,
394 untouched.erase(baseLayer->GetGuid());
395 untouched.erase(activationLayer->GetGuid());
407 ReduceLayer* baseLayer = PolymorphicDowncast<ReduceLayer*>(&base);
410 if (!reduceDescriptor.m_vAxis.empty() && reduceDescriptor.m_vAxis.size() > 1)
413 std::vector<IConnectableLayer*> layers = ChainReduceLayers<ReduceLayer>(optimizationViews,
418 ReplaceLayers<ReduceLayer>(optimizationViews, baseLayer, layers);
419 untouched.erase(baseLayer->GetGuid());
433 return optimizationViews;
443 auto memoryManager = std::make_shared<NeonMemoryManager>(std::make_unique<arm_compute::Allocator>(),
448 auto factory = std::make_unique<NeonTensorHandleFactory>(memoryManager);
457 return std::make_unique<DefaultAllocator>();
bool m_BiasEnabled
Enable/disable bias.
void RegisterMemoryManager(std::shared_ptr< IMemoryManager > memoryManger)
Register a memory manager with shared ownership.
IConnectableLayerIterator endIConnectable()
This layer represents a batch normalization operation.
std::unique_ptr< IWorkloadFactory > IWorkloadFactoryPtr
bool m_BiasEnabled
Enable/disable bias.
IBackendInternal::IBackendProfilingContextPtr CreateBackendProfilingContext(const IRuntime::CreationOptions &, IBackendProfilingPtr &backendProfiling) override
Create context specifically used for profiling interaction from backends.
arm_compute::Status NeonBatchNormalizationValidate(const TensorInfo &input, const TensorInfo &output, const TensorInfo &mean, const TensorInfo &var, const TensorInfo &beta, const TensorInfo &gamma, const BatchNormalizationDescriptor &descriptor, const ActivationDescriptor *activationDescriptor)
std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences() const override
(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.
This layer represents a depthwise convolution 2d operation.
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 NeonDepthwiseConvolutionWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const DepthwiseConvolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, const ActivationDescriptor *activationDescriptor)
IWorkloadFactoryPtr CreateWorkloadFactory(const IBackendInternal::IMemoryManagerSharedPtr &memoryManager=nullptr) const override
constexpr const char * NeonBackendId()
IConnectableLayerIterator beginIConnectable()
IBackendInternal::IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions &) const override
Create the runtime context of the backend.
arm_compute::Status NeonFullyConnectedWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const TensorInfo &weights, const Optional< TensorInfo > &biases, const FullyConnectedDescriptor &descriptor, const ActivationDescriptor *activationDescriptor)
std::shared_ptr< ConstTensorHandle > m_Mean
A unique pointer to store Mean values.
Copyright (c) 2021 ARM Limited and Contributors.
const Parameters & GetParameters() const override
If the layer has a descriptor return it.
std::unique_ptr< IMemoryManager > IMemoryManagerUniquePtr
arm_compute::Status NeonAdditionWorkloadValidate(const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
This layer represents a reduction operation.
The NeonBackendModelContext is used to pass in Neon specific backend ModelOptions.
std::shared_ptr< ConstTensorHandle > m_Beta
A unique pointer to store Beta values.
std::unique_ptr< ICustomAllocator > GetDefaultAllocator() const override
Returns the default memory allocator for the backend.
The SubgraphView class represents a subgraph of a Graph.
arm_compute::Status NeonSubtractionWorkloadValidate(const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
void RegisterTensorHandleFactories(class TensorHandleFactoryRegistry ®istry) override
(Optional) Register TensorHandleFactories Either this method or CreateMemoryManager() and IWorkloadFa...
void RegisterCopyAndImportFactoryPair(ITensorHandleFactory::FactoryId copyFactoryId, ITensorHandleFactory::FactoryId importFactoryId)
Register a pair of TensorHandleFactory Id for Memory Copy and TensorHandleFactory Id for Memory Impor...
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
This layer represents a fully connected operation.
std::shared_ptr< IBackendModelContext > IBackendSpecificModelContextPtr
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
A ReduceDescriptor for the REDUCE operators.
IBackendInternal::ILayerSupportSharedPtr GetLayerSupport() const override
A FullyConnectedDescriptor for the FullyConnectedLayer.
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
OptimizationViews OptimizeSubgraphView(const SubgraphView &subgraph, const ModelOptions &modelOptions) const override
IBackendInternal::IBackendSpecificModelContextPtr CreateBackendSpecificModelContext(const ModelOptions &modelOptions) const override
std::shared_ptr< ConstTensorHandle > m_Gamma
A unique pointer to store Gamma values.
arm_compute::Status NeonConvolution2dWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const Convolution2dDescriptor &descriptor, const TensorInfo &weights, const Optional< TensorInfo > &biases, bool isFastMathEnabled, const ActivationDescriptor *activationDescriptor)
An ActivationDescriptor for the ActivationLayer.
void AddUntouchedSubgraph(SubgraphView &&subgraph)
std::shared_ptr< arm::pipe::IBackendProfilingContext > IBackendProfilingContextPtr
This is the bridge between backend and backend profiling we'll keep it in the backend namespace...
std::shared_ptr< ConstTensorHandle > m_Variance
A unique pointer to store Variance values.
arm_compute::Status NeonDivisionWorkloadValidate(const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
This layer represents an addition operation.
std::shared_ptr< ILayerSupport > ILayerSupportSharedPtr
const Substitutions & GetSubstitutions() const
std::unique_ptr< arm::pipe::IBackendProfiling > IBackendProfilingPtr
This layer represents a subtraction operation.
std::vector< OutputSlot >::iterator BeginOutputSlots()
This layer represents a division operation.
std::vector< OutputSlot >::iterator EndOutputSlots()
static const BackendId & GetIdStatic()
static const FactoryId & GetIdStatic()
const char * GetName() const override
Returns the name of the layer.
This layer represents a convolution 2d operation.
This layer represents a multiplication operation.
const TensorInfo & GetTensorInfo() const override
arm_compute::Status NeonMultiplicationWorkloadValidate(const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
std::shared_ptr< T > GetAdditionalInformation() const
IBackendInternal::IMemoryManagerUniquePtr CreateMemoryManager() const override
LayerGuid GetGuid() const final
Returns the unique id of the layer.
std::unique_ptr< IBackendContext > IBackendContextPtr