From e48bdff741568236d3c0747ad3d18a8eba5b36dd Mon Sep 17 00:00:00 2001 From: Matteo Martincigh Date: Mon, 3 Sep 2018 13:50:50 +0100 Subject: IVGCVSW-1806 Refactored Android-NN-Driver, added common "getCapabilities", "getSupportedOperations" and "prepareModel" implementations * Added common base ArmnnDriverImpl class * Added common template implementation of the driver's "getCapabilities", "getSupportedOperations" and "prepareModel" methods * Refactored ArmnnPreparedModel and RequestThread to support HAL v1.1 models * Moved "getStatus" to the common base class, as it is shared by both HAL implementations * Refactored the code where necessary Change-Id: I747334730026d63b4002662523fb93608f67c899 --- 1.1/ArmnnDriver.hpp | 63 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 24 deletions(-) (limited to '1.1/ArmnnDriver.hpp') diff --git a/1.1/ArmnnDriver.hpp b/1.1/ArmnnDriver.hpp index 6bd8e03c..f55aad4b 100644 --- a/1.1/ArmnnDriver.hpp +++ b/1.1/ArmnnDriver.hpp @@ -8,13 +8,14 @@ #include #include "ArmnnDevice.hpp" -#include "1.0/ArmnnDriverImpl.hpp" -#include "1.1/ArmnnDriverImpl.hpp" +#include "../ArmnnDriverImpl.hpp" #include -namespace armnn_driver { -namespace V1_1 { +namespace armnn_driver +{ +namespace V1_1 +{ class ArmnnDriver : public ArmnnDevice, public ::android::hardware::neuralnetworks::V1_1::IDevice { @@ -28,74 +29,88 @@ public: public: Return getCapabilities( - ::android::hardware::neuralnetworks::V1_0::IDevice::getCapabilities_cb cb) + ::android::hardware::neuralnetworks::V1_0::IDevice::getCapabilities_cb cb) override { ALOGV("V1_1::ArmnnDriver::getCapabilities()"); - return V1_0::ArmnnDriverImpl::getCapabilities(m_Runtime, cb); + return armnn_driver::ArmnnDriverImpl::getCapabilities(m_Runtime, + cb); } Return getSupportedOperations( const ::android::hardware::neuralnetworks::V1_0::Model& model, - ::android::hardware::neuralnetworks::V1_0::IDevice::getSupportedOperations_cb cb) + ::android::hardware::neuralnetworks::V1_0::IDevice::getSupportedOperations_cb cb) override { ALOGV("V1_1::ArmnnDriver::getSupportedOperations()"); - return V1_0::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) + const android::sp& cb) override { ALOGV("V1_1::ArmnnDriver::prepareModel()"); - return V1_0::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) + ::android::hardware::neuralnetworks::V1_1::IDevice::getCapabilities_1_1_cb cb) override { ALOGV("V1_1::ArmnnDriver::getCapabilities_1_1()"); - return V1_1::ArmnnDriverImpl::getCapabilities_1_1(m_Runtime, cb); + return armnn_driver::ArmnnDriverImpl::getCapabilities(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) + ::android::hardware::neuralnetworks::V1_1::IDevice::getSupportedOperations_1_1_cb cb) override { ALOGV("V1_1::ArmnnDriver::getSupportedOperations_1_1()"); - return V1_1::ArmnnDriverImpl::getSupportedOperations_1_1(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) + const android::sp& cb) override { - using namespace ::android::hardware::neuralnetworks::V1_0; - ALOGV("V1_1::ArmnnDriver::prepareModel_1_1()"); - if(!(preference == ExecutionPreference::LOW_POWER || - preference == ExecutionPreference::FAST_SINGLE_ANSWER || - preference == ExecutionPreference::SUSTAINED_SPEED)) + 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("V1_1::ArmnnDriver::prepareModel_1_1: Invalid execution preference"); cb->notify(ErrorStatus::INVALID_ARGUMENT, nullptr); return ErrorStatus::INVALID_ARGUMENT; } - return V1_1::ArmnnDriverImpl::prepareModel_1_1(m_Runtime, m_ClTunedParameters, m_Options, model, cb); + return armnn_driver::ArmnnDriverImpl::prepareModel(m_Runtime, + m_ClTunedParameters, + m_Options, + model, + cb); } - Return getStatus() + Return getStatus() override { ALOGV("V1_1::ArmnnDriver::getStatus()"); - return V1_0::ArmnnDriverImpl::getStatus(); + return armnn_driver::ArmnnDriverImpl::getStatus(); } }; -- cgit v1.2.1