Matteo Martincigh | e48bdff | 2018-09-03 13:50:50 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | 93e4898 | 2018-09-05 13:05:09 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
Matteo Martincigh | e48bdff | 2018-09-03 13:50:50 +0100 | [diff] [blame] | 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
Matteo Martincigh | e48bdff | 2018-09-03 13:50:50 +0100 | [diff] [blame] | 8 | #include "DriverOptions.hpp" |
| 9 | |
arovir01 | b0717b5 | 2018-09-05 17:03:25 +0100 | [diff] [blame] | 10 | #include <HalInterfaces.h> |
Matteo Martincigh | e48bdff | 2018-09-03 13:50:50 +0100 | [diff] [blame] | 11 | |
Kevin May | ec1e5b8 | 2020-02-26 17:00:39 +0000 | [diff] [blame] | 12 | #ifdef ARMNN_ANDROID_R |
| 13 | using namespace android::nn::hal; |
| 14 | #endif |
| 15 | |
Matthew Bentham | 912b362 | 2019-05-03 15:49:14 +0100 | [diff] [blame] | 16 | namespace V1_0 = ::android::hardware::neuralnetworks::V1_0; |
Mike Kelly | b5fdf38 | 2019-06-11 16:35:25 +0100 | [diff] [blame] | 17 | namespace V1_1 = ::android::hardware::neuralnetworks::V1_1; |
| 18 | |
| 19 | #ifdef ARMNN_ANDROID_NN_V1_2 // Using ::android::hardware::neuralnetworks::V1_2 |
| 20 | namespace V1_2 = ::android::hardware::neuralnetworks::V1_2; |
| 21 | #endif |
Matthew Bentham | 912b362 | 2019-05-03 15:49:14 +0100 | [diff] [blame] | 22 | |
Kevin May | 42477c1 | 2020-03-26 13:34:14 +0000 | [diff] [blame] | 23 | #ifdef ARMNN_ANDROID_NN_V1_3 // Using ::android::hardware::neuralnetworks::V1_3 |
| 24 | namespace V1_2 = ::android::hardware::neuralnetworks::V1_2; |
| 25 | namespace V1_3 = ::android::hardware::neuralnetworks::V1_3; |
| 26 | #endif |
| 27 | |
Matteo Martincigh | e48bdff | 2018-09-03 13:50:50 +0100 | [diff] [blame] | 28 | namespace armnn_driver |
| 29 | { |
| 30 | |
Derek Lamberti | 4de83c5 | 2020-03-17 13:40:18 +0000 | [diff] [blame] | 31 | template <typename Callback, typename Context> |
| 32 | struct CallbackContext |
| 33 | { |
| 34 | Callback callback; |
| 35 | Context ctx; |
| 36 | }; |
| 37 | |
arovir01 | b0717b5 | 2018-09-05 17:03:25 +0100 | [diff] [blame] | 38 | template<typename HalPolicy> |
Matteo Martincigh | e48bdff | 2018-09-03 13:50:50 +0100 | [diff] [blame] | 39 | class ArmnnDriverImpl |
| 40 | { |
| 41 | public: |
arovir01 | b0717b5 | 2018-09-05 17:03:25 +0100 | [diff] [blame] | 42 | using HalModel = typename HalPolicy::Model; |
| 43 | using HalGetSupportedOperations_cb = typename HalPolicy::getSupportedOperations_cb; |
Kevin May | 42477c1 | 2020-03-26 13:34:14 +0000 | [diff] [blame] | 44 | using HalErrorStatus = typename HalPolicy::ErrorStatus; |
Matteo Martincigh | e48bdff | 2018-09-03 13:50:50 +0100 | [diff] [blame] | 45 | |
Matteo Martincigh | e48bdff | 2018-09-03 13:50:50 +0100 | [diff] [blame] | 46 | static Return<void> getSupportedOperations( |
| 47 | const armnn::IRuntimePtr& runtime, |
| 48 | const DriverOptions& options, |
| 49 | const HalModel& model, |
| 50 | HalGetSupportedOperations_cb); |
arovir01 | b0717b5 | 2018-09-05 17:03:25 +0100 | [diff] [blame] | 51 | |
Kevin May | ec1e5b8 | 2020-02-26 17:00:39 +0000 | [diff] [blame] | 52 | static Return<V1_0::ErrorStatus> prepareModel( |
Matteo Martincigh | e48bdff | 2018-09-03 13:50:50 +0100 | [diff] [blame] | 53 | const armnn::IRuntimePtr& runtime, |
| 54 | const armnn::IGpuAccTunedParametersPtr& clTunedParameters, |
| 55 | const DriverOptions& options, |
| 56 | const HalModel& model, |
Matthew Bentham | 912b362 | 2019-05-03 15:49:14 +0100 | [diff] [blame] | 57 | const android::sp<V1_0::IPreparedModelCallback>& cb, |
Matteo Martincigh | e48bdff | 2018-09-03 13:50:50 +0100 | [diff] [blame] | 58 | bool float32ToFloat16 = false); |
arovir01 | b0717b5 | 2018-09-05 17:03:25 +0100 | [diff] [blame] | 59 | |
Matteo Martincigh | e48bdff | 2018-09-03 13:50:50 +0100 | [diff] [blame] | 60 | static Return<DeviceStatus> getStatus(); |
Mike Kelly | b5fdf38 | 2019-06-11 16:35:25 +0100 | [diff] [blame] | 61 | |
Matteo Martincigh | e48bdff | 2018-09-03 13:50:50 +0100 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | } // namespace armnn_driver |