ArmNN
 22.08
EthosnRefBackend.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "EthosnRefBackend.hpp"
7 #include "EthosnRefBackendId.hpp"
11 
13 
16 
17 #include <Optimizer.hpp>
18 
20 
21 namespace armnn
22 {
23 
24 static bool VarGlobal_EnableWinograd;
25 static std::string VarGlobal_BlockConfigs;
26 
28 {
29  static const BackendId s_Id{EthosnRefBackendId()};
30  return s_Id;
31 }
32 
34  const IBackendInternal::IMemoryManagerSharedPtr& memoryManager) const
35 {
36  return std::make_unique<EthosnRefWorkloadFactory>(PolymorphicPointerDowncast<EthosnRefMemoryManager>(memoryManager), VarGlobal_EnableWinograd, VarGlobal_BlockConfigs);
37 }
38 
40  class TensorHandleFactoryRegistry& tensorHandleFactoryRegistry) const
41 {
42  auto memoryManager = std::make_shared<EthosnRefMemoryManager>();
43 
44  tensorHandleFactoryRegistry.RegisterMemoryManager(memoryManager);
45  tensorHandleFactoryRegistry.RegisterFactory(std::make_unique<EthosnRefTensorHandleFactory>(memoryManager));
46 
47  return std::make_unique<EthosnRefWorkloadFactory>(PolymorphicPointerDowncast<EthosnRefMemoryManager>(memoryManager), VarGlobal_EnableWinograd, VarGlobal_BlockConfigs);
48 }
49 
51 {
52  VarGlobal_EnableWinograd = false;
53  VarGlobal_BlockConfigs = "";
54 
55  for (auto optionsGroup : creationOptions.m_BackendOptions)
56  {
57  if (optionsGroup.GetBackendId() == EthosnRefBackend::GetId())
58  {
59  for (size_t i=0; i < optionsGroup.GetOptionCount(); i++)
60  {
61  const BackendOptions::BackendOption option = optionsGroup.GetOption(i);
62 
63  if(option.GetName() == "EnableWinograd" && option.GetValue().IsBool() == true) {
64  VarGlobal_EnableWinograd = option.GetValue().AsBool();
65  }
66  if(option.GetName() == "BlockConfigs" && option.GetValue().IsString() == true) {
67  VarGlobal_BlockConfigs = option.GetValue().AsString();
68  }
69  }
70  }
71  }
72  return IBackendContextPtr{};
73 }
74 
77 {
79 }
80 
82 {
83  return std::make_unique<EthosnRefMemoryManager>();
84 }
85 
86 IBackendInternal::Optimizations EthosnRefBackend::GetOptimizations() const
87 {
88  return Optimizations{};
89 }
90 
92 {
93  static ILayerSupportSharedPtr layerSupport{new EthosnRefLayerSupport};
94  return layerSupport;
95 }
96 
98 {
99  OptimizationViews optimizationViews;
100 
101  optimizationViews.AddUntouchedSubgraph(SubgraphView(subgraph));
102 
103  return optimizationViews;
104 }
105 
106 std::vector<ITensorHandleFactory::FactoryId> EthosnRefBackend::GetHandleFactoryPreferences() const
107 {
108  return std::vector<ITensorHandleFactory::FactoryId> { EthosnRefTensorHandleFactory::GetIdStatic() };
109 }
110 
112 {
113  auto memoryManager = std::make_shared<EthosnRefMemoryManager>();
114 
115  registry.RegisterMemoryManager(memoryManager);
116  registry.RegisterFactory(std::make_unique<EthosnRefTensorHandleFactory>(memoryManager));
117 }
118 
119 } // namespace armnn
void RegisterMemoryManager(std::shared_ptr< IMemoryManager > memoryManger)
Register a memory manager with shared ownership.
std::unique_ptr< IWorkloadFactory > IWorkloadFactoryPtr
std::vector< ITensorHandleFactory::FactoryId > GetHandleFactoryPreferences() const override
(Optional) Returns a vector of supported TensorHandleFactory ids in preference order.
void RegisterFactory(std::unique_ptr< ITensorHandleFactory > allocator)
Register a TensorHandleFactory and transfer ownership.
const BackendId & GetId() const override
Copyright (c) 2021 ARM Limited and Contributors.
std::unique_ptr< IMemoryManager > IMemoryManagerUniquePtr
OptimizationViews OptimizeSubgraphView(const SubgraphView &subgraph) const override
IBackendInternal::Optimizations GetOptimizations() const override
static const BackendId & GetIdStatic()
IBackendInternal::IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions &) const override
Create the runtime context of the backend.
The SubgraphView class represents a subgraph of a Graph.
void RegisterTensorHandleFactories(class TensorHandleFactoryRegistry &registry) override
(Optional) Register TensorHandleFactories Either this method or CreateMemoryManager() and IWorkloadFa...
std::vector< BackendOptions > m_BackendOptions
Pass backend specific options.
Definition: IRuntime.hpp:189
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
std::string AsString() const
void AddUntouchedSubgraph(SubgraphView &&subgraph)
std::shared_ptr< arm::pipe::IBackendProfilingContext > IBackendProfilingContextPtr
This is the bridge between backend and backend profiling we&#39;ll keep it in the backend namespace...
std::shared_ptr< ILayerSupport > ILayerSupportSharedPtr
std::unique_ptr< arm::pipe::IBackendProfiling > IBackendProfilingPtr
bool AsBool() const
Value getters.
IBackendInternal::IMemoryManagerUniquePtr CreateMemoryManager() const override
bool IsBool() const
Type getters.
IBackendInternal::IWorkloadFactoryPtr CreateWorkloadFactory(const IBackendInternal::IMemoryManagerSharedPtr &memoryManager=nullptr) const override
constexpr const char * EthosnRefBackendId()
IBackendInternal::IBackendProfilingContextPtr CreateBackendProfilingContext(const IRuntime::CreationOptions &creationOptions, IBackendProfilingPtr &backendProfiling) override
Create context specifically used for profiling interaction from backends.
IBackendInternal::ILayerSupportSharedPtr GetLayerSupport() const override
std::unique_ptr< IBackendContext > IBackendContextPtr