From 6bf3f43c6f1d88c676f277f4c3c766cb3ea37ed0 Mon Sep 17 00:00:00 2001 From: Pablo Tello Date: Wed, 1 Sep 2021 15:30:10 +0100 Subject: android-nn-driver getType returns the right device * ArmnnDriver queries the options and returns CPU or GPU depending on which is the first backend listed in the options * Resolves MLCE-401 Change-Id: If4e63e144507e817449f37926711fa325861b57d Signed-off-by: Pablo Tello --- 1.2/HalPolicy.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to '1.2/HalPolicy.cpp') diff --git a/1.2/HalPolicy.cpp b/1.2/HalPolicy.cpp index fb6c31ce..79d117ae 100644 --- a/1.2/HalPolicy.cpp +++ b/1.2/HalPolicy.cpp @@ -4,6 +4,8 @@ // #include "HalPolicy.hpp" +#include "DriverOptions.hpp" + namespace armnn_driver { @@ -17,6 +19,33 @@ namespace } // anonymous namespace +HalPolicy::DeviceType HalPolicy::GetDeviceTypeFromOptions(const DriverOptions& options) +{ + // Query backends list from the options + auto backends = options.GetBackends(); + // Return first backend + if(backends.size()>0) + { + const auto &first_backend = backends[0]; + if(first_backend.IsCpuAcc()||first_backend.IsCpuRef()) + { + return V1_2::DeviceType::CPU; + } + else if(first_backend.IsGpuAcc()) + { + return V1_2::DeviceType::GPU; + } + else + { + return V1_2::DeviceType::ACCELERATOR; + } + } + else + { + return V1_2::DeviceType::CPU; + } +} + bool HalPolicy::ConvertOperation(const Operation& operation, const Model& model, ConversionData& data) { switch (operation.type) -- cgit v1.2.1