blob: f49a2109886392482918d853984c248d91889517 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
#include <armnn/Types.hpp>
#include <armnn/IRuntime.hpp>
#include <ISubgraphViewConverter.hpp>
#include <SubgraphView.hpp>
#include "OptimizationViews.hpp"
#include <vector>
namespace armnn
{
class IWorkloadFactory;
class IBackendContext;
class IMemoryManager;
class Optimization;
class ILayerSupport;
class IBackendInternal : public IBackend
{
protected:
// Creation must be done through a specific
// backend interface.
IBackendInternal() = default;
public:
// Allow backends created by the factory function
// to be destroyed through IBackendInternal.
~IBackendInternal() override = default;
using IWorkloadFactoryPtr = std::unique_ptr<IWorkloadFactory>;
using IBackendContextPtr = std::unique_ptr<IBackendContext>;
using OptimizationPtr = std::unique_ptr<Optimization>;
using Optimizations = std::vector<OptimizationPtr>;
using ILayerSupportSharedPtr = std::shared_ptr<ILayerSupport>;
using IMemoryManagerUniquePtr = std::unique_ptr<IMemoryManager>;
using IMemoryManagerSharedPtr = std::shared_ptr<IMemoryManager>;
using GraphUniquePtr = std::unique_ptr<Graph>;
using SubgraphViewUniquePtr = std::unique_ptr<SubgraphView>;
virtual IMemoryManagerUniquePtr CreateMemoryManager() const = 0;
virtual IWorkloadFactoryPtr CreateWorkloadFactory(
const IMemoryManagerSharedPtr& memoryManager = nullptr) const = 0;
virtual IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions&) const = 0;
virtual Optimizations GetOptimizations() const = 0;
virtual ILayerSupportSharedPtr GetLayerSupport() const = 0;
// @deprecated Use "OptimizationViews OptimizeSubgraphView(const SubgraphView&);" instead.
virtual SubgraphViewUniquePtr OptimizeSubgraphView(const SubgraphView& subgraph, bool& optimizationAttempted) const
{
optimizationAttempted=false;
return nullptr;
}
// Default implementation of OptimizeSubgraphView for backward compatibility with old API.
// Override this method with a custom optimization implementation.
virtual OptimizationViews OptimizeSubgraphView(const SubgraphView& subgraph)
{
bool attempted=false;
SubgraphViewUniquePtr optSubgraph = OptimizeSubgraphView(subgraph, attempted);
OptimizationViews result;
if (!attempted)
{
result.AddUntouchedSubgraph(SubgraphView(subgraph));
}
else
{
if (optSubgraph)
{
result.AddSubstituion({*optSubgraph.get(), subgraph});
}
else
{
result.AddFailedSubgraph(SubgraphView(subgraph));
}
}
return result;
}
};
using IBackendInternalUniquePtr = std::unique_ptr<IBackendInternal>;
} // namespace armnn
|