| // |
| // Copyright © 2017 Arm Ltd. All rights reserved. |
| // SPDX-License-Identifier: MIT |
| // |
| |
| #pragma once |
| |
| #include "IBackendInternal.hpp" |
| |
| #include <functional> |
| #include <memory> |
| |
| namespace armnn |
| { |
| |
| class DynamicBackend |
| { |
| 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(); |
| |
| private: |
| template<typename BackendFunctionType> |
| BackendFunctionType SetFunctionPointer(const std::string& backendFunctionName); |
| |
| /// 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; |
| }; |
| |
| } // namespace armnn |