blob: a6ac5f3cf3c6e294bd4fcc6360643e72cdd59529 [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"
Kevin DuBois30c34ae2020-08-26 13:53:41 -07009#include "NamespaceAdaptor.hpp"
Matteo Martincighe48bdff2018-09-03 13:50:50 +010010
arovir01b0717b52018-09-05 17:03:25 +010011#include <HalInterfaces.h>
Matteo Martincighe48bdff2018-09-03 13:50:50 +010012
Kevin Mayec1e5b82020-02-26 17:00:39 +000013#ifdef ARMNN_ANDROID_R
Kevin DuBoisc0945c72020-11-20 16:57:09 -080014using namespace android::nn;
Kevin Mayec1e5b82020-02-26 17:00:39 +000015#endif
16
Matthew Bentham912b3622019-05-03 15:49:14 +010017namespace V1_0 = ::android::hardware::neuralnetworks::V1_0;
Mike Kellyb5fdf382019-06-11 16:35:25 +010018namespace V1_1 = ::android::hardware::neuralnetworks::V1_1;
19
20#ifdef ARMNN_ANDROID_NN_V1_2 // Using ::android::hardware::neuralnetworks::V1_2
21namespace V1_2 = ::android::hardware::neuralnetworks::V1_2;
22#endif
Matthew Bentham912b3622019-05-03 15:49:14 +010023
Kevin May42477c12020-03-26 13:34:14 +000024#ifdef ARMNN_ANDROID_NN_V1_3 // Using ::android::hardware::neuralnetworks::V1_3
25namespace V1_2 = ::android::hardware::neuralnetworks::V1_2;
26namespace V1_3 = ::android::hardware::neuralnetworks::V1_3;
27#endif
28
Matteo Martincighe48bdff2018-09-03 13:50:50 +010029namespace armnn_driver
30{
31
Derek Lamberti4de83c52020-03-17 13:40:18 +000032template <typename Callback, typename Context>
33struct CallbackContext
34{
35 Callback callback;
36 Context ctx;
37};
38
arovir01b0717b52018-09-05 17:03:25 +010039template<typename HalPolicy>
Matteo Martincighe48bdff2018-09-03 13:50:50 +010040class ArmnnDriverImpl
41{
42public:
arovir01b0717b52018-09-05 17:03:25 +010043 using HalModel = typename HalPolicy::Model;
44 using HalGetSupportedOperations_cb = typename HalPolicy::getSupportedOperations_cb;
Kevin May42477c12020-03-26 13:34:14 +000045 using HalErrorStatus = typename HalPolicy::ErrorStatus;
Matteo Martincighe48bdff2018-09-03 13:50:50 +010046
Matteo Martincighe48bdff2018-09-03 13:50:50 +010047 static Return<void> getSupportedOperations(
48 const armnn::IRuntimePtr& runtime,
49 const DriverOptions& options,
50 const HalModel& model,
51 HalGetSupportedOperations_cb);
arovir01b0717b52018-09-05 17:03:25 +010052
Kevin DuBois30c34ae2020-08-26 13:53:41 -070053 static Return<V1_0::ErrorStatus> prepareModel(
Matteo Martincighe48bdff2018-09-03 13:50:50 +010054 const armnn::IRuntimePtr& runtime,
55 const armnn::IGpuAccTunedParametersPtr& clTunedParameters,
56 const DriverOptions& options,
57 const HalModel& model,
Matthew Bentham912b3622019-05-03 15:49:14 +010058 const android::sp<V1_0::IPreparedModelCallback>& cb,
Matteo Martincighe48bdff2018-09-03 13:50:50 +010059 bool float32ToFloat16 = false);
arovir01b0717b52018-09-05 17:03:25 +010060
Kevin DuBois30c34ae2020-08-26 13:53:41 -070061 static Return<V1_0::DeviceStatus> getStatus();
Mike Kellyb5fdf382019-06-11 16:35:25 +010062
Matteo Martincighe48bdff2018-09-03 13:50:50 +010063};
64
65} // namespace armnn_driver