diff options
author | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-08-08 13:46:32 +0100 |
---|---|---|
committer | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-08-12 15:43:42 +0100 |
commit | 4e73b429ddfebef9beb64872d3e54a14bceccb29 (patch) | |
tree | 4df1460ac6fa836af5202ece84184bab136fb94d /src/backends/dynamic/reference | |
parent | 1fa19197a5673c57058efe19d94db223a93bc206 (diff) | |
download | armnn-4e73b429ddfebef9beb64872d3e54a14bceccb29.tar.gz |
IVGCVSW-3546 Create a reference dynamic backend to use for testing and as
an example in the docs
* Wrapped the reference backend into a dynamic backend
* Moved the static registration code to a separate file, so that
it is possible to create the reference dynamic backend that does not
register statically into armnn
* Added unit test
Change-Id: I1074d21b020820f9ac8c7178388be773b447555a
Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
Diffstat (limited to 'src/backends/dynamic/reference')
-rw-r--r-- | src/backends/dynamic/reference/CMakeLists.txt | 28 | ||||
-rw-r--r-- | src/backends/dynamic/reference/RefDynamicBackend.cpp | 33 | ||||
-rw-r--r-- | src/backends/dynamic/reference/RefDynamicBackend.hpp | 15 |
3 files changed, 76 insertions, 0 deletions
diff --git a/src/backends/dynamic/reference/CMakeLists.txt b/src/backends/dynamic/reference/CMakeLists.txt new file mode 100644 index 0000000000..e9a94af2fc --- /dev/null +++ b/src/backends/dynamic/reference/CMakeLists.txt @@ -0,0 +1,28 @@ +# +# Copyright © 2017 Arm Ltd. All rights reserved. +# SPDX-License-Identifier: MIT +# + +# File needed to wrap the existing backend into a dynamic one +list(APPEND armnnRefDynamicBackend_sources + RefDynamicBackend.cpp + RefDynamicBackend.hpp +) + +# Set the backend source path +set(RefBackendPath ${PROJECT_SOURCE_DIR}/src/backends/reference) + +# Source files of the backend, taken directly from the source tree +file(GLOB RefBackendBaseFiles ${RefBackendPath}/*.cpp) +set(RefBackendFiles ${RefBackendBaseFiles}) + +# Remove the file that contains the static backend registration +list(REMOVE_ITEM RefBackendFiles ${RefBackendPath}/RefRegistryInitializer.cpp) + +# Create the shared object +add_library(Arm_CpuRef_backend MODULE ${armnnRefDynamicBackend_sources} ${RefBackendFiles}) +target_include_directories(Arm_CpuRef_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn) +target_include_directories(Arm_CpuRef_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/armnnUtils) +target_include_directories(Arm_CpuRef_backend PRIVATE ${PROJECT_SOURCE_DIR}/src/backends) +set_target_properties(Arm_CpuRef_backend PROPERTIES PREFIX "") +target_link_libraries(Arm_CpuRef_backend armnn) diff --git a/src/backends/dynamic/reference/RefDynamicBackend.cpp b/src/backends/dynamic/reference/RefDynamicBackend.cpp new file mode 100644 index 0000000000..592043268b --- /dev/null +++ b/src/backends/dynamic/reference/RefDynamicBackend.cpp @@ -0,0 +1,33 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "RefDynamicBackend.hpp" + +#include <reference/RefBackend.hpp> + +using namespace armnn; + +const char* GetBackendId() +{ + return RefBackend::GetIdStatic().Get().c_str(); +} + +void GetVersion(uint32_t* outMajor, uint32_t* outMinor) +{ + if (!outMajor || !outMinor) + { + return; + } + + BackendVersion apiVersion = IBackendInternal::GetApiVersion(); + + *outMajor = apiVersion.m_Major; + *outMinor = apiVersion.m_Minor; +} + +void* BackendFactory() +{ + return new RefBackend(); +} diff --git a/src/backends/dynamic/reference/RefDynamicBackend.hpp b/src/backends/dynamic/reference/RefDynamicBackend.hpp new file mode 100644 index 0000000000..b058cd206c --- /dev/null +++ b/src/backends/dynamic/reference/RefDynamicBackend.hpp @@ -0,0 +1,15 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include <cstdint> + +extern "C" +{ +const char* GetBackendId(); +void GetVersion(uint32_t* outMajor, uint32_t* outMinor); +void* BackendFactory(); +} |