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