37 #include <arm_compute/core/Types.h> 38 #include <arm_compute/runtime/Allocator.h> 51 return std::make_unique<NeonMemoryManager>(std::make_unique<arm_compute::Allocator>(),
58 return std::make_unique<NeonWorkloadFactory>(
59 PolymorphicPointerDowncast<NeonMemoryManager>(memoryManager));
65 return std::make_unique<NeonWorkloadFactory>(
72 auto memoryManager = std::make_shared<NeonMemoryManager>(std::make_unique<arm_compute::Allocator>(),
76 tensorHandleFactoryRegistry.
RegisterFactory(std::make_unique<NeonTensorHandleFactory>(memoryManager));
78 return std::make_unique<NeonWorkloadFactory>(
79 PolymorphicPointerDowncast<NeonMemoryManager>(memoryManager));
85 auto memoryManager = std::make_shared<NeonMemoryManager>(std::make_unique<arm_compute::Allocator>(),
89 tensorHandleFactoryRegistry.
RegisterFactory(std::make_unique<NeonTensorHandleFactory>(memoryManager));
91 return std::make_unique<NeonWorkloadFactory>(
139 auto it = subgraph.
end();
140 std::map<LayerGuid, Layer*> untouched;
142 while (it != subgraph.
begin())
146 untouched.insert({base.
GetGuid(), &base});
150 while (it != subgraph.
begin())
164 if (output->GetNumConnections() == 1)
166 for (
auto&& childInput : output->GetConnections())
169 (checkDataTypeInputandOutput(childInput->GetOwningLayer())))
171 Layer& child = childInput->GetOwningLayer();
173 auto* activationLayer = PolymorphicDowncast<ActivationLayer*>(&child);
175 const std::string name = std::string(
"fused-") + child.
GetName() + std::string(
"-into-") +
189 biases = baseLayer->
m_Bias->GetTensorInfo();
194 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
196 baseLayer->
m_Weight->GetTensorInfo(),
203 FuseLayerWithWeightsAndBiases<Convolution2dLayer>(optimizationViews,
208 untouched.erase(baseLayer->GetGuid());
209 untouched.erase(activationLayer->GetGuid());
215 PolymorphicDowncast<DepthwiseConvolution2dLayer*>(&base);
221 biases = baseLayer->
m_Bias->GetTensorInfo();
226 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
228 baseLayer->
m_Weight->GetTensorInfo(),
234 FuseLayerWithWeightsAndBiases<DepthwiseConvolution2dLayer>(optimizationViews,
239 untouched.erase(baseLayer->GetGuid());
240 untouched.erase(activationLayer->GetGuid());
249 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
250 baseLayer->
m_Weight->GetTensorInfo(),
251 baseLayer->
m_Bias->GetTensorInfo(),
257 FuseLayerWithWeightsAndBiases<FullyConnectedLayer>(optimizationViews,
262 untouched.erase(baseLayer->GetGuid());
263 untouched.erase(activationLayer->GetGuid());
269 PolymorphicDowncast<BatchNormalizationLayer*>(&base);
273 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
274 baseLayer->
m_Mean->GetTensorInfo(),
276 baseLayer->
m_Beta->GetTensorInfo(),
277 baseLayer->
m_Gamma->GetTensorInfo(),
284 FuseLayerWithParameters<BatchNormalizationLayer>(
291 replacementLayer->
m_Beta = std::move(baseLayer->m_Beta);
292 replacementLayer->
m_Gamma = std::move(baseLayer->m_Gamma);
293 replacementLayer->
m_Mean = std::move(baseLayer->m_Mean);
294 replacementLayer->
m_Variance = std::move(baseLayer->m_Variance);
295 untouched.erase(baseLayer->GetGuid());
296 untouched.erase(activationLayer->GetGuid());
301 AdditionLayer* baseLayer = PolymorphicDowncast<AdditionLayer*>(&base);
306 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
311 FuseLayerWithoutParameters<AdditionLayer>(optimizationViews,
316 untouched.erase(baseLayer->GetGuid());
317 untouched.erase(activationLayer->GetGuid());
322 DivisionLayer* baseLayer = PolymorphicDowncast<DivisionLayer*>(&base);
327 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
332 FuseLayerWithoutParameters<DivisionLayer>(optimizationViews,
337 untouched.erase(baseLayer->GetGuid());
338 untouched.erase(activationLayer->GetGuid());
348 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
353 FuseLayerWithoutParameters<MultiplicationLayer>(optimizationViews,
358 untouched.erase(baseLayer->GetGuid());
359 untouched.erase(activationLayer->GetGuid());
364 SubtractionLayer* baseLayer = PolymorphicDowncast<SubtractionLayer*>(&base);
369 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
374 FuseLayerWithoutParameters<SubtractionLayer>(optimizationViews,
379 untouched.erase(baseLayer->GetGuid());
380 untouched.erase(activationLayer->GetGuid());
392 ReduceLayer* baseLayer = PolymorphicDowncast<ReduceLayer*>(&base);
395 if (!reduceDescriptor.m_vAxis.empty() && reduceDescriptor.m_vAxis.size() > 1)
398 std::vector<Layer*> layers = ChainReduceLayers<ReduceLayer>(optimizationViews,
403 ReplaceLayers<ReduceLayer>(optimizationViews, baseLayer, layers);
404 untouched.erase(baseLayer->GetGuid());
418 return optimizationViews;
428 auto memoryManager = std::make_shared<NeonMemoryManager>(std::make_unique<arm_compute::Allocator>(),
432 registry.
RegisterFactory(std::make_unique<NeonTensorHandleFactory>(memoryManager));
bool m_BiasEnabled
Enable/disable bias.
void RegisterMemoryManager(std::shared_ptr< IMemoryManager > memoryManger)
Register a memory manager with shared ownership.
This layer represents a batch normalization operation.
std::unique_ptr< IWorkloadFactory > IWorkloadFactoryPtr
bool m_BiasEnabled
Enable/disable bias.
std::vector< OptimizationPtr > Optimizations
const Parameters & GetParameters() const
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.
OptimizationViews OptimizeSubgraphView(const SubgraphView &subgraph) const override
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()
IBackendInternal::IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions &) const override
Create the runtime context of the backend.
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.
arm_compute::Status NeonFullyConnectedWorkloadValidate(const TensorInfo &input, const TensorInfo &output, const TensorInfo &weights, const TensorInfo &biases, const FullyConnectedDescriptor &descriptor, const ActivationDescriptor *activationDescriptor)
Copyright (c) 2021 ARM Limited and Contributors.
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.
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...
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
std::unique_ptr< armnn::profiling::IBackendProfiling > IBackendProfilingPtr
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::ILayerSupportSharedPtr GetLayerSupport() const override
std::shared_ptr< ConstTensorHandle > m_Bias
A unique pointer to store Bias values.
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
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< ConstTensorHandle > m_Variance
A unique pointer to store Variance values.
std::shared_ptr< ConstTensorHandle > m_Bias
A unique pointer to store Bias 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
This layer represents a subtraction operation.
IBackendInternal::Optimizations GetOptimizations() const override
std::vector< OutputSlot >::iterator BeginOutputSlots()
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.
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
std::shared_ptr< armnn::profiling::IBackendProfilingContext > IBackendProfilingContextPtr
This is the bridge between backend and backend profiling we'll keep it in the backend namespace...
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