// // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // #pragma once #include #include "../ArmnnDevice.hpp" #include "ArmnnDriverImpl.hpp" #include "HalPolicy.hpp" #include "../ArmnnDriverImpl.hpp" #include "../1.2/ArmnnDriverImpl.hpp" #include "../1.2/HalPolicy.hpp" #include "../1.1/ArmnnDriverImpl.hpp" #include "../1.1/HalPolicy.hpp" #include "../1.0/ArmnnDriverImpl.hpp" #include "../1.0/HalPolicy.hpp" #include namespace armnn_driver { namespace hal_1_2 { class ArmnnDriver : public ArmnnDevice, public V1_2::IDevice { public: ArmnnDriver(DriverOptions options) : ArmnnDevice(std::move(options)) { ALOGV("hal_1_2::ArmnnDriver::ArmnnDriver()"); } ~ArmnnDriver() {} using HidlToken = android::hardware::hidl_array; public: Return getCapabilities(V1_0::IDevice::getCapabilities_cb cb) override { ALOGV("hal_1_2::ArmnnDriver::getCapabilities()"); return hal_1_0::ArmnnDriverImpl::getCapabilities(m_Runtime, cb); } Return getSupportedOperations(const V1_0::Model& model, V1_0::IDevice::getSupportedOperations_cb cb) override { ALOGV("hal_1_2::ArmnnDriver::getSupportedOperations()"); return armnn_driver::ArmnnDriverImpl::getSupportedOperations(m_Runtime, m_Options, model, cb); } Return prepareModel(const V1_0::Model& model, const android::sp& cb) override { ALOGV("hal_1_2::ArmnnDriver::prepareModel()"); return armnn_driver::ArmnnDriverImpl::prepareModel(m_Runtime, m_ClTunedParameters, m_Options, model, cb); } Return getCapabilities_1_1(V1_1::IDevice::getCapabilities_1_1_cb cb) override { ALOGV("hal_1_2::ArmnnDriver::getCapabilities_1_1()"); return hal_1_1::ArmnnDriverImpl::getCapabilities_1_1(m_Runtime, cb); } Return getSupportedOperations_1_1(const V1_1::Model& model, V1_1::IDevice::getSupportedOperations_1_1_cb cb) override { ALOGV("hal_1_2::ArmnnDriver::getSupportedOperations_1_1()"); return armnn_driver::ArmnnDriverImpl::getSupportedOperations(m_Runtime, m_Options, model, cb); } Return prepareModel_1_1(const V1_1::Model& model, V1_1::ExecutionPreference preference, const android::sp& cb) override { ALOGV("hal_1_2::ArmnnDriver::prepareModel_1_1()"); if (!(preference == V1_1::ExecutionPreference::LOW_POWER || preference == V1_1::ExecutionPreference::FAST_SINGLE_ANSWER || preference == V1_1::ExecutionPreference::SUSTAINED_SPEED)) { ALOGV("hal_1_2::ArmnnDriver::prepareModel_1_1: Invalid execution preference"); cb->notify(V1_0::ErrorStatus::INVALID_ARGUMENT, nullptr); return V1_0::ErrorStatus::INVALID_ARGUMENT; } return armnn_driver::ArmnnDriverImpl::prepareModel(m_Runtime, m_ClTunedParameters, m_Options, model, cb, model.relaxComputationFloat32toFloat16 && m_Options.GetFp16Enabled()); } Return getStatus() override { ALOGV("hal_1_2::ArmnnDriver::getStatus()"); return armnn_driver::ArmnnDriverImpl::getStatus(); } Return getVersionString(getVersionString_cb cb) { ALOGV("hal_1_2::ArmnnDriver::getVersionString()"); cb(V1_0::ErrorStatus::NONE, "ArmNN"); return Void(); } Return getType(getType_cb cb) { ALOGV("hal_1_2::ArmnnDriver::getType()"); cb(V1_0::ErrorStatus::NONE, V1_2::DeviceType::CPU); return Void(); } Return prepareModelFromCache( const android::hardware::hidl_vec&, const android::hardware::hidl_vec&, const HidlToken&, const sp& callback) { ALOGV("hal_1_2::ArmnnDriver::prepareModelFromCache()"); callback->notify_1_2(V1_0::ErrorStatus::GENERAL_FAILURE, nullptr); return V1_0::ErrorStatus::GENERAL_FAILURE; } Return prepareModel_1_2(const V1_2::Model& model, V1_1::ExecutionPreference preference, const android::hardware::hidl_vec&, const android::hardware::hidl_vec&, const HidlToken&, const android::sp& cb) { ALOGV("hal_1_2::ArmnnDriver::prepareModel_1_2()"); if (!(preference == V1_1::ExecutionPreference::LOW_POWER || preference == V1_1::ExecutionPreference::FAST_SINGLE_ANSWER || preference == V1_1::ExecutionPreference::SUSTAINED_SPEED)) { ALOGV("hal_1_2::ArmnnDriver::prepareModel_1_2: Invalid execution preference"); cb->notify(V1_0::ErrorStatus::INVALID_ARGUMENT, nullptr); return V1_0::ErrorStatus::INVALID_ARGUMENT; } return ArmnnDriverImpl::prepareArmnnModel_1_2(m_Runtime, m_ClTunedParameters, m_Options, model, cb, model.relaxComputationFloat32toFloat16 && m_Options.GetFp16Enabled()); } Return getSupportedExtensions(getSupportedExtensions_cb cb) { ALOGV("hal_1_2::ArmnnDriver::getSupportedExtensions()"); cb(V1_0::ErrorStatus::NONE, {/* No extensions. */}); return Void(); } Return getCapabilities_1_2(getCapabilities_1_2_cb cb) { ALOGV("hal_1_2::ArmnnDriver::getCapabilities()"); return hal_1_2::ArmnnDriverImpl::getCapabilities_1_2(m_Runtime, cb); } Return getSupportedOperations_1_2(const V1_2::Model& model, getSupportedOperations_1_2_cb cb) { ALOGV("hal_1_2::ArmnnDriver::getSupportedOperations()"); return armnn_driver::ArmnnDriverImpl::getSupportedOperations(m_Runtime, m_Options, model, cb); } Return getNumberOfCacheFilesNeeded(getNumberOfCacheFilesNeeded_cb cb) { ALOGV("hal_1_2::ArmnnDriver::getSupportedExtensions()"); // Set both numbers to be 0 for cache not supported. cb(V1_0::ErrorStatus::NONE, 0, 0); return Void(); } }; } // namespace hal_1_2 } // namespace armnn_driver