blob: f55aad4b90a52f61e075405f6d9deadc342c5385 [file] [log] [blame]
telsoa01ce3e84a2018-08-31 09:31:35 +01001//
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"
Matteo Martincighe48bdff2018-09-03 13:50:50 +010011#include "../ArmnnDriverImpl.hpp"
telsoa01ce3e84a2018-08-31 09:31:35 +010012
13#include <log/log.h>
14
Matteo Martincighe48bdff2018-09-03 13:50:50 +010015namespace armnn_driver
16{
17namespace V1_1
18{
telsoa01ce3e84a2018-08-31 09:31:35 +010019
20class ArmnnDriver : public ArmnnDevice, public ::android::hardware::neuralnetworks::V1_1::IDevice
21{
22public:
23 ArmnnDriver(DriverOptions options)
24 : ArmnnDevice(std::move(options))
25 {
26 ALOGV("V1_1::ArmnnDriver::ArmnnDriver()");
27 }
28 ~ArmnnDriver() {}
29
30public:
31 Return<void> getCapabilities(
Matteo Martincighe48bdff2018-09-03 13:50:50 +010032 ::android::hardware::neuralnetworks::V1_0::IDevice::getCapabilities_cb cb) override
telsoa01ce3e84a2018-08-31 09:31:35 +010033 {
34 ALOGV("V1_1::ArmnnDriver::getCapabilities()");
35
Matteo Martincighe48bdff2018-09-03 13:50:50 +010036 return armnn_driver::ArmnnDriverImpl<HalVersion_1_0>::getCapabilities(m_Runtime,
37 cb);
telsoa01ce3e84a2018-08-31 09:31:35 +010038 }
39
40 Return<void> getSupportedOperations(
41 const ::android::hardware::neuralnetworks::V1_0::Model& model,
Matteo Martincighe48bdff2018-09-03 13:50:50 +010042 ::android::hardware::neuralnetworks::V1_0::IDevice::getSupportedOperations_cb cb) override
telsoa01ce3e84a2018-08-31 09:31:35 +010043 {
44 ALOGV("V1_1::ArmnnDriver::getSupportedOperations()");
45
Matteo Martincighe48bdff2018-09-03 13:50:50 +010046 return armnn_driver::ArmnnDriverImpl<HalVersion_1_0>::getSupportedOperations(m_Runtime,
47 m_Options,
48 model,
49 cb);
telsoa01ce3e84a2018-08-31 09:31:35 +010050 }
51
52 Return<ErrorStatus> prepareModel(
53 const ::android::hardware::neuralnetworks::V1_0::Model& model,
Matteo Martincighe48bdff2018-09-03 13:50:50 +010054 const android::sp<IPreparedModelCallback>& cb) override
telsoa01ce3e84a2018-08-31 09:31:35 +010055 {
56 ALOGV("V1_1::ArmnnDriver::prepareModel()");
57
Matteo Martincighe48bdff2018-09-03 13:50:50 +010058 return armnn_driver::ArmnnDriverImpl<HalVersion_1_0>::prepareModel(m_Runtime,
59 m_ClTunedParameters,
60 m_Options,
61 model,
62 cb);
telsoa01ce3e84a2018-08-31 09:31:35 +010063 }
64
65 Return<void> getCapabilities_1_1(
Matteo Martincighe48bdff2018-09-03 13:50:50 +010066 ::android::hardware::neuralnetworks::V1_1::IDevice::getCapabilities_1_1_cb cb) override
telsoa01ce3e84a2018-08-31 09:31:35 +010067 {
68 ALOGV("V1_1::ArmnnDriver::getCapabilities_1_1()");
69
Matteo Martincighe48bdff2018-09-03 13:50:50 +010070 return armnn_driver::ArmnnDriverImpl<HalVersion_1_1>::getCapabilities(m_Runtime,
71 cb);
telsoa01ce3e84a2018-08-31 09:31:35 +010072 }
73
74 Return<void> getSupportedOperations_1_1(
75 const ::android::hardware::neuralnetworks::V1_1::Model& model,
Matteo Martincighe48bdff2018-09-03 13:50:50 +010076 ::android::hardware::neuralnetworks::V1_1::IDevice::getSupportedOperations_1_1_cb cb) override
telsoa01ce3e84a2018-08-31 09:31:35 +010077 {
78 ALOGV("V1_1::ArmnnDriver::getSupportedOperations_1_1()");
79
Matteo Martincighe48bdff2018-09-03 13:50:50 +010080 return armnn_driver::ArmnnDriverImpl<HalVersion_1_1>::getSupportedOperations(m_Runtime,
81 m_Options,
82 model,
83 cb);
telsoa01ce3e84a2018-08-31 09:31:35 +010084 }
85
86 Return<ErrorStatus> prepareModel_1_1(
87 const ::android::hardware::neuralnetworks::V1_1::Model& model,
88 ::android::hardware::neuralnetworks::V1_1::ExecutionPreference preference,
Matteo Martincighe48bdff2018-09-03 13:50:50 +010089 const android::sp<IPreparedModelCallback>& cb) override
telsoa01ce3e84a2018-08-31 09:31:35 +010090 {
telsoa01ce3e84a2018-08-31 09:31:35 +010091 ALOGV("V1_1::ArmnnDriver::prepareModel_1_1()");
92
Matteo Martincighe48bdff2018-09-03 13:50:50 +010093 if (!(preference == ExecutionPreference::LOW_POWER ||
94 preference == ExecutionPreference::FAST_SINGLE_ANSWER ||
95 preference == ExecutionPreference::SUSTAINED_SPEED))
telsoa01ce3e84a2018-08-31 09:31:35 +010096 {
Matteo Martincighe48bdff2018-09-03 13:50:50 +010097 ALOGV("V1_1::ArmnnDriver::prepareModel_1_1: Invalid execution preference");
telsoa01ce3e84a2018-08-31 09:31:35 +010098 cb->notify(ErrorStatus::INVALID_ARGUMENT, nullptr);
99 return ErrorStatus::INVALID_ARGUMENT;
100 }
101
Matteo Martincighe48bdff2018-09-03 13:50:50 +0100102 return armnn_driver::ArmnnDriverImpl<HalVersion_1_1>::prepareModel(m_Runtime,
103 m_ClTunedParameters,
104 m_Options,
105 model,
106 cb);
telsoa01ce3e84a2018-08-31 09:31:35 +0100107 }
108
Matteo Martincighe48bdff2018-09-03 13:50:50 +0100109 Return<DeviceStatus> getStatus() override
telsoa01ce3e84a2018-08-31 09:31:35 +0100110 {
111 ALOGV("V1_1::ArmnnDriver::getStatus()");
112
Matteo Martincighe48bdff2018-09-03 13:50:50 +0100113 return armnn_driver::ArmnnDriverImpl<HalVersion_1_1>::getStatus();
telsoa01ce3e84a2018-08-31 09:31:35 +0100114 }
115};
116
117} // armnn_driver::namespace V1_1
118} // namespace armnn_driver