ArmNN
 24.08
DynamicBackend.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017,2022 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include "IBackendInternal.hpp"
10 #include <armnn/BackendId.hpp>
11 
12 #include <stdint.h>
13 #include <functional>
14 #include <memory>
15 #include <string>
16 
17 namespace armnn
18 {
19 
20 class DynamicBackend final
21 {
22 public:
23  using HandleCloser = std::function<void(const void*)>;
24  using HandlePtr = std::unique_ptr<void, HandleCloser>;
25 
26  explicit DynamicBackend(const void* sharedObjectHandle);
27 
28  /// Public dynamic backend functions
33 
34 private:
35  /// Private utility functions
36  template<typename BackendFunctionType>
37  BackendFunctionType SetFunctionPointer(const std::string& backendFunctionName);
38  IBackendInternalUniquePtr CreateBackend();
39 
40  /// Backend function pointer types
41  using IdFunctionType = const char*(*)();
42  using VersionFunctionType = void(*)(uint32_t*, uint32_t*);
43  using FactoryFunctionType = void*(*)();
44 
45  /// Backend function pointers
46  IdFunctionType m_BackendIdFunction;
47  VersionFunctionType m_BackendVersionFunction;
48  FactoryFunctionType m_BackendFactoryFunction;
49 
50  /// Shared object handle
51  HandlePtr m_Handle;
52 };
53 
54 using DynamicBackendPtr = std::unique_ptr<DynamicBackend>;
55 
56 } // namespace armnn
armnn::DynamicBackendPtr
std::unique_ptr< DynamicBackend > DynamicBackendPtr
Definition: DynamicBackend.hpp:54
armnn::DynamicBackend::HandleCloser
std::function< void(const void *)> HandleCloser
Definition: DynamicBackend.hpp:23
BackendId.hpp
BackendRegistry.hpp
armnn::BackendRegistry::FactoryFunction
std::function< PointerType()> FactoryFunction
Definition: BackendRegistry.hpp:39
armnn::DynamicBackend
Definition: DynamicBackend.hpp:20
armnn::DynamicBackend::GetBackendVersion
BackendVersion GetBackendVersion()
Definition: DynamicBackend.cpp:58
armnn::DynamicBackend::DynamicBackend
DynamicBackend(const void *sharedObjectHandle)
Definition: DynamicBackend.cpp:12
armnn::DynamicBackend::GetBackendId
BackendId GetBackendId()
Public dynamic backend functions.
Definition: DynamicBackend.cpp:42
armnn::DynamicBackend::GetFactoryFunction
BackendRegistry::FactoryFunction GetFactoryFunction()
Definition: DynamicBackend.cpp:78
IBackendInternal.hpp
armnn::DynamicBackend::HandlePtr
std::unique_ptr< void, HandleCloser > HandlePtr
Definition: DynamicBackend.hpp:24
armnn::BackendVersion
Definition: IBackendInternal.hpp:34
armnn::BackendId
Definition: BackendId.hpp:75
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::IBackendInternalUniquePtr
std::unique_ptr< IBackendInternal > IBackendInternalUniquePtr
Definition: BackendRegistry.hpp:32
armnn::DynamicBackend::GetBackend
IBackendInternalUniquePtr GetBackend()
Definition: DynamicBackend.cpp:72