From 856d1c9c9b0b1609282c4f797cbafefc6531240d Mon Sep 17 00:00:00 2001 From: Narumol Prangnawarat Date: Fri, 3 May 2019 16:42:52 +0100 Subject: IVGCVSW-3014 Check supported backends from runtime divice spec !armnn:1070 Signed-off-by: Narumol Prangnawarat Change-Id: If0f411f2232e856ebc4f1a4c10fa626e3277a6ab --- ArmnnDevice.cpp | 25 +++++++++++++++++++++++++ DriverOptions.cpp | 17 +---------------- DriverOptions.hpp | 1 + 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/ArmnnDevice.cpp b/ArmnnDevice.cpp index 216b010c..c96798a8 100644 --- a/ArmnnDevice.cpp +++ b/ArmnnDevice.cpp @@ -81,6 +81,31 @@ ArmnnDevice::ArmnnDevice(DriverOptions options) ALOGE("ArmnnDevice: Failed to setup CL runtime: %s. Device will be unavailable.", error.what()); } #endif + std::vector backends; + + if (m_Runtime) + { + const armnn::BackendIdSet supportedDevices = m_Runtime->GetDeviceSpec().GetSupportedBackends(); + for (auto &backend : m_Options.GetBackends()) + { + if (std::find(supportedDevices.cbegin(), supportedDevices.cend(), backend) == supportedDevices.cend()) + { + ALOGW("Requested unknown backend %s", backend.Get().c_str()); + } + else + { + backends.push_back(backend); + } + } + } + + if (backends.empty()) + { + backends.emplace_back("GpuAcc"); + ALOGW("No known backend specified. Defaulting to: GpuAcc"); + } + + m_Options.SetBackends(backends); ALOGV("ArmnnDevice: Created device with the following backends: %s", GetBackendString(m_Options).c_str()); } diff --git a/DriverOptions.cpp b/DriverOptions.cpp index 6615e519..94fd5942 100644 --- a/DriverOptions.cpp +++ b/DriverOptions.cpp @@ -66,7 +66,7 @@ DriverOptions::DriverOptions(int argc, char** argv) ("compute,c", po::value>()-> multitoken()->default_value(std::vector{"GpuAcc"}, "{GpuAcc}"), - "Which backend to run layers on. Possible values are: CpuRef, CpuAcc, GpuAcc") + "Which backend to run layers on. Examples of possible values are: CpuRef, CpuAcc, GpuAcc") ("verbose-logging,v", po::bool_switch(&m_VerboseLogging), @@ -120,25 +120,10 @@ DriverOptions::DriverOptions(int argc, char** argv) } const std::vector backends = variablesMap["compute"].as>(); - const std::vector supportedDevices({"CpuRef", "CpuAcc", "GpuAcc"}); m_Backends.reserve(backends.size()); - for (auto&& backend : backends) { - if (std::find(supportedDevices.cbegin(), supportedDevices.cend(), backend) == supportedDevices.cend()) - { - ALOGW("Requested unknown backend %s", backend.c_str()); - } - else - { m_Backends.emplace_back(backend); - } - } - - if (m_Backends.empty()) - { - m_Backends.emplace_back("GpuAcc"); - ALOGW("No known backend specified. Defaulting to: GpuAcc"); } if (!unsupportedOperationsAsString.empty()) diff --git a/DriverOptions.hpp b/DriverOptions.hpp index 895af574..141ca8a2 100644 --- a/DriverOptions.hpp +++ b/DriverOptions.hpp @@ -31,6 +31,7 @@ public: armnn::IGpuAccTunedParameters::TuningLevel GetClTuningLevel() const { return m_ClTuningLevel; } bool IsGpuProfilingEnabled() const { return m_EnableGpuProfiling; } bool GetFp16Enabled() const { return m_fp16Enabled; } + void SetBackends(const std::vector& backends) { m_Backends = backends; } private: std::vector m_Backends; -- cgit v1.2.1