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 --- ArmnnDriverImpl.hpp | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 ArmnnDriverImpl.hpp (limited to 'ArmnnDriverImpl.hpp') diff --git a/ArmnnDriverImpl.hpp b/ArmnnDriverImpl.hpp new file mode 100644 index 00000000..c0600977 --- /dev/null +++ b/ArmnnDriverImpl.hpp @@ -0,0 +1,62 @@ +// +// 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 +{ + +struct HalVersion_1_0 +{ + using Model = ::android::hardware::neuralnetworks::V1_0::Model; + using Capabilities = ::android::hardware::neuralnetworks::V1_0::Capabilities; + using getCapabilities_cb = ::android::hardware::neuralnetworks::V1_0::IDevice::getCapabilities_cb; + using getSupportedOperations_cb = ::android::hardware::neuralnetworks::V1_0::IDevice::getSupportedOperations_cb; +}; + +#if defined(ARMNN_ANDROID_NN_V1_1) +struct HalVersion_1_1 +{ + using Model = ::android::hardware::neuralnetworks::V1_1::Model; + using Capabilities = ::android::hardware::neuralnetworks::V1_1::Capabilities; + using getCapabilities_cb = ::android::hardware::neuralnetworks::V1_1::IDevice::getCapabilities_1_1_cb; + using getSupportedOperations_cb = ::android::hardware::neuralnetworks::V1_1::IDevice::getSupportedOperations_1_1_cb; +}; +#endif + +template +class ArmnnDriverImpl +{ +public: + using HalModel = typename HalVersion::Model; + using HalCapabilities = typename HalVersion::Capabilities; + using HalGetCapabilities_cb = typename HalVersion::getCapabilities_cb; + using HalGetSupportedOperations_cb = typename HalVersion::getSupportedOperations_cb; + + static Return getCapabilities( + const armnn::IRuntimePtr& runtime, + HalGetCapabilities_cb cb); + static Return getSupportedOperations( + const armnn::IRuntimePtr& runtime, + const DriverOptions& options, + const HalModel& model, + HalGetSupportedOperations_cb); + static Return prepareModel( + const armnn::IRuntimePtr& runtime, + const armnn::IGpuAccTunedParametersPtr& clTunedParameters, + const DriverOptions& options, + const HalModel& model, + const android::sp& cb, + bool float32ToFloat16 = false); + static Return getStatus(); +}; + +} // namespace armnn_driver -- cgit v1.2.1