36 #include <arm_compute/core/Types.h> 37 #include <arm_compute/runtime/Allocator.h> 50 return std::make_unique<NeonMemoryManager>(std::make_unique<arm_compute::Allocator>(),
57 return std::make_unique<NeonWorkloadFactory>(
58 PolymorphicPointerDowncast<NeonMemoryManager>(memoryManager));
64 return std::make_unique<NeonWorkloadFactory>(
71 auto memoryManager = std::make_shared<NeonMemoryManager>(std::make_unique<arm_compute::Allocator>(),
75 tensorHandleFactoryRegistry.
RegisterFactory(std::make_unique<NeonTensorHandleFactory>(memoryManager));
77 return std::make_unique<NeonWorkloadFactory>(
78 PolymorphicPointerDowncast<NeonMemoryManager>(memoryManager));
84 auto memoryManager = std::make_shared<NeonMemoryManager>(std::make_unique<arm_compute::Allocator>(),
88 tensorHandleFactoryRegistry.
RegisterFactory(std::make_unique<NeonTensorHandleFactory>(memoryManager));
90 return std::make_unique<NeonWorkloadFactory>(
138 auto it = subgraph.
end();
139 std::map<LayerGuid, Layer*> untouched;
141 while (it != subgraph.
begin())
145 untouched.insert({base.
GetGuid(), &base});
149 while (it != subgraph.
begin())
162 if (output->GetNumConnections() == 1)
164 for (
auto&& childInput : output->GetConnections())
168 Layer& child = childInput->GetOwningLayer();
170 auto* activationLayer = PolymorphicDowncast<ActivationLayer*>(&child);
172 const std::string name = std::string(
"fused-") + child.
GetName() + std::string(
"-into-") +
186 biases = baseLayer->
m_Bias->GetTensorInfo();
191 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
193 baseLayer->
m_Weight->GetTensorInfo(),
200 FuseLayerWithWeightsAndBiases<Convolution2dLayer>(optimizationViews,
205 untouched.erase(baseLayer->GetGuid());
206 untouched.erase(activationLayer->GetGuid());
212 PolymorphicDowncast<DepthwiseConvolution2dLayer*>(&base);
218 biases = baseLayer->
m_Bias->GetTensorInfo();
223 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
225 baseLayer->
m_Weight->GetTensorInfo(),
231 FuseLayerWithWeightsAndBiases<DepthwiseConvolution2dLayer>(optimizationViews,
236 untouched.erase(baseLayer->GetGuid());
237 untouched.erase(activationLayer->GetGuid());
246 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
247 baseLayer->
m_Weight->GetTensorInfo(),
248 baseLayer->
m_Bias->GetTensorInfo(),
254 FuseLayerWithWeightsAndBiases<FullyConnectedLayer>(optimizationViews,
259 untouched.erase(baseLayer->GetGuid());
260 untouched.erase(activationLayer->GetGuid());
266 PolymorphicDowncast<BatchNormalizationLayer*>(&base);
270 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
271 baseLayer->
m_Mean->GetTensorInfo(),
273 baseLayer->
m_Beta->GetTensorInfo(),
274 baseLayer->
m_Gamma->GetTensorInfo(),
281 FuseLayerWithParameters<BatchNormalizationLayer>(
288 replacementLayer->
m_Beta = std::move(baseLayer->m_Beta);
289 replacementLayer->
m_Gamma = std::move(baseLayer->m_Gamma);
290 replacementLayer->
m_Mean = std::move(baseLayer->m_Mean);
291 replacementLayer->
m_Variance = std::move(baseLayer->m_Variance);
292 untouched.erase(baseLayer->GetGuid());
293 untouched.erase(activationLayer->GetGuid());
298 AdditionLayer* baseLayer = PolymorphicDowncast<AdditionLayer*>(&base);
303 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
308 FuseLayerWithoutParameters<AdditionLayer>(optimizationViews,
313 untouched.erase(baseLayer->GetGuid());
314 untouched.erase(activationLayer->GetGuid());
319 DivisionLayer* baseLayer = PolymorphicDowncast<DivisionLayer*>(&base);
324 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
329 FuseLayerWithoutParameters<DivisionLayer>(optimizationViews,
334 untouched.erase(baseLayer->GetGuid());
335 untouched.erase(activationLayer->GetGuid());
345 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
350 FuseLayerWithoutParameters<MultiplicationLayer>(optimizationViews,
355 untouched.erase(baseLayer->GetGuid());
356 untouched.erase(activationLayer->GetGuid());
361 SubtractionLayer* baseLayer = PolymorphicDowncast<SubtractionLayer*>(&base);
366 activationLayer->GetInputSlot(0).GetConnectedOutputSlot()->GetTensorInfo(),
371 FuseLayerWithoutParameters<SubtractionLayer>(optimizationViews,
376 untouched.erase(baseLayer->GetGuid());
377 untouched.erase(activationLayer->GetGuid());
396 return optimizationViews;
406 auto memoryManager = std::make_shared<NeonMemoryManager>(std::make_unique<arm_compute::Allocator>(),
410 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.
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
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::unique_ptr< ScopedCpuTensorHandle > m_Bias
A unique pointer to store Bias values.
OptimizationViews OptimizeSubgraphView(const SubgraphView &subgraph) const override
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 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()
std::unique_ptr< ScopedCpuTensorHandle > m_Gamma
A unique pointer to store Gamma values.
IBackendInternal::IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions &) const override
Create the runtime context of the backend.
std::unique_ptr< ScopedCpuTensorHandle > m_Variance
A unique pointer to store Variance 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) 2020 ARM Limited.
std::unique_ptr< IMemoryManager > IMemoryManagerUniquePtr
arm_compute::Status NeonAdditionWorkloadValidate(const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, const ActivationDescriptor *activationDescriptor)
The NeonBackendModelContext is used to pass in Neon specific backend ModelOptions.
std::unique_ptr< ScopedCpuTensorHandle > 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::unique_ptr< ScopedCpuTensorHandle > m_Mean
A unique pointer to store Mean values.
std::shared_ptr< IBackendModelContext > IBackendSpecificModelContextPtr
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
IBackendInternal::ILayerSupportSharedPtr GetLayerSupport() const override
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
IBackendInternal::IBackendSpecificModelContextPtr CreateBackendSpecificModelContext(const ModelOptions &modelOptions) const override
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)
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::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
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.
std::unique_ptr< ScopedCpuTensorHandle > m_Weight
A unique pointer to store Weight values.
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