IVGCVSW-3014 Check supported backends from runtime divice spec

!armnn:1070

Signed-off-by: Narumol Prangnawarat <narumol.prangnawarat@arm.com>
Change-Id: If0f411f2232e856ebc4f1a4c10fa626e3277a6ab
diff --git a/ArmnnDevice.cpp b/ArmnnDevice.cpp
index 216b010..c96798a 100644
--- a/ArmnnDevice.cpp
+++ b/ArmnnDevice.cpp
@@ -81,6 +81,31 @@
         ALOGE("ArmnnDevice: Failed to setup CL runtime: %s. Device will be unavailable.", error.what());
     }
 #endif
+    std::vector<armnn::BackendId> 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 6615e51..94fd594 100644
--- a/DriverOptions.cpp
+++ b/DriverOptions.cpp
@@ -66,7 +66,7 @@
         ("compute,c",
          po::value<std::vector<std::string>>()->
             multitoken()->default_value(std::vector<std::string>{"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 @@
     }
 
     const std::vector<std::string> backends = variablesMap["compute"].as<std::vector<std::string>>();
-    const std::vector<string> 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 895af57..141ca8a 100644
--- a/DriverOptions.hpp
+++ b/DriverOptions.hpp
@@ -31,6 +31,7 @@
     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<armnn::BackendId>& backends) { m_Backends = backends; }
 
 private:
     std::vector<armnn::BackendId> m_Backends;