From 79250ab173e7dfa2c6057854c0d4b8dafe377fb0 Mon Sep 17 00:00:00 2001 From: Matteo Martincigh Date: Tue, 4 Sep 2018 16:28:10 +0100 Subject: IVGCVSW-1806 Restored the fp16 flag left behind during the previous refactoring * Split getCapabilities and getCapabilities_1_1 as it was before * Setting relaxedFloat32toFloat16Performance when using HAL 1.1 as required by one of the VTS test Change-Id: Iff883b8cbd0511596e9848fa40e91e4fa58d4260 --- 1.1/ArmnnDriver.hpp | 14 ++++++---- 1.1/ArmnnDriverImpl.cpp | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ 1.1/ArmnnDriverImpl.hpp | 28 +++++++++++++++++++ 3 files changed, 110 insertions(+), 5 deletions(-) create mode 100644 1.1/ArmnnDriverImpl.cpp create mode 100644 1.1/ArmnnDriverImpl.hpp (limited to '1.1') diff --git a/1.1/ArmnnDriver.hpp b/1.1/ArmnnDriver.hpp index f55aad4b..079d9cd1 100644 --- a/1.1/ArmnnDriver.hpp +++ b/1.1/ArmnnDriver.hpp @@ -8,7 +8,9 @@ #include #include "ArmnnDevice.hpp" +#include "ArmnnDriverImpl.hpp" #include "../ArmnnDriverImpl.hpp" +#include "../1.0/ArmnnDriverImpl.hpp" #include @@ -33,8 +35,8 @@ public: { ALOGV("V1_1::ArmnnDriver::getCapabilities()"); - return armnn_driver::ArmnnDriverImpl::getCapabilities(m_Runtime, - cb); + return V1_0::ArmnnDriverImpl::getCapabilities(m_Runtime, + cb); } Return getSupportedOperations( @@ -67,8 +69,8 @@ public: { ALOGV("V1_1::ArmnnDriver::getCapabilities_1_1()"); - return armnn_driver::ArmnnDriverImpl::getCapabilities(m_Runtime, - cb); + return V1_1::ArmnnDriverImpl::getCapabilities_1_1(m_Runtime, + cb); } Return getSupportedOperations_1_1( @@ -103,7 +105,9 @@ public: m_ClTunedParameters, m_Options, model, - cb); + cb, + model.relaxComputationFloat32toFloat16 + && m_Options.GetFp16Enabled()); } Return getStatus() override diff --git a/1.1/ArmnnDriverImpl.cpp b/1.1/ArmnnDriverImpl.cpp new file mode 100644 index 00000000..1d063cbc --- /dev/null +++ b/1.1/ArmnnDriverImpl.cpp @@ -0,0 +1,73 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// See LICENSE file in the project root for full license information. +// + +#include "ArmnnDriverImpl.hpp" +#include "../SystemPropertiesUtils.hpp" + +#include + +using namespace std; +using namespace android; +using namespace android::nn; +using namespace android::hardware; + +namespace +{ + +const char *g_Float32PerformanceExecTimeName = "ArmNN.float32Performance.execTime"; +const char *g_Float32PerformancePowerUsageName = "ArmNN.float32Performance.powerUsage"; +const char *g_Quantized8PerformanceExecTimeName = "ArmNN.quantized8Performance.execTime"; +const char *g_Quantized8PerformancePowerUsageName = "ArmNN.quantized8Performance.powerUsage"; +const char *g_RelaxedFloat32toFloat16PerformanceExecTime = "ArmNN.relaxedFloat32toFloat16Performance.execTime"; + +} // anonymous namespace + +namespace armnn_driver +{ +namespace V1_1 +{ + +Return ArmnnDriverImpl::getCapabilities_1_1( + const armnn::IRuntimePtr& runtime, + neuralnetworks::V1_1::IDevice::getCapabilities_1_1_cb cb) +{ + ALOGV("V1_1::ArmnnDriverImpl::getCapabilities()"); + + neuralnetworks::V1_1::Capabilities capabilities; + if (runtime) + { + capabilities.float32Performance.execTime = + ParseSystemProperty(g_Float32PerformanceExecTimeName, .1f); + + capabilities.float32Performance.powerUsage = + ParseSystemProperty(g_Float32PerformancePowerUsageName, .1f); + + capabilities.quantized8Performance.execTime = + ParseSystemProperty(g_Quantized8PerformanceExecTimeName, .1f); + + capabilities.quantized8Performance.powerUsage = + ParseSystemProperty(g_Quantized8PerformancePowerUsageName, .1f); + + capabilities.relaxedFloat32toFloat16Performance.execTime = + ParseSystemProperty(g_RelaxedFloat32toFloat16PerformanceExecTime, .1f); + + cb(ErrorStatus::NONE, capabilities); + } + else + { + capabilities.float32Performance.execTime = 0; + capabilities.float32Performance.powerUsage = 0; + capabilities.quantized8Performance.execTime = 0; + capabilities.quantized8Performance.powerUsage = 0; + capabilities.relaxedFloat32toFloat16Performance.execTime = 0; + + cb(ErrorStatus::DEVICE_UNAVAILABLE, capabilities); + } + + return Void(); +} + +} // namespace armnn_driver::V1_1 +} // namespace armnn_driver diff --git a/1.1/ArmnnDriverImpl.hpp b/1.1/ArmnnDriverImpl.hpp new file mode 100644 index 00000000..c309b69d --- /dev/null +++ b/1.1/ArmnnDriverImpl.hpp @@ -0,0 +1,28 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// See LICENSE file in the project root for full license information. +// + +#pragma once + +#include + +#include "../DriverOptions.hpp" + +#include + +namespace armnn_driver +{ +namespace V1_1 +{ + +class ArmnnDriverImpl +{ +public: + static Return getCapabilities_1_1( + const armnn::IRuntimePtr& runtime, + ::android::hardware::neuralnetworks::V1_1::IDevice::getCapabilities_1_1_cb cb); +}; + +} // namespace armnn_driver::V1_1 +} // namespace armnn_driver -- cgit v1.2.1