diff options
author | David Beck <david.beck@arm.com> | 2018-10-22 13:16:00 +0100 |
---|---|---|
committer | Matthew Bentham <matthew.bentham@arm.com> | 2018-10-22 16:57:54 +0100 |
commit | 056be3cbe0306f4e1409c10952a8a73676a4acdd (patch) | |
tree | c7bcbeed66468b49dde7cf16f77256cd128b584c /src/armnn | |
parent | a8e06ed540a934f966679e1ef1cf7acf295211b3 (diff) | |
download | armnn-056be3cbe0306f4e1409c10952a8a73676a4acdd.tar.gz |
IVGCVSW-1991 : refactor m_SupportedComputes in DeviceSpecs
Change-Id: Ied3d54dc356f5e4f87aeb59f66423ac1f893dd01
Diffstat (limited to 'src/armnn')
-rw-r--r-- | src/armnn/DeviceSpec.hpp | 12 | ||||
-rw-r--r-- | src/armnn/Network.cpp | 7 | ||||
-rw-r--r-- | src/armnn/Runtime.cpp | 12 |
3 files changed, 14 insertions, 17 deletions
diff --git a/src/armnn/DeviceSpec.hpp b/src/armnn/DeviceSpec.hpp index af0d8f578b..834ce0921d 100644 --- a/src/armnn/DeviceSpec.hpp +++ b/src/armnn/DeviceSpec.hpp @@ -14,15 +14,19 @@ namespace armnn class DeviceSpec : public IDeviceSpec { public: - DeviceSpec() {} + DeviceSpec(const BackendIdSet& supportedBackends) + : m_SupportedBackends{supportedBackends} {} + virtual ~DeviceSpec() {} - virtual std::vector<IBackendSharedPtr> GetBackends() const + virtual const BackendIdSet& GetSupportedBackends() const { - return std::vector<IBackendSharedPtr>(); + return m_SupportedBackends; } - std::set<BackendId> m_SupportedComputeDevices; +private: + DeviceSpec() = delete; + BackendIdSet m_SupportedBackends; }; } diff --git a/src/armnn/Network.cpp b/src/armnn/Network.cpp index 8c70e5d793..f95e829cb9 100644 --- a/src/armnn/Network.cpp +++ b/src/armnn/Network.cpp @@ -129,6 +129,7 @@ IOptimizedNetworkPtr Optimize(const INetwork& inNetwork, // We know that DeviceSpec should be the only implementation of IDeviceSpec. const DeviceSpec& spec = *boost::polymorphic_downcast<const DeviceSpec*>(&deviceSpec); + auto const& supportedBackends = spec.GetSupportedBackends(); // determine which of the preferred backends we have available for use // and whether we have specified CpuRef as one of those backends. @@ -137,9 +138,7 @@ IOptimizedNetworkPtr Optimize(const INetwork& inNetwork, for (const auto& backend : backendPreferences) { // Check if the backend is in the available backend devices. - if (std::find(spec.m_SupportedComputeDevices.begin(), - spec.m_SupportedComputeDevices.end(), backend) != - spec.m_SupportedComputeDevices.end()) + if (supportedBackends.count(backend) > 0) { availablePreferredBackends.push_back(backend); if (backend == armnn::Compute::CpuRef) { @@ -150,7 +149,7 @@ IOptimizedNetworkPtr Optimize(const INetwork& inNetwork, if (availablePreferredBackends.empty()) { std::stringstream failureMsg; failureMsg << "ERROR: None of the preferred backends " << backendPreferences - << " are supported. Current platform provides " << spec.m_SupportedComputeDevices; + << " are supported. Current platform provides " << supportedBackends; BOOST_LOG_TRIVIAL(warning) << failureMsg.str(); if (errMessages) { errMessages.value().push_back(failureMsg.str()); diff --git a/src/armnn/Runtime.cpp b/src/armnn/Runtime.cpp index 354a567f88..8a7023ed76 100644 --- a/src/armnn/Runtime.cpp +++ b/src/armnn/Runtime.cpp @@ -4,7 +4,8 @@ // #include "Runtime.hpp" -#include "armnn/Version.hpp" +#include <armnn/Version.hpp> +#include <backends/BackendRegistry.hpp> #include <iostream> @@ -133,16 +134,9 @@ Runtime::Runtime(const CreationOptions& options) : m_ClContextControl(options.m_GpuAccTunedParameters.get(), options.m_EnableGpuProfiling) , m_NetworkIdCounter(0) + , m_DeviceSpec{BackendRegistryInstance().GetBackendIds()} { BOOST_LOG_TRIVIAL(info) << "ArmNN v" << ARMNN_VERSION << "\n"; - - m_DeviceSpec.m_SupportedComputeDevices.insert(armnn::Compute::CpuRef); - #if ARMCOMPUTECL_ENABLED - m_DeviceSpec.m_SupportedComputeDevices.insert(armnn::Compute::GpuAcc); - #endif - #if ARMCOMPUTENEON_ENABLED - m_DeviceSpec.m_SupportedComputeDevices.insert(armnn::Compute::CpuAcc); - #endif } Runtime::~Runtime() |