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 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'ArmnnDevice.cpp') 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()); } -- cgit v1.2.1