blob: 4785ef7c67658ee8a82794fbef6e02409fea730b [file] [log] [blame]
Matteo Martincighe48bdff2018-09-03 13:50:50 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beck93e48982018-09-05 13:05:09 +01003// SPDX-License-Identifier: MIT
Matteo Martincighe48bdff2018-09-03 13:50:50 +01004//
5
6#pragma once
7
Matteo Martincighe48bdff2018-09-03 13:50:50 +01008#include "DriverOptions.hpp"
9
arovir01b0717b52018-09-05 17:03:25 +010010#include <HalInterfaces.h>
Matteo Martincighe48bdff2018-09-03 13:50:50 +010011
Kevin Mayec1e5b82020-02-26 17:00:39 +000012#ifdef ARMNN_ANDROID_R
13using namespace android::nn::hal;
14#endif
15
Sadik Armagan188675f2021-02-12 17:16:42 +000016#ifdef ARMNN_ANDROID_S
17using namespace android::hardware;
18#endif
19
Matthew Bentham912b3622019-05-03 15:49:14 +010020namespace V1_0 = ::android::hardware::neuralnetworks::V1_0;
Mike Kellyb5fdf382019-06-11 16:35:25 +010021namespace V1_1 = ::android::hardware::neuralnetworks::V1_1;
22
23#ifdef ARMNN_ANDROID_NN_V1_2 // Using ::android::hardware::neuralnetworks::V1_2
24namespace V1_2 = ::android::hardware::neuralnetworks::V1_2;
25#endif
Matthew Bentham912b3622019-05-03 15:49:14 +010026
Kevin May42477c12020-03-26 13:34:14 +000027#ifdef ARMNN_ANDROID_NN_V1_3 // Using ::android::hardware::neuralnetworks::V1_3
28namespace V1_2 = ::android::hardware::neuralnetworks::V1_2;
29namespace V1_3 = ::android::hardware::neuralnetworks::V1_3;
30#endif
31
Matteo Martincighe48bdff2018-09-03 13:50:50 +010032namespace armnn_driver
33{
34
Derek Lamberti4de83c52020-03-17 13:40:18 +000035template <typename Callback, typename Context>
36struct CallbackContext
37{
38 Callback callback;
39 Context ctx;
40};
41
arovir01b0717b52018-09-05 17:03:25 +010042template<typename HalPolicy>
Matteo Martincighe48bdff2018-09-03 13:50:50 +010043class ArmnnDriverImpl
44{
45public:
arovir01b0717b52018-09-05 17:03:25 +010046 using HalModel = typename HalPolicy::Model;
47 using HalGetSupportedOperations_cb = typename HalPolicy::getSupportedOperations_cb;
Kevin May42477c12020-03-26 13:34:14 +000048 using HalErrorStatus = typename HalPolicy::ErrorStatus;
Matteo Martincighe48bdff2018-09-03 13:50:50 +010049
Matteo Martincighe48bdff2018-09-03 13:50:50 +010050 static Return<void> getSupportedOperations(
51 const armnn::IRuntimePtr& runtime,
52 const DriverOptions& options,
53 const HalModel& model,
54 HalGetSupportedOperations_cb);
arovir01b0717b52018-09-05 17:03:25 +010055
Kevin Mayec1e5b82020-02-26 17:00:39 +000056 static Return<V1_0::ErrorStatus> prepareModel(
Matteo Martincighe48bdff2018-09-03 13:50:50 +010057 const armnn::IRuntimePtr& runtime,
58 const armnn::IGpuAccTunedParametersPtr& clTunedParameters,
59 const DriverOptions& options,
60 const HalModel& model,
Matthew Bentham912b3622019-05-03 15:49:14 +010061 const android::sp<V1_0::IPreparedModelCallback>& cb,
Matteo Martincighe48bdff2018-09-03 13:50:50 +010062 bool float32ToFloat16 = false);
arovir01b0717b52018-09-05 17:03:25 +010063
Sadik Armagan188675f2021-02-12 17:16:42 +000064 static Return<V1_0::DeviceStatus> getStatus();
Mike Kellyb5fdf382019-06-11 16:35:25 +010065
Matteo Martincighe48bdff2018-09-03 13:50:50 +010066};
67
68} // namespace armnn_driver