blob: f888b1e27e334ab5f406ce62852bc0a765f6860d (
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
|
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
#include "IBackendInternal.hpp"
#include <armnn/BackendRegistry.hpp>
#include <functional>
#include <memory>
namespace armnn
{
class DynamicBackend final
{
public:
using HandleCloser = std::function<void(const void*)>;
using HandlePtr = std::unique_ptr<void, HandleCloser>;
explicit DynamicBackend(const void* sharedObjectHandle);
/// Public dynamic backend functions
BackendId GetBackendId();
BackendVersion GetBackendVersion();
IBackendInternalUniquePtr GetBackend();
BackendRegistry::FactoryFunction GetFactoryFunction();
private:
/// Private utility functions
template<typename BackendFunctionType>
BackendFunctionType SetFunctionPointer(const std::string& backendFunctionName);
IBackendInternalUniquePtr CreateBackend();
/// Backend function pointer types
using IdFunctionType = const char*(*)();
using VersionFunctionType = void(*)(uint32_t*, uint32_t*);
using FactoryFunctionType = void*(*)();
/// Backend function pointers
IdFunctionType m_BackendIdFunction;
VersionFunctionType m_BackendVersionFunction;
FactoryFunctionType m_BackendFactoryFunction;
/// Shared object handle
HandlePtr m_Handle;
};
using DynamicBackendPtr = std::unique_ptr<DynamicBackend>;
} // namespace armnn
|