From b0717b5241a15e3e4d37a1b51b6e5fd9a92a664f Mon Sep 17 00:00:00 2001 From: arovir01 Date: Wed, 5 Sep 2018 17:03:25 +0100 Subject: IVGCVSW-1806: Refactor Android-NN-Driver ModelToINetworkConverter * Moved conversion logic into new V1_0 and V1_1 HalPolicy classes * Extracted common helper functions into ConversionUtils class Change-Id: I1ab50edc266dd528c0cb22a5cd1aa65e103674d9 --- 1.1/ArmnnDriver.hpp | 105 +++++++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 55 deletions(-) (limited to '1.1/ArmnnDriver.hpp') diff --git a/1.1/ArmnnDriver.hpp b/1.1/ArmnnDriver.hpp index 38248053..ef8bca8a 100644 --- a/1.1/ArmnnDriver.hpp +++ b/1.1/ArmnnDriver.hpp @@ -9,114 +9,109 @@ #include "ArmnnDevice.hpp" #include "ArmnnDriverImpl.hpp" +#include "HalPolicy.hpp" + #include "../ArmnnDriverImpl.hpp" #include "../1.0/ArmnnDriverImpl.hpp" +#include "../1.0/HalPolicy.hpp" #include namespace armnn_driver { -namespace V1_1 +namespace hal_1_1 { -class ArmnnDriver : public ArmnnDevice, public ::android::hardware::neuralnetworks::V1_1::IDevice +class ArmnnDriver : public ArmnnDevice, public V1_1::IDevice { public: ArmnnDriver(DriverOptions options) : ArmnnDevice(std::move(options)) { - ALOGV("V1_1::ArmnnDriver::ArmnnDriver()"); + ALOGV("hal_1_1::ArmnnDriver::ArmnnDriver()"); } ~ArmnnDriver() {} public: - Return getCapabilities( - ::android::hardware::neuralnetworks::V1_0::IDevice::getCapabilities_cb cb) override + Return getCapabilities(V1_0::IDevice::getCapabilities_cb cb) override { - ALOGV("V1_1::ArmnnDriver::getCapabilities()"); + ALOGV("hal_1_1::ArmnnDriver::getCapabilities()"); - return V1_0::ArmnnDriverImpl::getCapabilities(m_Runtime, - cb); + return hal_1_0::ArmnnDriverImpl::getCapabilities(m_Runtime, cb); } - Return getSupportedOperations( - const ::android::hardware::neuralnetworks::V1_0::Model& model, - ::android::hardware::neuralnetworks::V1_0::IDevice::getSupportedOperations_cb cb) override + Return getSupportedOperations(const V1_0::Model& model, + V1_0::IDevice::getSupportedOperations_cb cb) override { - ALOGV("V1_1::ArmnnDriver::getSupportedOperations()"); + ALOGV("hal_1_1::ArmnnDriver::getSupportedOperations()"); - return armnn_driver::ArmnnDriverImpl::getSupportedOperations(m_Runtime, - m_Options, - model, - cb); + return armnn_driver::ArmnnDriverImpl::getSupportedOperations(m_Runtime, + m_Options, + model, + cb); } - Return prepareModel( - const ::android::hardware::neuralnetworks::V1_0::Model& model, - const android::sp& cb) override + Return prepareModel(const V1_0::Model& model, + const android::sp& cb) override { - ALOGV("V1_1::ArmnnDriver::prepareModel()"); + ALOGV("hal_1_1::ArmnnDriver::prepareModel()"); - return armnn_driver::ArmnnDriverImpl::prepareModel(m_Runtime, - m_ClTunedParameters, - m_Options, - model, - cb); + return armnn_driver::ArmnnDriverImpl::prepareModel(m_Runtime, + m_ClTunedParameters, + m_Options, + model, + cb); } - Return getCapabilities_1_1( - ::android::hardware::neuralnetworks::V1_1::IDevice::getCapabilities_1_1_cb cb) override + Return getCapabilities_1_1(V1_1::IDevice::getCapabilities_1_1_cb cb) override { - ALOGV("V1_1::ArmnnDriver::getCapabilities_1_1()"); + ALOGV("hal_1_1::ArmnnDriver::getCapabilities_1_1()"); - return V1_1::ArmnnDriverImpl::getCapabilities_1_1(m_Runtime, - cb); + return hal_1_1::ArmnnDriverImpl::getCapabilities_1_1(m_Runtime, cb); } - Return getSupportedOperations_1_1( - const ::android::hardware::neuralnetworks::V1_1::Model& model, - ::android::hardware::neuralnetworks::V1_1::IDevice::getSupportedOperations_1_1_cb cb) override + Return getSupportedOperations_1_1(const V1_1::Model& model, + V1_1::IDevice::getSupportedOperations_1_1_cb cb) override { - ALOGV("V1_1::ArmnnDriver::getSupportedOperations_1_1()"); + ALOGV("hal_1_1::ArmnnDriver::getSupportedOperations_1_1()"); - return armnn_driver::ArmnnDriverImpl::getSupportedOperations(m_Runtime, - m_Options, - model, - cb); + return armnn_driver::ArmnnDriverImpl::getSupportedOperations(m_Runtime, + m_Options, + model, + cb); } - Return prepareModel_1_1( - const ::android::hardware::neuralnetworks::V1_1::Model& model, - ::android::hardware::neuralnetworks::V1_1::ExecutionPreference preference, - const android::sp& cb) override + Return prepareModel_1_1(const V1_1::Model& model, + V1_1::ExecutionPreference preference, + const android::sp& cb) override { - ALOGV("V1_1::ArmnnDriver::prepareModel_1_1()"); + ALOGV("hal_1_1::ArmnnDriver::prepareModel_1_1()"); if (!(preference == ExecutionPreference::LOW_POWER || preference == ExecutionPreference::FAST_SINGLE_ANSWER || preference == ExecutionPreference::SUSTAINED_SPEED)) { - ALOGV("V1_1::ArmnnDriver::prepareModel_1_1: Invalid execution preference"); + ALOGV("hal_1_1::ArmnnDriver::prepareModel_1_1: Invalid execution preference"); cb->notify(ErrorStatus::INVALID_ARGUMENT, nullptr); return ErrorStatus::INVALID_ARGUMENT; } - return armnn_driver::ArmnnDriverImpl::prepareModel(m_Runtime, - m_ClTunedParameters, - m_Options, - model, - cb, - model.relaxComputationFloat32toFloat16 - && m_Options.GetFp16Enabled()); + return armnn_driver::ArmnnDriverImpl::prepareModel(m_Runtime, + m_ClTunedParameters, + m_Options, + model, + cb, + model.relaxComputationFloat32toFloat16 + && m_Options.GetFp16Enabled()); } Return getStatus() override { - ALOGV("V1_1::ArmnnDriver::getStatus()"); + ALOGV("hal_1_1::ArmnnDriver::getStatus()"); - return armnn_driver::ArmnnDriverImpl::getStatus(); + return armnn_driver::ArmnnDriverImpl::getStatus(); } }; -} // armnn_driver::namespace V1_1 -} // namespace armnn_driver +} // namespace hal_1_1 +} // namespace armnn_driver \ No newline at end of file -- cgit v1.2.1