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;
};
}
// 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.
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) {
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());
//
#include "Runtime.hpp"
-#include "armnn/Version.hpp"
+#include <armnn/Version.hpp>
+#include <backends/BackendRegistry.hpp>
#include <iostream>
: 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()