8 #include <armnnTestUtils/MockBackend.hpp> 9 #include <armnnTestUtils/MockTensorHandle.hpp> 11 #include <backendsCommon/test/MockBackendId.hpp> 17 const BackendId& MockBackend::GetIdStatic()
19 static const BackendId s_Id{MockBackendId()};
25 static const BackendId s_Id{ MockBackendId() };
28 MockWorkloadFactory::MockWorkloadFactory(
const std::shared_ptr<MockMemoryManager>& memoryManager)
29 : m_MemoryManager(memoryManager)
32 MockWorkloadFactory::MockWorkloadFactory()
33 : m_MemoryManager(new MockMemoryManager())
41 std::unique_ptr<IWorkload> MockWorkloadFactory::CreateWorkload(
LayerType type,
42 const QueueDescriptor& descriptor,
43 const WorkloadInfo& info)
const 47 case LayerType::MemCopy: {
48 auto memCopyQueueDescriptor = PolymorphicDowncast<const MemCopyQueueDescriptor*>(&descriptor);
49 if (descriptor.m_Inputs.empty())
51 throw InvalidArgumentException(
"MockWorkloadFactory: CreateMemCopy() expected an input tensor.");
53 return std::make_unique<CopyMemGenericWorkload>(*memCopyQueueDescriptor, info);
90 const std::string layerName(layer->
GetName());
91 bool optimizable = layerName.find(
"unoptimizable") == std::string::npos;
106 MockBackendInitialiser::MockBackendInitialiser()
115 MockBackendInitialiser::~MockBackendInitialiser()
123 std::cerr <<
"could not deregister mock backend" << std::endl;
130 return IWorkloadFactoryPtr{};
135 return IBackendContextPtr{};
142 std::shared_ptr<armnn::MockBackendProfilingContext> context =
143 std::make_shared<MockBackendProfilingContext>(backendProfiling);
144 MockBackendProfilingService::Instance().SetProfilingContextPtr(context);
171 std::for_each(subgraphLayers.begin(),
172 subgraphLayers.end(),
183 supportedLayers.push_back(layer);
188 untouchedLayers.push_back(layer);
194 unsupportedLayers.push_back(layer);
199 if (!supportedLayers.empty())
202 auto supportedSubgraphSelector = [](
const Layer& layer)
216 std::for_each(supportedSubgraphs.begin(),
217 supportedSubgraphs.end(),
226 optimizationViews.
GetINetwork()->AddPrecompiledLayer(
228 supportedSubgraph->GetNumOutputSlots()),
236 optimizationViews.
AddSubstitution({ substitutionSubgraph, replacementSubgraph });
241 if (!unsupportedLayers.empty())
244 auto unsupportedSubgraphSelector = [](
const Layer& layer)
257 std::for_each(unsupportedSubgraphs.begin(),
258 unsupportedSubgraphs.end(),
268 if (!untouchedLayers.empty())
271 auto untouchedSubgraphSelector = [](
const Layer& layer)
285 std::for_each(untouchedSubgraphs.begin(),
286 untouchedSubgraphs.end(),
295 return optimizationViews;
298 std::unique_ptr<ICustomAllocator> MockBackend::GetDefaultAllocator()
const 300 return std::make_unique<DefaultAllocator>();
bool IsLayerSupported(const armnn::Layer *layer)
std::unique_ptr< IWorkloadFactory > IWorkloadFactoryPtr
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
void Register(const BackendId &id, FactoryFunction factory)
const IConnectableLayers & GetIConnectableLayers() const
std::shared_ptr< ILayerSupport > ILayerSupportSharedPtr
void AddSubstitution(SubstitutionPair &&substitution)
BackendRegistry & BackendRegistryInstance()
Copyright (c) 2021 ARM Limited and Contributors.
std::unique_ptr< IMemoryManager > IMemoryManagerUniquePtr
void IgnoreUnused(Ts &&...)
std::unique_ptr< void, CompiledBlobDeleter > CompiledBlobPtr
The SubgraphView class represents a subgraph of a Graph.
std::unique_ptr< SubgraphView > SubgraphViewPtr
std::list< IConnectableLayer * > IConnectableLayers
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
void AddFailedSubgraph(SubgraphView &&subgraph)
LayerType GetType() const override
Returns the armnn::LayerType of this layer.
std::vector< SubgraphViewPtr > Subgraphs
INetworkPtr & GetINetwork()
const char * GetBackendId()
#define ARMNN_ASSERT(COND)
bool IsLayerOptimizable(const armnn::Layer *layer)
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< ILayerSupport > ILayerSupportSharedPtr
static Subgraphs SelectSubgraphs(Graph &graph, const LayerSelectorFunction &selector)
Selects subgraphs from a graph based on the selector function and the algorithm.
bool IsLayerSupported(const armnn::Layer &layer)
void Deregister(const BackendId &id)
bool IsLayerOptimizable(const armnn::Layer &layer)
const char * GetName() const override
Returns the name of the layer.
std::unique_ptr< IBackendInternal > IBackendInternalUniquePtr
A PreCompiledDescriptor for the PreCompiledLayer.
std::unique_ptr< IMemoryManager > IMemoryManagerUniquePtr
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...
std::unique_ptr< IBackendContext > IBackendContextPtr