diff options
author | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-01-31 15:35:59 +0000 |
---|---|---|
committer | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-02-01 10:24:15 +0000 |
commit | d95e906f135ab9c7a7ac4c9f5d2cef8beb154a88 (patch) | |
tree | da56a3d5b9546409d7860126a46419e5b0eaa7d5 /src | |
parent | 339bcae73515c66899432b5844d7c239c570c4b8 (diff) | |
download | armnn-d95e906f135ab9c7a7ac4c9f5d2cef8beb154a88.tar.gz |
IVGCVSW-2603 The macros ARMCOMPUTECL_ENABLED and ARMCOMPUTENEON_ENABLED
no longer work
* Added two master variables ARMNN_COMPUTE_CL_ENABLED and ARMNN_COMPUTE_NEON_ENABLED
to android-nn-driver/Android.mk to easily control backend support
* Setting either of those two new variables then properly sets the
corresponding build macro
* If a specific backend gets disabled, the corresponding source files
will be excluded from the build
* Unified the usage of the pre-compile macros
!android-nn-driver:613
Change-Id: I582ff73493b70ba9e22ca2e38d875a0f19566c8a
Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/backends/aclCommon/BaseMemoryManager.cpp | 4 | ||||
-rw-r--r-- | src/backends/aclCommon/BaseMemoryManager.hpp | 18 | ||||
-rw-r--r-- | src/backends/aclCommon/test/CreateWorkloadClNeon.hpp | 4 | ||||
-rw-r--r-- | src/backends/aclCommon/test/MemCopyTests.cpp | 11 | ||||
-rw-r--r-- | src/backends/backendsCommon/test/OptimizedNetworkTests.cpp | 6 | ||||
-rw-r--r-- | src/backends/cl/ClLayerSupport.cpp | 8 | ||||
-rw-r--r-- | src/backends/cl/backend.mk | 28 | ||||
-rw-r--r-- | src/backends/neon/NeonLayerSupport.cpp | 6 | ||||
-rw-r--r-- | src/backends/neon/backend.mk | 30 |
9 files changed, 85 insertions, 30 deletions
diff --git a/src/backends/aclCommon/BaseMemoryManager.cpp b/src/backends/aclCommon/BaseMemoryManager.cpp index f564dc63e2..7c06ec5537 100644 --- a/src/backends/aclCommon/BaseMemoryManager.cpp +++ b/src/backends/aclCommon/BaseMemoryManager.cpp @@ -89,7 +89,7 @@ void BaseMemoryManager::Release() } #endif -#ifdef ARMCOMPUTENEON_ENABLED +#if defined(ARMCOMPUTENEON_ENABLED) std::shared_ptr<arm_compute::IMemoryGroup> NeonMemoryManager::CreateMemoryGroup(const std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager) { @@ -97,7 +97,7 @@ NeonMemoryManager::CreateMemoryGroup(const std::shared_ptr<arm_compute::MemoryMa } #endif -#ifdef ARMCOMPUTECL_ENABLED +#if defined(ARMCOMPUTECL_ENABLED) std::shared_ptr<arm_compute::IMemoryGroup> ClMemoryManager::CreateMemoryGroup(const std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager) { diff --git a/src/backends/aclCommon/BaseMemoryManager.hpp b/src/backends/aclCommon/BaseMemoryManager.hpp index a880b9a183..b8d1922d62 100644 --- a/src/backends/aclCommon/BaseMemoryManager.hpp +++ b/src/backends/aclCommon/BaseMemoryManager.hpp @@ -7,11 +7,11 @@ #include <backendsCommon/IMemoryManager.hpp> #include <backendsCommon/WorkloadFactory.hpp> -#ifdef ARMCOMPUTENEON_ENABLED +#if defined(ARMCOMPUTENEON_ENABLED) #include <arm_compute/runtime/MemoryGroup.h> #endif -#ifdef ARMCOMPUTECL_ENABLED +#if defined(ARMCOMPUTECL_ENABLED) #include <arm_compute/runtime/CL/CLMemoryGroup.h> #endif @@ -40,7 +40,6 @@ public: void Release() override; #if defined(ARMCOMPUTENEON_ENABLED) || defined(ARMCOMPUTECL_ENABLED) - BaseMemoryManager(std::unique_ptr<arm_compute::IAllocator> alloc, MemoryAffinity memoryAffinity); std::shared_ptr<arm_compute::MemoryManagerOnDemand>& GetIntraLayerManager() { return m_IntraLayerMemoryMgr; } @@ -57,17 +56,16 @@ protected: virtual std::shared_ptr<arm_compute::IMemoryGroup> CreateMemoryGroup(const std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager) = 0; - #endif }; +#if defined(ARMCOMPUTENEON_ENABLED) class NeonMemoryManager : public BaseMemoryManager { public: NeonMemoryManager() {} virtual ~NeonMemoryManager() {} -#ifdef ARMCOMPUTENEON_ENABLED NeonMemoryManager(std::unique_ptr<arm_compute::IAllocator> alloc, MemoryAffinity memoryAffinity) : BaseMemoryManager(std::move(alloc), memoryAffinity) { @@ -75,18 +73,18 @@ public: } protected: - virtual std::shared_ptr<arm_compute::IMemoryGroup> + std::shared_ptr<arm_compute::IMemoryGroup> CreateMemoryGroup(const std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager) override; -#endif }; +#endif +#if defined(ARMCOMPUTECL_ENABLED) class ClMemoryManager : public BaseMemoryManager { public: ClMemoryManager() {} virtual ~ClMemoryManager() {} -#ifdef ARMCOMPUTECL_ENABLED ClMemoryManager(std::unique_ptr<arm_compute::IAllocator> alloc) : BaseMemoryManager(std::move(alloc), MemoryAffinity::Buffer) { @@ -94,9 +92,9 @@ public: } protected: - virtual std::shared_ptr<arm_compute::IMemoryGroup> + std::shared_ptr<arm_compute::IMemoryGroup> CreateMemoryGroup(const std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager) override; -#endif }; +#endif } //namespace armnn diff --git a/src/backends/aclCommon/test/CreateWorkloadClNeon.hpp b/src/backends/aclCommon/test/CreateWorkloadClNeon.hpp index adabed07f8..f544c12c30 100644 --- a/src/backends/aclCommon/test/CreateWorkloadClNeon.hpp +++ b/src/backends/aclCommon/test/CreateWorkloadClNeon.hpp @@ -9,11 +9,11 @@ #include <backendsCommon/MemCopyWorkload.hpp> #include <reference/RefWorkloadFactory.hpp> -#if ARMCOMPUTECL_ENABLED +#if defined(ARMCOMPUTECL_ENABLED) #include <cl/ClTensorHandle.hpp> #endif -#if ARMCOMPUTENEON_ENABLED +#if defined(ARMCOMPUTENEON_ENABLED) #include <neon/NeonTensorHandle.hpp> #endif diff --git a/src/backends/aclCommon/test/MemCopyTests.cpp b/src/backends/aclCommon/test/MemCopyTests.cpp index 78cd95b21d..3e26364354 100644 --- a/src/backends/aclCommon/test/MemCopyTests.cpp +++ b/src/backends/aclCommon/test/MemCopyTests.cpp @@ -4,15 +4,14 @@ // #include <aclCommon/ArmComputeTensorUtils.hpp> -#include <cl/ClWorkloadFactory.hpp> -#include <neon/NeonWorkloadFactory.hpp> - -#if ARMCOMPUTECL_ENABLED && ARMCOMPUTENEON_ENABLED #include <aclCommon/test/MemCopyTestImpl.hpp> +#if defined(ARMCOMPUTECL_ENABLED) && defined(ARMCOMPUTENEON_ENABLED) +#include <cl/ClWorkloadFactory.hpp> #include <cl/test/ClContextControlFixture.hpp> #include <cl/test/ClWorkloadFactoryHelper.hpp> +#include <neon/NeonWorkloadFactory.hpp> #include <neon/test/NeonWorkloadFactoryHelper.hpp> #endif @@ -41,7 +40,7 @@ BOOST_AUTO_TEST_CASE(AclTypeConversions) BOOST_AUTO_TEST_SUITE_END() -#if ARMCOMPUTECL_ENABLED && ARMCOMPUTENEON_ENABLED +#if defined(ARMCOMPUTECL_ENABLED) && defined(ARMCOMPUTENEON_ENABLED) BOOST_FIXTURE_TEST_SUITE(MemCopyClNeon, ClContextControlFixture) @@ -75,4 +74,4 @@ BOOST_AUTO_TEST_CASE(CopyBetweenGpuAndNeonWithSubtensors) BOOST_AUTO_TEST_SUITE_END() -#endif
\ No newline at end of file +#endif diff --git a/src/backends/backendsCommon/test/OptimizedNetworkTests.cpp b/src/backends/backendsCommon/test/OptimizedNetworkTests.cpp index 8d88241000..7b6135df71 100644 --- a/src/backends/backendsCommon/test/OptimizedNetworkTests.cpp +++ b/src/backends/backendsCommon/test/OptimizedNetworkTests.cpp @@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE(OptimizeValidateDeviceNonSupportLayerWithFallback) // If NEON is enabled, Input and Output layers are supported by CpuAcc, // the other layers are supported by CpuRef. // If NEON is not enabled, all layers are supported by CpuRef. -#if ARMCOMPUTENEON_ENABLED +#if defined(ARMCOMPUTENEON_ENABLED) if (layer->GetType() == armnn::LayerType::Input || layer->GetType() == armnn::LayerType::Output) { BOOST_CHECK(layer->GetBackendId() == armnn::Compute::CpuAcc); @@ -303,7 +303,7 @@ BOOST_AUTO_TEST_CASE(OptimizeValidateWorkloadsDuplicateComputeDeviceWithFallback // If only CL is enabled, Input and Output layers are supported by GpuAcc, // the other layers are supported by CpuRef. // If neither NEON, nor CL is enabled, all layers are supported by CpuRef. -#if ARMCOMPUTENEON_ENABLED +#if defined(ARMCOMPUTENEON_ENABLED) if (layer->GetType() == armnn::LayerType::Input || layer->GetType() == armnn::LayerType::Output) { BOOST_CHECK(layer->GetBackendId() == armnn::Compute::CpuAcc); @@ -312,7 +312,7 @@ BOOST_AUTO_TEST_CASE(OptimizeValidateWorkloadsDuplicateComputeDeviceWithFallback { BOOST_CHECK(layer->GetBackendId() == armnn::Compute::CpuRef); } -#elif ARMCOMPUTECL_ENABLED +#elif defined(ARMCOMPUTECL_ENABLED) if (layer->GetType() == armnn::LayerType::Input || layer->GetType() == armnn::LayerType::Output) { BOOST_CHECK(layer->GetBackendId() == armnn::Compute::GpuAcc); diff --git a/src/backends/cl/ClLayerSupport.cpp b/src/backends/cl/ClLayerSupport.cpp index a7c1358ae7..cfc0f11d25 100644 --- a/src/backends/cl/ClLayerSupport.cpp +++ b/src/backends/cl/ClLayerSupport.cpp @@ -14,7 +14,7 @@ #include <boost/core/ignore_unused.hpp> -#ifdef ARMCOMPUTECL_ENABLED +#if defined(ARMCOMPUTECL_ENABLED) #include "workloads/ClAdditionWorkload.hpp" #include "workloads/ClActivationWorkload.hpp" #include "workloads/ClBatchNormalizationFloatWorkload.hpp" @@ -72,7 +72,7 @@ bool IsMatchingStride(uint32_t actualStride) bool IsClBackendSupported(Optional<std::string&> reasonIfUnsupported) { -#if ARMCOMPUTECL_ENABLED +#if defined(ARMCOMPUTECL_ENABLED) return true; #else if (reasonIfUnsupported) @@ -83,13 +83,13 @@ bool IsClBackendSupported(Optional<std::string&> reasonIfUnsupported) #endif } -#if ARMCOMPUTECL_ENABLED +#if defined(ARMCOMPUTECL_ENABLED) #define FORWARD_CL_LAYER_SUPPORT_FUNC(expr) (expr) #else #define FORWARD_CL_LAYER_SUPPORT_FUNC(expr) IsClBackendSupported(reasonIfUnsupported) #endif -#if ARMCOMPUTECL_ENABLED +#if defined(ARMCOMPUTECL_ENABLED) template<class FuncType, class... Args> inline bool IsWorkloadSupported(FuncType&& func, Optional<std::string&> reasonIfUnsupported, Args&&... args) { diff --git a/src/backends/cl/backend.mk b/src/backends/cl/backend.mk index a6d6e002c4..283ebcad89 100644 --- a/src/backends/cl/backend.mk +++ b/src/backends/cl/backend.mk @@ -7,6 +7,12 @@ # in the Android build and it is picked up by the Android.mk # file in the root of ArmNN +# The variable to enable/disable the CL backend (ARMNN_COMPUTE_CL_ENABLED) is declared in android-nn-driver/Android.mk +ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1) + +# ARMNN_COMPUTE_CL_ENABLED == 1 +# Include the source files for the CL backend + BACKEND_SOURCES := \ ClBackend.cpp \ ClBackendContext.cpp \ @@ -46,11 +52,25 @@ BACKEND_SOURCES := \ workloads/ClSpaceToBatchNdWorkload.cpp \ workloads/ClStridedSliceWorkload.cpp \ workloads/ClSubtractionWorkload.cpp +else + +# ARMNN_COMPUTE_CL_ENABLED == 0 +# No source file will be compiled for the CL backend + +BACKEND_SOURCES := + +endif # BACKEND_TEST_SOURCES contains the list of files to be included # in the Android unit test build (armnn-tests) and it is picked # up by the Android.mk file in the root of ArmNN +# The variable to enable/disable the CL backend (ARMNN_COMPUTE_CL_ENABLED) is declared in android-nn-driver/Android.mk +ifeq ($(ARMNN_COMPUTE_CL_ENABLED),1) + +# ARMNN_COMPUTE_CL_ENABLED == 1 +# Include the source files for the CL backend tests + BACKEND_TEST_SOURCES := \ test/ClCreateWorkloadTests.cpp \ test/ClEndToEndTests.cpp \ @@ -62,3 +82,11 @@ BACKEND_TEST_SOURCES := \ test/ClRuntimeTests.cpp \ test/Fp16SupportTest.cpp \ test/OpenClTimerTest.cpp +else + +# ARMNN_COMPUTE_CL_ENABLED == 0 +# No source file will be compiled for the CL backend tests + +BACKEND_TEST_SOURCES := + +endif diff --git a/src/backends/neon/NeonLayerSupport.cpp b/src/backends/neon/NeonLayerSupport.cpp index e56d88b7c8..53399a9bf3 100644 --- a/src/backends/neon/NeonLayerSupport.cpp +++ b/src/backends/neon/NeonLayerSupport.cpp @@ -16,7 +16,7 @@ #include <boost/core/ignore_unused.hpp> -#ifdef ARMCOMPUTENEON_ENABLED +#if defined(ARMCOMPUTENEON_ENABLED) #include "workloads/NeonAdditionWorkload.hpp" #include "workloads/NeonActivationWorkload.hpp" #include "workloads/NeonBatchNormalizationWorkload.hpp" @@ -49,7 +49,7 @@ namespace bool IsNeonBackendSupported(Optional<std::string&> reasonIfUnsupported) { -#if ARMCOMPUTENEON_ENABLED +#if defined(ARMCOMPUTENEON_ENABLED) return true; #else if (reasonIfUnsupported) @@ -78,7 +78,7 @@ bool IsSupportedForDataTypeNeon(Optional<std::string&> reasonIfUnsupported, std::forward<Params>(params)...); } -#if ARMCOMPUTENEON_ENABLED +#if defined(ARMCOMPUTENEON_ENABLED) template<class FuncType, class... Args> inline bool IsWorkloadSupported(FuncType& func, Optional<std::string&> reasonIfUnsupported, Args&&... args) { diff --git a/src/backends/neon/backend.mk b/src/backends/neon/backend.mk index 34f797ff46..d9f2ad2255 100644 --- a/src/backends/neon/backend.mk +++ b/src/backends/neon/backend.mk @@ -7,6 +7,12 @@ # in the Android build and it is picked up by the Android.mk # file in the root of ArmNN +# The variable to enable/disable the NEON backend (ARMNN_COMPUTE_NEON_ENABLED) is declared in android-nn-driver/Android.mk +ifeq ($(ARMNN_COMPUTE_NEON_ENABLED),1) + +# ARMNN_COMPUTE_NEON_ENABLED == 1 +# Include the source files for the NEON backend + BACKEND_SOURCES := \ NeonBackend.cpp \ NeonInterceptorScheduler.cpp \ @@ -42,10 +48,25 @@ BACKEND_SOURCES := \ workloads/NeonSoftmaxUint8Workload.cpp \ workloads/NeonSubtractionFloatWorkload.cpp +else + +# ARMNN_COMPUTE_NEON_ENABLED == 0 +# No source file will be compiled for the NEON backend + +BACKEND_SOURCES := + +endif + # BACKEND_TEST_SOURCES contains the list of files to be included # in the Android unit test build (armnn-tests) and it is picked # up by the Android.mk file in the root of ArmNN +# The variable to enable/disable the NEON backend (ARMNN_COMPUTE_NEON_ENABLED) is declared in android-nn-driver/Android.mk +ifeq ($(ARMNN_COMPUTE_NEON_ENABLED),1) + +# ARMNN_COMPUTE_NEON_ENABLED == 1 +# Include the source files for the NEON backend tests + BACKEND_TEST_SOURCES := \ test/NeonCreateWorkloadTests.cpp \ test/NeonEndToEndTests.cpp \ @@ -56,3 +77,12 @@ BACKEND_TEST_SOURCES := \ test/NeonOptimizedNetworkTests.cpp \ test/NeonRuntimeTests.cpp \ test/NeonTimerTest.cpp + +else + +# ARMNN_COMPUTE_NEON_ENABLED == 0 +# No source file will be compiled for the NEON backend tests + +BACKEND_TEST_SOURCES := + +endif |