blob: cdff90544c462f89427687862973be8651dee285 [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
Matthew Bentham912b3622019-05-03 15:49:14 +010016namespace V1_0 = ::android::hardware::neuralnetworks::V1_0;
Mike Kellyb5fdf382019-06-11 16:35:25 +010017namespace V1_1 = ::android::hardware::neuralnetworks::V1_1;
18
19#ifdef ARMNN_ANDROID_NN_V1_2 // Using ::android::hardware::neuralnetworks::V1_2
20namespace V1_2 = ::android::hardware::neuralnetworks::V1_2;
21#endif
Matthew Bentham912b3622019-05-03 15:49:14 +010022
Kevin May42477c12020-03-26 13:34:14 +000023#ifdef ARMNN_ANDROID_NN_V1_3 // Using ::android::hardware::neuralnetworks::V1_3
24namespace V1_2 = ::android::hardware::neuralnetworks::V1_2;
25namespace V1_3 = ::android::hardware::neuralnetworks::V1_3;
26#endif
27
Matteo Martincighe48bdff2018-09-03 13:50:50 +010028namespace armnn_driver
29{
30
Derek Lamberti4de83c52020-03-17 13:40:18 +000031template <typename Callback, typename Context>
32struct CallbackContext
33{
34 Callback callback;
35 Context ctx;
36};
37
arovir01b0717b52018-09-05 17:03:25 +010038template<typename HalPolicy>
Matteo Martincighe48bdff2018-09-03 13:50:50 +010039class ArmnnDriverImpl
40{
41public:
arovir01b0717b52018-09-05 17:03:25 +010042 using HalModel = typename HalPolicy::Model;
43 using HalGetSupportedOperations_cb = typename HalPolicy::getSupportedOperations_cb;
Kevin May42477c12020-03-26 13:34:14 +000044 using HalErrorStatus = typename HalPolicy::ErrorStatus;
Matteo Martincighe48bdff2018-09-03 13:50:50 +010045
Matteo Martincighe48bdff2018-09-03 13:50:50 +010046 static Return<void> getSupportedOperations(
47 const armnn::IRuntimePtr& runtime,
48 const DriverOptions& options,
49 const HalModel& model,
50 HalGetSupportedOperations_cb);
arovir01b0717b52018-09-05 17:03:25 +010051
Kevin Mayec1e5b82020-02-26 17:00:39 +000052 static Return<V1_0::ErrorStatus> prepareModel(
Matteo Martincighe48bdff2018-09-03 13:50:50 +010053 const armnn::IRuntimePtr& runtime,
54 const armnn::IGpuAccTunedParametersPtr& clTunedParameters,
55 const DriverOptions& options,
56 const HalModel& model,
Matthew Bentham912b3622019-05-03 15:49:14 +010057 const android::sp<V1_0::IPreparedModelCallback>& cb,
Matteo Martincighe48bdff2018-09-03 13:50:50 +010058 bool float32ToFloat16 = false);
arovir01b0717b52018-09-05 17:03:25 +010059
Matteo Martincighe48bdff2018-09-03 13:50:50 +010060 static Return<DeviceStatus> getStatus();
Mike Kellyb5fdf382019-06-11 16:35:25 +010061
Matteo Martincighe48bdff2018-09-03 13:50:50 +010062};
63
64} // namespace armnn_driver