• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #ifndef TENSORFLOW_LITE_NNAPI_SL_PUBLIC_NEURAL_NETWORKS_SUPPORT_LIBRARY_IMPL_H_
17 #define TENSORFLOW_LITE_NNAPI_SL_PUBLIC_NEURAL_NETWORKS_SUPPORT_LIBRARY_IMPL_H_
18 
19 /******************************************************************
20  *
21  * IMPORTANT NOTICE:
22  *
23  *   This file is part of Android's set of stable system headers
24  *   exposed by the Android NDK (Native Development Kit).
25  *
26  *   Third-party source AND binary code relies on the definitions
27  *   here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
28  *
29  *   - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
30  *   - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
31  *   - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
32  *   - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
33  */
34 
35 #include <stdint.h>
36 #include <stdio.h>
37 #include <stdlib.h>
38 
39 // Changed when importing from AOSP
40 #include "tensorflow/lite/nnapi/NeuralNetworksTypes.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /**
47  * Base version of NnApiSLDriverImpl with version information.
48  *
49  * NnApiSLDriverImpl is non-opaque, versioning struct to make it possible to
50  * pass its instance straight from the SL Driver to the shim registration. The
51  * glue code that loads the SL and calls the shim is non-updatable. An opaque
52  * struct would require the glue code to be updated if we would like to use
53  * newer NNAPI Feature Level.
54  *
55  * There's expectation that for M>N, NnApiSLDriverImplFL(M) is
56  * a strict superset of NnApiSLDriverImplFL(N), and NnApiSLDriverImplFL(M)* can
57  * be reinterpret_cast to NnApiSLDriverImplFL(N)* safely.
58  */
59 struct NnApiSLDriverImpl {
60   /**
61    * Version of the NnApiSLDriverImpl struct. Uses {@link FeatureLevelCode}
62    * values for versioning.
63    */
64   int64_t implFeatureLevel;
65 };
66 
67 /**
68  * NnApiSLDriverImpl for an Updatable SL Driver implementing {@link
69  * ANEURALNETWORKS_FEATURE_LEVEL_5}.
70  *
71  * This struct must set its implFeatureLevel to {@link
72  * ANEURALNETWORKS_FEATURE_LEVEL_5}.
73  */
74 struct NnApiSLDriverImplFL5 {
75   /**
76    * Base type with version information. Allows to cast a pointer of this type
77    * to NnApiSLDriverImpl* with valid version information.
78    * For this type, its .version fields should be always set to {@link
79    * ANEURALNETWORKS_FEATURE_LEVEL_5}.
80    */
81   NnApiSLDriverImpl base;
82 
83   /**
84    * SL Driver implementation of {@link ANeuralNetworksBurst_create}.
85    * Behavior, arguments, and outputs match NNAPI Runtime function
86    * {@link ANeuralNetworksBurst_create},
87    * at the feature level of this NnApiSLDriver struct.
88    */
89   int (*ANeuralNetworksBurst_create)(ANeuralNetworksCompilation* compilation,
90                                      ANeuralNetworksBurst** burst);
91 
92   /**
93    * SL Driver implementation of {@link ANeuralNetworksBurst_free}.
94    * Behavior, arguments, and outputs match NNAPI Runtime function
95    * {@link ANeuralNetworksBurst_free},
96    * at the feature level of this NnApiSLDriver struct.
97    */
98   void (*ANeuralNetworksBurst_free)(ANeuralNetworksBurst* burst);
99 
100   /**
101    * SL Driver implementation of {@link
102    * ANeuralNetworksCompilation_createForDevices}. Behavior, arguments, and
103    * outputs match NNAPI Runtime function
104    * {@link ANeuralNetworksCompilation_createForDevices},
105    * at the feature level of this NnApiSLDriver struct.
106    */
107   int (*ANeuralNetworksCompilation_createForDevices)(
108       ANeuralNetworksModel* model, const ANeuralNetworksDevice* const* devices,
109       uint32_t numDevices, ANeuralNetworksCompilation** compilation);
110 
111   /**
112    * SL Driver implementation of {@link ANeuralNetworksCompilation_finish}.
113    * Behavior, arguments, and outputs match NNAPI Runtime function
114    * {@link ANeuralNetworksCompilation_finish},
115    * at the feature level of this NnApiSLDriver struct.
116    */
117   int (*ANeuralNetworksCompilation_finish)(
118       ANeuralNetworksCompilation* compilation);
119 
120   /**
121    * SL Driver implementation of {@link ANeuralNetworksCompilation_free}.
122    * Behavior, arguments, and outputs match NNAPI Runtime function
123    * {@link ANeuralNetworksCompilation_free},
124    * at the feature level of this NnApiSLDriver struct.
125    */
126   void (*ANeuralNetworksCompilation_free)(
127       ANeuralNetworksCompilation* compilation);
128 
129   /**
130    * SL Driver implementation of {@link
131    * ANeuralNetworksCompilation_getPreferredMemoryAlignmentForInput}. Behavior,
132    * arguments, and outputs match NNAPI Runtime function
133    * {@link ANeuralNetworksCompilation_getPreferredMemoryAlignmentForInput},
134    * at the feature level of this NnApiSLDriver struct.
135    */
136   int (*ANeuralNetworksCompilation_getPreferredMemoryAlignmentForInput)(
137       const ANeuralNetworksCompilation* compilation, uint32_t index,
138       uint32_t* alignment);
139 
140   /**
141    * SL Driver implementation of {@link
142    * ANeuralNetworksCompilation_getPreferredMemoryAlignmentForOutput}. Behavior,
143    * arguments, and outputs match NNAPI Runtime function
144    * {@link ANeuralNetworksCompilation_getPreferredMemoryAlignmentForOutput},
145    * at the feature level of this NnApiSLDriver struct.
146    */
147   int (*ANeuralNetworksCompilation_getPreferredMemoryAlignmentForOutput)(
148       const ANeuralNetworksCompilation* compilation, uint32_t index,
149       uint32_t* alignment);
150 
151   /**
152    * SL Driver implementation of {@link
153    * ANeuralNetworksCompilation_getPreferredMemoryPaddingForInput}. Behavior,
154    * arguments, and outputs match NNAPI Runtime function
155    * {@link ANeuralNetworksCompilation_getPreferredMemoryPaddingForInput},
156    * at the feature level of this NnApiSLDriver struct.
157    */
158   int (*ANeuralNetworksCompilation_getPreferredMemoryPaddingForInput)(
159       const ANeuralNetworksCompilation* compilation, uint32_t index,
160       uint32_t* padding);
161 
162   /**
163    * SL Driver implementation of {@link
164    * ANeuralNetworksCompilation_getPreferredMemoryPaddingForOutput}. Behavior,
165    * arguments, and outputs match NNAPI Runtime function
166    * {@link ANeuralNetworksCompilation_getPreferredMemoryPaddingForOutput},
167    * at the feature level of this NnApiSLDriver struct.
168    */
169   int (*ANeuralNetworksCompilation_getPreferredMemoryPaddingForOutput)(
170       const ANeuralNetworksCompilation* compilation, uint32_t index,
171       uint32_t* padding);
172 
173   /**
174    * SL Driver implementation of {@link ANeuralNetworksCompilation_setCaching}.
175    * Behavior, arguments, and outputs match NNAPI Runtime function
176    * {@link ANeuralNetworksCompilation_setCaching},
177    * at the feature level of this NnApiSLDriver struct.
178    */
179   int (*ANeuralNetworksCompilation_setCaching)(
180       ANeuralNetworksCompilation* compilation, const char* cacheDir,
181       const uint8_t* token);
182 
183   /**
184    * SL Driver implementation of {@link
185    * ANeuralNetworksCompilation_setPreference}. Behavior, arguments, and outputs
186    * match NNAPI Runtime function
187    * {@link ANeuralNetworksCompilation_setPreference},
188    * at the feature level of this NnApiSLDriver struct.
189    */
190   int (*ANeuralNetworksCompilation_setPreference)(
191       ANeuralNetworksCompilation* compilation, int32_t preference);
192 
193   /**
194    * SL Driver implementation of {@link ANeuralNetworksCompilation_setPriority}.
195    * Behavior, arguments, and outputs match NNAPI Runtime function
196    * {@link ANeuralNetworksCompilation_setPriority},
197    * at the feature level of this NnApiSLDriver struct.
198    */
199   int (*ANeuralNetworksCompilation_setPriority)(
200       ANeuralNetworksCompilation* compilation, int priority);
201 
202   /**
203    * SL Driver implementation of {@link ANeuralNetworksCompilation_setTimeout}.
204    * Behavior, arguments, and outputs match NNAPI Runtime function
205    * {@link ANeuralNetworksCompilation_setTimeout},
206    * at the feature level of this NnApiSLDriver struct.
207    */
208   int (*ANeuralNetworksCompilation_setTimeout)(
209       ANeuralNetworksCompilation* compilation, uint64_t duration);
210 
211   /**
212    * SL Driver implementation of {@link
213    * ANeuralNetworksDevice_getExtensionSupport}. Behavior, arguments, and
214    * outputs match NNAPI Runtime function
215    * {@link ANeuralNetworksDevice_getExtensionSupport},
216    * at the feature level of this NnApiSLDriver struct.
217    */
218   int (*ANeuralNetworksDevice_getExtensionSupport)(
219       const ANeuralNetworksDevice* device, const char* extensionName,
220       bool* isExtensionSupported);
221 
222   /**
223    * SL Driver implementation of {@link ANeuralNetworksDevice_getFeatureLevel}.
224    * Behavior, arguments, and outputs match NNAPI Runtime function
225    * {@link ANeuralNetworksDevice_getFeatureLevel},
226    * at the feature level of this NnApiSLDriver struct.
227    */
228   int (*ANeuralNetworksDevice_getFeatureLevel)(
229       const ANeuralNetworksDevice* device, int64_t* featureLevel);
230 
231   /**
232    * SL Driver implementation of {@link ANeuralNetworksDevice_getName}.
233    * Behavior, arguments, and outputs match NNAPI Runtime function
234    * {@link ANeuralNetworksDevice_getName},
235    * at the feature level of this NnApiSLDriver struct.
236    */
237   int (*ANeuralNetworksDevice_getName)(const ANeuralNetworksDevice* device,
238                                        const char** name);
239 
240   /**
241    * SL Driver implementation of {@link ANeuralNetworksDevice_getType}.
242    * Behavior, arguments, and outputs match NNAPI Runtime function
243    * {@link ANeuralNetworksDevice_getType},
244    * at the feature level of this NnApiSLDriver struct.
245    */
246   int (*ANeuralNetworksDevice_getType)(const ANeuralNetworksDevice* device,
247                                        int32_t* type);
248 
249   /**
250    * SL Driver implementation of {@link ANeuralNetworksDevice_getVersion}.
251    * Behavior, arguments, and outputs match NNAPI Runtime function
252    * {@link ANeuralNetworksDevice_getVersion},
253    * at the feature level of this NnApiSLDriver struct.
254    */
255   int (*ANeuralNetworksDevice_getVersion)(const ANeuralNetworksDevice* device,
256                                           const char** version);
257 
258   /**
259    * SL Driver implementation of {@link ANeuralNetworksDevice_wait}.
260    * Behavior, arguments, and outputs match NNAPI Runtime function
261    * {@link ANeuralNetworksDevice_wait},
262    * at the feature level of this NnApiSLDriver struct.
263    */
264   int (*ANeuralNetworksDevice_wait)(const ANeuralNetworksDevice* device);
265 
266   /**
267    * SL Driver implementation of {@link
268    * ANeuralNetworksEvent_createFromSyncFenceFd}. Behavior, arguments, and
269    * outputs match NNAPI Runtime function
270    * {@link ANeuralNetworksEvent_createFromSyncFenceFd},
271    * at the feature level of this NnApiSLDriver struct.
272    */
273   int (*ANeuralNetworksEvent_createFromSyncFenceFd)(
274       int sync_fence_fd, ANeuralNetworksEvent** event);
275 
276   /**
277    * SL Driver implementation of {@link ANeuralNetworksEvent_free}.
278    * Behavior, arguments, and outputs match NNAPI Runtime function
279    * {@link ANeuralNetworksEvent_free},
280    * at the feature level of this NnApiSLDriver struct.
281    */
282   void (*ANeuralNetworksEvent_free)(ANeuralNetworksEvent* event);
283 
284   /**
285    * SL Driver implementation of {@link ANeuralNetworksEvent_getSyncFenceFd}.
286    * Behavior, arguments, and outputs match NNAPI Runtime function
287    * {@link ANeuralNetworksEvent_getSyncFenceFd},
288    * at the feature level of this NnApiSLDriver struct.
289    */
290   int (*ANeuralNetworksEvent_getSyncFenceFd)(const ANeuralNetworksEvent* event,
291                                              int* sync_fence_fd);
292 
293   /**
294    * SL Driver implementation of {@link ANeuralNetworksEvent_wait}.
295    * Behavior, arguments, and outputs match NNAPI Runtime function
296    * {@link ANeuralNetworksEvent_wait},
297    * at the feature level of this NnApiSLDriver struct.
298    */
299   int (*ANeuralNetworksEvent_wait)(ANeuralNetworksEvent* event);
300 
301   /**
302    * SL Driver implementation of {@link ANeuralNetworksExecution_burstCompute}.
303    * Behavior, arguments, and outputs match NNAPI Runtime function
304    * {@link ANeuralNetworksExecution_burstCompute},
305    * at the feature level of this NnApiSLDriver struct.
306    */
307   int (*ANeuralNetworksExecution_burstCompute)(
308       ANeuralNetworksExecution* execution, ANeuralNetworksBurst* burst);
309 
310   /**
311    * SL Driver implementation of {@link ANeuralNetworksExecution_compute}.
312    * Behavior, arguments, and outputs match NNAPI Runtime function
313    * {@link ANeuralNetworksExecution_compute},
314    * at the feature level of this NnApiSLDriver struct.
315    */
316   int (*ANeuralNetworksExecution_compute)(ANeuralNetworksExecution* execution);
317 
318   /**
319    * SL Driver implementation of {@link ANeuralNetworksExecution_create}.
320    * Behavior, arguments, and outputs match NNAPI Runtime function
321    * {@link ANeuralNetworksExecution_create},
322    * at the feature level of this NnApiSLDriver struct.
323    */
324   int (*ANeuralNetworksExecution_create)(
325       ANeuralNetworksCompilation* compilation,
326       ANeuralNetworksExecution** execution);
327 
328   /**
329    * SL Driver implementation of {@link
330    * ANeuralNetworksExecution_enableInputAndOutputPadding}. Behavior, arguments,
331    * and outputs match NNAPI Runtime function
332    * {@link ANeuralNetworksExecution_enableInputAndOutputPadding},
333    * at the feature level of this NnApiSLDriver struct.
334    */
335   int (*ANeuralNetworksExecution_enableInputAndOutputPadding)(
336       ANeuralNetworksExecution* execution, bool enable);
337 
338   /**
339    * SL Driver implementation of {@link ANeuralNetworksExecution_free}.
340    * Behavior, arguments, and outputs match NNAPI Runtime function
341    * {@link ANeuralNetworksExecution_free},
342    * at the feature level of this NnApiSLDriver struct.
343    */
344   void (*ANeuralNetworksExecution_free)(ANeuralNetworksExecution* execution);
345 
346   /**
347    * SL Driver implementation of {@link ANeuralNetworksExecution_getDuration}.
348    * Behavior, arguments, and outputs match NNAPI Runtime function
349    * {@link ANeuralNetworksExecution_getDuration},
350    * at the feature level of this NnApiSLDriver struct.
351    */
352   int (*ANeuralNetworksExecution_getDuration)(
353       const ANeuralNetworksExecution* execution, int32_t durationCode,
354       uint64_t* duration);
355 
356   /**
357    * SL Driver implementation of {@link
358    * ANeuralNetworksExecution_getOutputOperandDimensions}. Behavior, arguments,
359    * and outputs match NNAPI Runtime function
360    * {@link ANeuralNetworksExecution_getOutputOperandDimensions},
361    * at the feature level of this NnApiSLDriver struct.
362    */
363   int (*ANeuralNetworksExecution_getOutputOperandDimensions)(
364       ANeuralNetworksExecution* execution, int32_t index, uint32_t* dimensions);
365 
366   /**
367    * SL Driver implementation of {@link
368    * ANeuralNetworksExecution_getOutputOperandRank}. Behavior, arguments, and
369    * outputs match NNAPI Runtime function
370    * {@link ANeuralNetworksExecution_getOutputOperandRank},
371    * at the feature level of this NnApiSLDriver struct.
372    */
373   int (*ANeuralNetworksExecution_getOutputOperandRank)(
374       ANeuralNetworksExecution* execution, int32_t index, uint32_t* rank);
375 
376   /**
377    * SL Driver implementation of {@link ANeuralNetworksExecution_setInput}.
378    * Behavior, arguments, and outputs match NNAPI Runtime function
379    * {@link ANeuralNetworksExecution_setInput},
380    * at the feature level of this NnApiSLDriver struct.
381    */
382   int (*ANeuralNetworksExecution_setInput)(
383       ANeuralNetworksExecution* execution, int32_t index,
384       const ANeuralNetworksOperandType* type, const void* buffer,
385       size_t length);
386 
387   /**
388    * SL Driver implementation of {@link
389    * ANeuralNetworksExecution_setInputFromMemory}. Behavior, arguments, and
390    * outputs match NNAPI Runtime function
391    * {@link ANeuralNetworksExecution_setInputFromMemory},
392    * at the feature level of this NnApiSLDriver struct.
393    */
394   int (*ANeuralNetworksExecution_setInputFromMemory)(
395       ANeuralNetworksExecution* execution, int32_t index,
396       const ANeuralNetworksOperandType* type,
397       const ANeuralNetworksMemory* memory, size_t offset, size_t length);
398 
399   /**
400    * SL Driver implementation of {@link
401    * ANeuralNetworksExecution_setLoopTimeout}. Behavior, arguments, and outputs
402    * match NNAPI Runtime function
403    * {@link ANeuralNetworksExecution_setLoopTimeout},
404    * at the feature level of this NnApiSLDriver struct.
405    */
406   int (*ANeuralNetworksExecution_setLoopTimeout)(
407       ANeuralNetworksExecution* execution, uint64_t duration);
408 
409   /**
410    * SL Driver implementation of {@link
411    * ANeuralNetworksExecution_setMeasureTiming}. Behavior, arguments, and
412    * outputs match NNAPI Runtime function
413    * {@link ANeuralNetworksExecution_setMeasureTiming},
414    * at the feature level of this NnApiSLDriver struct.
415    */
416   int (*ANeuralNetworksExecution_setMeasureTiming)(
417       ANeuralNetworksExecution* execution, bool measure);
418 
419   /**
420    * SL Driver implementation of {@link ANeuralNetworksExecution_setOutput}.
421    * Behavior, arguments, and outputs match NNAPI Runtime function
422    * {@link ANeuralNetworksExecution_setOutput},
423    * at the feature level of this NnApiSLDriver struct.
424    */
425   int (*ANeuralNetworksExecution_setOutput)(
426       ANeuralNetworksExecution* execution, int32_t index,
427       const ANeuralNetworksOperandType* type, void* buffer, size_t length);
428 
429   /**
430    * SL Driver implementation of {@link
431    * ANeuralNetworksExecution_setOutputFromMemory}. Behavior, arguments, and
432    * outputs match NNAPI Runtime function
433    * {@link ANeuralNetworksExecution_setOutputFromMemory},
434    * at the feature level of this NnApiSLDriver struct.
435    */
436   int (*ANeuralNetworksExecution_setOutputFromMemory)(
437       ANeuralNetworksExecution* execution, int32_t index,
438       const ANeuralNetworksOperandType* type,
439       const ANeuralNetworksMemory* memory, size_t offset, size_t length);
440 
441   /**
442    * SL Driver implementation of {@link ANeuralNetworksExecution_setReusable}.
443    * Behavior, arguments, and outputs match NNAPI Runtime function
444    * {@link ANeuralNetworksExecution_setReusable},
445    * at the feature level of this NnApiSLDriver struct.
446    */
447   int (*ANeuralNetworksExecution_setReusable)(
448       ANeuralNetworksExecution* execution, bool reusable);
449 
450   /**
451    * SL Driver implementation of {@link ANeuralNetworksExecution_setTimeout}.
452    * Behavior, arguments, and outputs match NNAPI Runtime function
453    * {@link ANeuralNetworksExecution_setTimeout},
454    * at the feature level of this NnApiSLDriver struct.
455    */
456   int (*ANeuralNetworksExecution_setTimeout)(
457       ANeuralNetworksExecution* execution, uint64_t duration);
458 
459   /**
460    * SL Driver implementation of {@link
461    * ANeuralNetworksExecution_startComputeWithDependencies}. Behavior,
462    * arguments, and outputs match NNAPI Runtime function
463    * {@link ANeuralNetworksExecution_startComputeWithDependencies},
464    * at the feature level of this NnApiSLDriver struct.
465    */
466   int (*ANeuralNetworksExecution_startComputeWithDependencies)(
467       ANeuralNetworksExecution* execution,
468       const ANeuralNetworksEvent* const* dependencies,
469       uint32_t num_dependencies, uint64_t duration,
470       ANeuralNetworksEvent** event);
471 
472   /**
473    * SL Driver implementation of {@link ANeuralNetworksMemoryDesc_addInputRole}.
474    * Behavior, arguments, and outputs match NNAPI Runtime function
475    * {@link ANeuralNetworksMemoryDesc_addInputRole},
476    * at the feature level of this NnApiSLDriver struct.
477    */
478   int (*ANeuralNetworksMemoryDesc_addInputRole)(
479       ANeuralNetworksMemoryDesc* desc,
480       const ANeuralNetworksCompilation* compilation, uint32_t index,
481       float frequency);
482 
483   /**
484    * SL Driver implementation of {@link
485    * ANeuralNetworksMemoryDesc_addOutputRole}. Behavior, arguments, and outputs
486    * match NNAPI Runtime function
487    * {@link ANeuralNetworksMemoryDesc_addOutputRole},
488    * at the feature level of this NnApiSLDriver struct.
489    */
490   int (*ANeuralNetworksMemoryDesc_addOutputRole)(
491       ANeuralNetworksMemoryDesc* desc,
492       const ANeuralNetworksCompilation* compilation, uint32_t index,
493       float frequency);
494 
495   /**
496    * SL Driver implementation of {@link ANeuralNetworksMemoryDesc_create}.
497    * Behavior, arguments, and outputs match NNAPI Runtime function
498    * {@link ANeuralNetworksMemoryDesc_create},
499    * at the feature level of this NnApiSLDriver struct.
500    */
501   int (*ANeuralNetworksMemoryDesc_create)(ANeuralNetworksMemoryDesc** desc);
502 
503   /**
504    * SL Driver implementation of {@link ANeuralNetworksMemoryDesc_finish}.
505    * Behavior, arguments, and outputs match NNAPI Runtime function
506    * {@link ANeuralNetworksMemoryDesc_finish},
507    * at the feature level of this NnApiSLDriver struct.
508    */
509   int (*ANeuralNetworksMemoryDesc_finish)(ANeuralNetworksMemoryDesc* desc);
510 
511   /**
512    * SL Driver implementation of {@link ANeuralNetworksMemoryDesc_free}.
513    * Behavior, arguments, and outputs match NNAPI Runtime function
514    * {@link ANeuralNetworksMemoryDesc_free},
515    * at the feature level of this NnApiSLDriver struct.
516    */
517   void (*ANeuralNetworksMemoryDesc_free)(ANeuralNetworksMemoryDesc* desc);
518 
519   /**
520    * SL Driver implementation of {@link
521    * ANeuralNetworksMemoryDesc_setDimensions}. Behavior, arguments, and outputs
522    * match NNAPI Runtime function
523    * {@link ANeuralNetworksMemoryDesc_setDimensions},
524    * at the feature level of this NnApiSLDriver struct.
525    */
526   int (*ANeuralNetworksMemoryDesc_setDimensions)(
527       ANeuralNetworksMemoryDesc* desc, uint32_t rank,
528       const uint32_t* dimensions);
529 
530   /**
531    * SL Driver implementation of {@link ANeuralNetworksMemory_copy}.
532    * Behavior, arguments, and outputs match NNAPI Runtime function
533    * {@link ANeuralNetworksMemory_copy},
534    * at the feature level of this NnApiSLDriver struct.
535    */
536   int (*ANeuralNetworksMemory_copy)(const ANeuralNetworksMemory* src,
537                                     const ANeuralNetworksMemory* dst);
538 
539   /**
540    * SL Driver implementation of {@link
541    * ANeuralNetworksMemory_createFromAHardwareBuffer}. Behavior, arguments, and
542    * outputs match NNAPI Runtime function
543    * {@link ANeuralNetworksMemory_createFromAHardwareBuffer},
544    * at the feature level of this NnApiSLDriver struct.
545    */
546   int (*ANeuralNetworksMemory_createFromAHardwareBuffer)(
547       const AHardwareBuffer* ahwb, ANeuralNetworksMemory** memory);
548 
549   /**
550    * SL Driver implementation of {@link ANeuralNetworksMemory_createFromDesc}.
551    * Behavior, arguments, and outputs match NNAPI Runtime function
552    * {@link ANeuralNetworksMemory_createFromDesc},
553    * at the feature level of this NnApiSLDriver struct.
554    */
555   int (*ANeuralNetworksMemory_createFromDesc)(
556       const ANeuralNetworksMemoryDesc* desc, ANeuralNetworksMemory** memory);
557 
558   /**
559    * SL Driver implementation of {@link ANeuralNetworksMemory_createFromFd}.
560    * Behavior, arguments, and outputs match NNAPI Runtime function
561    * {@link ANeuralNetworksMemory_createFromFd},
562    * at the feature level of this NnApiSLDriver struct.
563    */
564   int (*ANeuralNetworksMemory_createFromFd)(size_t size, int protect, int fd,
565                                             size_t offset,
566                                             ANeuralNetworksMemory** memory);
567 
568   /**
569    * SL Driver implementation of {@link ANeuralNetworksMemory_free}.
570    * Behavior, arguments, and outputs match NNAPI Runtime function
571    * {@link ANeuralNetworksMemory_free},
572    * at the feature level of this NnApiSLDriver struct.
573    */
574   void (*ANeuralNetworksMemory_free)(ANeuralNetworksMemory* memory);
575 
576   /**
577    * SL Driver implementation of {@link ANeuralNetworksModel_addOperand}.
578    * Behavior, arguments, and outputs match NNAPI Runtime function
579    * {@link ANeuralNetworksModel_addOperand},
580    * at the feature level of this NnApiSLDriver struct.
581    */
582   int (*ANeuralNetworksModel_addOperand)(
583       ANeuralNetworksModel* model, const ANeuralNetworksOperandType* type);
584 
585   /**
586    * SL Driver implementation of {@link ANeuralNetworksModel_addOperation}.
587    * Behavior, arguments, and outputs match NNAPI Runtime function
588    * {@link ANeuralNetworksModel_addOperation},
589    * at the feature level of this NnApiSLDriver struct.
590    */
591   int (*ANeuralNetworksModel_addOperation)(ANeuralNetworksModel* model,
592                                            ANeuralNetworksOperationType type,
593                                            uint32_t inputCount,
594                                            const uint32_t* inputs,
595                                            uint32_t outputCount,
596                                            const uint32_t* outputs);
597 
598   /**
599    * SL Driver implementation of {@link ANeuralNetworksModel_create}.
600    * Behavior, arguments, and outputs match NNAPI Runtime function
601    * {@link ANeuralNetworksModel_create},
602    * at the feature level of this NnApiSLDriver struct.
603    */
604   int (*ANeuralNetworksModel_create)(ANeuralNetworksModel** model);
605 
606   /**
607    * SL Driver implementation of {@link ANeuralNetworksModel_finish}.
608    * Behavior, arguments, and outputs match NNAPI Runtime function
609    * {@link ANeuralNetworksModel_finish},
610    * at the feature level of this NnApiSLDriver struct.
611    */
612   int (*ANeuralNetworksModel_finish)(ANeuralNetworksModel* model);
613 
614   /**
615    * SL Driver implementation of {@link ANeuralNetworksModel_free}.
616    * Behavior, arguments, and outputs match NNAPI Runtime function
617    * {@link ANeuralNetworksModel_free},
618    * at the feature level of this NnApiSLDriver struct.
619    */
620   void (*ANeuralNetworksModel_free)(ANeuralNetworksModel* model);
621 
622   /**
623    * SL Driver implementation of {@link
624    * ANeuralNetworksModel_getExtensionOperandType}. Behavior, arguments, and
625    * outputs match NNAPI Runtime function
626    * {@link ANeuralNetworksModel_getExtensionOperandType},
627    * at the feature level of this NnApiSLDriver struct.
628    */
629   int (*ANeuralNetworksModel_getExtensionOperandType)(
630       ANeuralNetworksModel* model, const char* extensionName,
631       uint16_t operandCodeWithinExtension, int32_t* type);
632 
633   /**
634    * SL Driver implementation of {@link
635    * ANeuralNetworksModel_getExtensionOperationType}. Behavior, arguments, and
636    * outputs match NNAPI Runtime function
637    * {@link ANeuralNetworksModel_getExtensionOperationType},
638    * at the feature level of this NnApiSLDriver struct.
639    */
640   int (*ANeuralNetworksModel_getExtensionOperationType)(
641       ANeuralNetworksModel* model, const char* extensionName,
642       uint16_t operationCodeWithinExtension,
643       ANeuralNetworksOperationType* type);
644 
645   /**
646    * SL Driver implementation of {@link
647    * ANeuralNetworksModel_getSupportedOperationsForDevices}. Behavior,
648    * arguments, and outputs match NNAPI Runtime function
649    * {@link ANeuralNetworksModel_getSupportedOperationsForDevices},
650    * at the feature level of this NnApiSLDriver struct.
651    */
652   int (*ANeuralNetworksModel_getSupportedOperationsForDevices)(
653       const ANeuralNetworksModel* model,
654       const ANeuralNetworksDevice* const* devices, uint32_t numDevices,
655       bool* supportedOps);
656 
657   /**
658    * SL Driver implementation of {@link
659    * ANeuralNetworksModel_identifyInputsAndOutputs}. Behavior, arguments, and
660    * outputs match NNAPI Runtime function
661    * {@link ANeuralNetworksModel_identifyInputsAndOutputs},
662    * at the feature level of this NnApiSLDriver struct.
663    */
664   int (*ANeuralNetworksModel_identifyInputsAndOutputs)(
665       ANeuralNetworksModel* model, uint32_t inputCount, const uint32_t* inputs,
666       uint32_t outputCount, const uint32_t* outputs);
667 
668   /**
669    * SL Driver implementation of {@link
670    * ANeuralNetworksModel_relaxComputationFloat32toFloat16}. Behavior,
671    * arguments, and outputs match NNAPI Runtime function
672    * {@link ANeuralNetworksModel_relaxComputationFloat32toFloat16},
673    * at the feature level of this NnApiSLDriver struct.
674    */
675   int (*ANeuralNetworksModel_relaxComputationFloat32toFloat16)(
676       ANeuralNetworksModel* model, bool allow);
677 
678   /**
679    * SL Driver implementation of {@link
680    * ANeuralNetworksModel_setOperandExtensionData}. Behavior, arguments, and
681    * outputs match NNAPI Runtime function
682    * {@link ANeuralNetworksModel_setOperandExtensionData},
683    * at the feature level of this NnApiSLDriver struct.
684    */
685   int (*ANeuralNetworksModel_setOperandExtensionData)(
686       ANeuralNetworksModel* model, int32_t index, const void* data,
687       size_t length);
688 
689   /**
690    * SL Driver implementation of {@link
691    * ANeuralNetworksModel_setOperandSymmPerChannelQuantParams}. Behavior,
692    * arguments, and outputs match NNAPI Runtime function
693    * {@link ANeuralNetworksModel_setOperandSymmPerChannelQuantParams},
694    * at the feature level of this NnApiSLDriver struct.
695    */
696   int (*ANeuralNetworksModel_setOperandSymmPerChannelQuantParams)(
697       ANeuralNetworksModel* model, int32_t index,
698       const ANeuralNetworksSymmPerChannelQuantParams* channelQuant);
699 
700   /**
701    * SL Driver implementation of {@link ANeuralNetworksModel_setOperandValue}.
702    * Behavior, arguments, and outputs match NNAPI Runtime function
703    * {@link ANeuralNetworksModel_setOperandValue},
704    * at the feature level of this NnApiSLDriver struct.
705    */
706   int (*ANeuralNetworksModel_setOperandValue)(ANeuralNetworksModel* model,
707                                               int32_t index, const void* buffer,
708                                               size_t length);
709 
710   /**
711    * SL Driver implementation of {@link
712    * ANeuralNetworksModel_setOperandValueFromMemory}. Behavior, arguments, and
713    * outputs match NNAPI Runtime function
714    * {@link ANeuralNetworksModel_setOperandValueFromMemory},
715    * at the feature level of this NnApiSLDriver struct.
716    */
717   int (*ANeuralNetworksModel_setOperandValueFromMemory)(
718       ANeuralNetworksModel* model, int32_t index,
719       const ANeuralNetworksMemory* memory, size_t offset, size_t length);
720 
721   /**
722    * SL Driver implementation of {@link
723    * ANeuralNetworksModel_setOperandValueFromModel}. Behavior, arguments, and
724    * outputs match NNAPI Runtime function
725    * {@link ANeuralNetworksModel_setOperandValueFromModel},
726    * at the feature level of this NnApiSLDriver struct.
727    */
728   int (*ANeuralNetworksModel_setOperandValueFromModel)(
729       ANeuralNetworksModel* model, int32_t index,
730       const ANeuralNetworksModel* value);
731 
732   /**
733    * SL Driver implementation of {@link ANeuralNetworks_getDefaultLoopTimeout}.
734    * Behavior, arguments, and outputs match NNAPI Runtime function
735    * {@link ANeuralNetworks_getDefaultLoopTimeout},
736    * at the feature level of this NnApiSLDriver struct.
737    */
738   uint64_t (*ANeuralNetworks_getDefaultLoopTimeout)();
739 
740   /**
741    * SL Driver implementation of {@link ANeuralNetworks_getDevice}.
742    * Behavior, arguments, and outputs match NNAPI Runtime function
743    * {@link ANeuralNetworks_getDevice},
744    * at the feature level of this NnApiSLDriver struct.
745    */
746   int (*ANeuralNetworks_getDevice)(uint32_t devIndex,
747                                    ANeuralNetworksDevice** device);
748 
749   /**
750    * SL Driver implementation of {@link ANeuralNetworks_getDeviceCount}.
751    * Behavior, arguments, and outputs match NNAPI Runtime function
752    * {@link ANeuralNetworks_getDeviceCount},
753    * at the feature level of this NnApiSLDriver struct.
754    */
755   int (*ANeuralNetworks_getDeviceCount)(uint32_t* numDevices);
756 
757   /**
758    * SL Driver implementation of {@link ANeuralNetworks_getMaximumLoopTimeout}.
759    * Behavior, arguments, and outputs match NNAPI Runtime function
760    * {@link ANeuralNetworks_getMaximumLoopTimeout},
761    * at the feature level of this NnApiSLDriver struct.
762    */
763   uint64_t (*ANeuralNetworks_getMaximumLoopTimeout)();
764 
765   /**
766    * SL Driver implementation of {@link ANeuralNetworks_getRuntimeFeatureLevel}.
767    * Behavior, arguments, and outputs match NNAPI Runtime function
768    * {@link ANeuralNetworks_getRuntimeFeatureLevel},
769    * at the feature level of this NnApiSLDriver struct.
770    */
771   int64_t (*ANeuralNetworks_getRuntimeFeatureLevel)();
772 
773   /**
774    * 72nd pointer required to align to 8 bytes on 32bit archs.
775    */
776   void (*reserved_placeholder1)();
777 };
778 
779 #ifdef __cplusplus
780 }  // extern "C"
781 #endif
782 
783 #endif  // TENSORFLOW_LITE_NNAPI_SL_PUBLIC_NEURAL_NETWORKS_SUPPORT_LIBRARY_IMPL_H_
784