1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_FRAMEWORKS_ML_NN_COMMON_HAL_INTERFACES_H
18 #define ANDROID_FRAMEWORKS_ML_NN_COMMON_HAL_INTERFACES_H
19 
20 #include <android/hardware/neuralnetworks/1.0/IDevice.h>
21 #include <android/hardware/neuralnetworks/1.0/IExecutionCallback.h>
22 #include <android/hardware/neuralnetworks/1.0/IPreparedModel.h>
23 #include <android/hardware/neuralnetworks/1.0/IPreparedModelCallback.h>
24 #include <android/hardware/neuralnetworks/1.0/types.h>
25 #include <android/hardware/neuralnetworks/1.1/IDevice.h>
26 #include <android/hardware/neuralnetworks/1.1/types.h>
27 #include <android/hardware/neuralnetworks/1.2/IDevice.h>
28 #include <android/hardware/neuralnetworks/1.2/IExecutionCallback.h>
29 #include <android/hardware/neuralnetworks/1.2/IPreparedModel.h>
30 #include <android/hardware/neuralnetworks/1.2/IPreparedModelCallback.h>
31 #include <android/hardware/neuralnetworks/1.2/types.h>
32 #include <android/hardware/neuralnetworks/1.3/IDevice.h>
33 #include <android/hardware/neuralnetworks/1.3/IExecutionCallback.h>
34 #include <android/hardware/neuralnetworks/1.3/IFencedExecutionCallback.h>
35 #include <android/hardware/neuralnetworks/1.3/IPreparedModel.h>
36 #include <android/hardware/neuralnetworks/1.3/IPreparedModelCallback.h>
37 #include <android/hardware/neuralnetworks/1.3/types.h>
38 #include <android/hidl/memory/1.0/IMemory.h>
39 #include <hidlmemory/mapping.h>
40 
41 #include <functional>
42 
43 namespace android::nn::hal {
44 
45 using android::sp;
46 
47 using hardware::hidl_death_recipient;
48 using hardware::hidl_enum_range;
49 using hardware::hidl_handle;
50 using hardware::hidl_memory;
51 using hardware::hidl_string;
52 using hardware::hidl_vec;
53 using hardware::Return;
54 using hardware::Void;
55 
56 using hidl::memory::V1_0::IMemory;
57 
58 namespace V1_0 = hardware::neuralnetworks::V1_0;
59 namespace V1_1 = hardware::neuralnetworks::V1_1;
60 namespace V1_2 = hardware::neuralnetworks::V1_2;
61 namespace V1_3 = hardware::neuralnetworks::V1_3;
62 
63 using V1_0::DataLocation;
64 using V1_0::DeviceStatus;
65 using V1_0::FusedActivationFunc;
66 using V1_0::PerformanceInfo;
67 using V1_0::RequestArgument;
68 using V1_1::ExecutionPreference;
69 using V1_2::Constant;
70 using V1_2::DeviceType;
71 using V1_2::Extension;
72 using V1_2::MeasureTiming;
73 using V1_2::OutputShape;
74 using V1_2::SymmPerChannelQuantParams;
75 using V1_2::Timing;
76 using V1_3::BufferDesc;
77 using V1_3::BufferRole;
78 using V1_3::Capabilities;
79 using V1_3::ErrorStatus;
80 using V1_3::IBuffer;
81 using V1_3::IDevice;
82 using V1_3::IExecutionCallback;
83 using V1_3::IFencedExecutionCallback;
84 using V1_3::IPreparedModel;
85 using V1_3::IPreparedModelCallback;
86 using V1_3::LoopTimeoutDurationNs;
87 using V1_3::Model;
88 using V1_3::Operand;
89 using V1_3::OperandLifeTime;
90 using V1_3::OperandType;
91 using V1_3::OperandTypeRange;
92 using V1_3::Operation;
93 using V1_3::OperationType;
94 using V1_3::OperationTypeRange;
95 using V1_3::OptionalTimeoutDuration;
96 using V1_3::OptionalTimePoint;
97 using V1_3::Priority;
98 using V1_3::Request;
99 using V1_3::Subgraph;
100 using ExtensionNameAndPrefix = V1_2::Model::ExtensionNameAndPrefix;
101 using ExtensionTypeEncoding = V1_2::Model::ExtensionTypeEncoding;
102 using OperandExtraParams = V1_2::Operand::ExtraParams;
103 
104 using CacheToken =
105         hardware::hidl_array<uint8_t, static_cast<uint32_t>(Constant::BYTE_SIZE_OF_CACHE_TOKEN)>;
106 using DeviceFactory = std::function<sp<V1_0::IDevice>(bool blocking)>;
107 using ModelFactory = std::function<Model()>;
108 
109 inline constexpr Priority kDefaultPriority = Priority::MEDIUM;
110 
111 }  // namespace android::nn::hal
112 
113 #endif  // ANDROID_FRAMEWORKS_ML_NN_COMMON_HAL_INTERFACES_H
114