telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame^] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // See LICENSE file in the project root for full license information. |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | #include <HalInterfaces.h> |
| 9 | |
| 10 | #include "ArmnnDevice.hpp" |
| 11 | #include "1.0/ArmnnDriverImpl.hpp" |
| 12 | #include "1.1/ArmnnDriverImpl.hpp" |
| 13 | |
| 14 | #include <log/log.h> |
| 15 | |
| 16 | namespace armnn_driver { |
| 17 | namespace V1_1 { |
| 18 | |
| 19 | class ArmnnDriver : public ArmnnDevice, public ::android::hardware::neuralnetworks::V1_1::IDevice |
| 20 | { |
| 21 | public: |
| 22 | ArmnnDriver(DriverOptions options) |
| 23 | : ArmnnDevice(std::move(options)) |
| 24 | { |
| 25 | ALOGV("V1_1::ArmnnDriver::ArmnnDriver()"); |
| 26 | } |
| 27 | ~ArmnnDriver() {} |
| 28 | |
| 29 | public: |
| 30 | Return<void> getCapabilities( |
| 31 | ::android::hardware::neuralnetworks::V1_0::IDevice::getCapabilities_cb cb) |
| 32 | { |
| 33 | ALOGV("V1_1::ArmnnDriver::getCapabilities()"); |
| 34 | |
| 35 | return V1_0::ArmnnDriverImpl::getCapabilities(m_Runtime, cb); |
| 36 | } |
| 37 | |
| 38 | Return<void> getSupportedOperations( |
| 39 | const ::android::hardware::neuralnetworks::V1_0::Model& model, |
| 40 | ::android::hardware::neuralnetworks::V1_0::IDevice::getSupportedOperations_cb cb) |
| 41 | { |
| 42 | ALOGV("V1_1::ArmnnDriver::getSupportedOperations()"); |
| 43 | |
| 44 | return V1_0::ArmnnDriverImpl::getSupportedOperations(m_Runtime, m_Options, model, cb); |
| 45 | } |
| 46 | |
| 47 | Return<ErrorStatus> prepareModel( |
| 48 | const ::android::hardware::neuralnetworks::V1_0::Model& model, |
| 49 | const android::sp<IPreparedModelCallback>& cb) |
| 50 | { |
| 51 | ALOGV("V1_1::ArmnnDriver::prepareModel()"); |
| 52 | |
| 53 | return V1_0::ArmnnDriverImpl::prepareModel(m_Runtime, m_ClTunedParameters, m_Options, model, cb); |
| 54 | } |
| 55 | |
| 56 | Return<void> getCapabilities_1_1( |
| 57 | ::android::hardware::neuralnetworks::V1_1::IDevice::getCapabilities_1_1_cb cb) |
| 58 | { |
| 59 | ALOGV("V1_1::ArmnnDriver::getCapabilities_1_1()"); |
| 60 | |
| 61 | return V1_1::ArmnnDriverImpl::getCapabilities_1_1(m_Runtime, cb); |
| 62 | } |
| 63 | |
| 64 | Return<void> getSupportedOperations_1_1( |
| 65 | const ::android::hardware::neuralnetworks::V1_1::Model& model, |
| 66 | ::android::hardware::neuralnetworks::V1_1::IDevice::getSupportedOperations_1_1_cb cb) |
| 67 | { |
| 68 | ALOGV("V1_1::ArmnnDriver::getSupportedOperations_1_1()"); |
| 69 | |
| 70 | return V1_1::ArmnnDriverImpl::getSupportedOperations_1_1(m_Runtime, m_Options, model, cb); |
| 71 | } |
| 72 | |
| 73 | Return<ErrorStatus> prepareModel_1_1( |
| 74 | const ::android::hardware::neuralnetworks::V1_1::Model& model, |
| 75 | ::android::hardware::neuralnetworks::V1_1::ExecutionPreference preference, |
| 76 | const android::sp<IPreparedModelCallback>& cb) |
| 77 | { |
| 78 | using namespace ::android::hardware::neuralnetworks::V1_0; |
| 79 | |
| 80 | ALOGV("V1_1::ArmnnDriver::prepareModel_1_1()"); |
| 81 | |
| 82 | if(!(preference == ExecutionPreference::LOW_POWER || |
| 83 | preference == ExecutionPreference::FAST_SINGLE_ANSWER || |
| 84 | preference == ExecutionPreference::SUSTAINED_SPEED)) |
| 85 | { |
| 86 | ALOGV("V1_1::ArmnnDriver::prepareModel_1_1(): Invalid execution preference"); |
| 87 | cb->notify(ErrorStatus::INVALID_ARGUMENT, nullptr); |
| 88 | return ErrorStatus::INVALID_ARGUMENT; |
| 89 | } |
| 90 | |
| 91 | return V1_1::ArmnnDriverImpl::prepareModel_1_1(m_Runtime, m_ClTunedParameters, m_Options, model, cb); |
| 92 | } |
| 93 | |
| 94 | Return<DeviceStatus> getStatus() |
| 95 | { |
| 96 | ALOGV("V1_1::ArmnnDriver::getStatus()"); |
| 97 | |
| 98 | return V1_0::ArmnnDriverImpl::getStatus(); |
| 99 | } |
| 100 | }; |
| 101 | |
| 102 | } // armnn_driver::namespace V1_1 |
| 103 | } // namespace armnn_driver |