1 //
2 // Copyright (C) 2020 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 // clang-format off
18 #include "native_bridge_support/vdso/interceptable_functions.h"
19
20 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksBurst_create);
21 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksBurst_free);
22 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksCompilation_create);
23 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksCompilation_createForDevices);
24 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksCompilation_finish);
25 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksCompilation_free);
26 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksCompilation_setCaching);
27 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksCompilation_setPreference);
28 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksDevice_getExtensionSupport);
29 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksDevice_getFeatureLevel);
30 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksDevice_getName);
31 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksDevice_getType);
32 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksDevice_getVersion);
33 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksEvent_free);
34 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksEvent_wait);
35 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksExecution_burstCompute);
36 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksExecution_compute);
37 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksExecution_create);
38 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksExecution_free);
39 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksExecution_getDuration);
40 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksExecution_getOutputOperandDimensions);
41 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksExecution_getOutputOperandRank);
42 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksExecution_setInput);
43 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksExecution_setInputFromMemory);
44 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksExecution_setMeasureTiming);
45 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksExecution_setOutput);
46 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksExecution_setOutputFromMemory);
47 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksExecution_startCompute);
48 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksMemoryDesc_addInputRole);
49 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksMemoryDesc_addOutputRole);
50 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksMemoryDesc_create);
51 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksMemoryDesc_finish);
52 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksMemoryDesc_free);
53 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksMemoryDesc_setDimensions);
54 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksMemory_copy);
55 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksMemory_createFromAHardwareBuffer);
56 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksMemory_createFromDesc);
57 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksMemory_createFromFd);
58 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksMemory_free);
59 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksModel_addOperand);
60 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksModel_addOperation);
61 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksModel_create);
62 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksModel_finish);
63 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksModel_free);
64 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksModel_getExtensionOperandType);
65 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksModel_getExtensionOperationType);
66 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksModel_getSupportedOperationsForDevices);
67 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksModel_identifyInputsAndOutputs);
68 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksModel_relaxComputationFloat32toFloat16);
69 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksModel_setOperandExtensionData);
70 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksModel_setOperandSymmPerChannelQuantParams);
71 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksModel_setOperandValue);
72 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworksModel_setOperandValueFromMemory);
73 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworks_getDevice);
74 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ANeuralNetworks_getDeviceCount);
75
init_stub_library()76 static void __attribute__((constructor(0))) init_stub_library() {
77 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksBurst_create);
78 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksBurst_free);
79 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksCompilation_create);
80 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksCompilation_createForDevices);
81 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksCompilation_finish);
82 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksCompilation_free);
83 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksCompilation_setCaching);
84 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksCompilation_setPreference);
85 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksDevice_getExtensionSupport);
86 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksDevice_getFeatureLevel);
87 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksDevice_getName);
88 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksDevice_getType);
89 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksDevice_getVersion);
90 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksEvent_free);
91 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksEvent_wait);
92 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksExecution_burstCompute);
93 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksExecution_compute);
94 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksExecution_create);
95 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksExecution_free);
96 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksExecution_getDuration);
97 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksExecution_getOutputOperandDimensions);
98 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksExecution_getOutputOperandRank);
99 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksExecution_setInput);
100 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksExecution_setInputFromMemory);
101 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksExecution_setMeasureTiming);
102 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksExecution_setOutput);
103 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksExecution_setOutputFromMemory);
104 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksExecution_startCompute);
105 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksMemoryDesc_addInputRole);
106 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksMemoryDesc_addOutputRole);
107 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksMemoryDesc_create);
108 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksMemoryDesc_finish);
109 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksMemoryDesc_free);
110 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksMemoryDesc_setDimensions);
111 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksMemory_copy);
112 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksMemory_createFromAHardwareBuffer);
113 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksMemory_createFromDesc);
114 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksMemory_createFromFd);
115 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksMemory_free);
116 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksModel_addOperand);
117 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksModel_addOperation);
118 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksModel_create);
119 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksModel_finish);
120 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksModel_free);
121 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksModel_getExtensionOperandType);
122 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksModel_getExtensionOperationType);
123 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksModel_getSupportedOperationsForDevices);
124 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksModel_identifyInputsAndOutputs);
125 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksModel_relaxComputationFloat32toFloat16);
126 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksModel_setOperandExtensionData);
127 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksModel_setOperandSymmPerChannelQuantParams);
128 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksModel_setOperandValue);
129 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworksModel_setOperandValueFromMemory);
130 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworks_getDevice);
131 INIT_INTERCEPTABLE_STUB_FUNCTION("libneuralnetworks.so", ANeuralNetworks_getDeviceCount);
132 }
133 // clang-format on
134