xref: /aosp_15_r20/external/pytorch/aten/src/ATen/nnapi/nnapi_wrapper.h (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 /**
2  * Copyright (c) Facebook, Inc. and its affiliates.
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 // This file is generated by nnapi/codegen.py
18 #ifndef NNAPI_WRAPPER_H_
19 #define NNAPI_WRAPPER_H_
20 #include <stddef.h>
21 #include <stdint.h>
22 #include <ATen/nnapi/NeuralNetworks.h>
23 struct nnapi_wrapper {
24   int(*_getDeviceCount)(uint32_t* numDevices);
25   int(*_getDevice)(uint32_t devIndex, ANeuralNetworksDevice** device);
26   int(*Device_getName)(const ANeuralNetworksDevice* device, const char** name);
27   int(*Device_getVersion)(const ANeuralNetworksDevice* device, const char** version);
28   int(*Device_getFeatureLevel)(const ANeuralNetworksDevice* device, int64_t* featureLevel);
29   int(*Model_getSupportedOperationsForDevices)( const ANeuralNetworksModel* model, const ANeuralNetworksDevice* const* devices, uint32_t numDevices, bool* supportedOps);
30   int(*Compilation_createForDevices)(ANeuralNetworksModel* model, const ANeuralNetworksDevice* const* devices, uint32_t numDevices, ANeuralNetworksCompilation** compilation);
31   int(*Execution_compute)(ANeuralNetworksExecution* execution);
32   int(*Memory_createFromFd)(size_t size, int protect, int fd, size_t offset, ANeuralNetworksMemory** memory);
33   void(*Memory_free)(ANeuralNetworksMemory* memory);
34   int(*Model_create)(ANeuralNetworksModel** model);
35   void(*Model_free)(ANeuralNetworksModel* model);
36   int(*Model_finish)(ANeuralNetworksModel* model);
37   int(*Model_addOperand)(ANeuralNetworksModel* model, const ANeuralNetworksOperandType* type);
38   int(*Model_setOperandValue)(ANeuralNetworksModel* model, int32_t index, const void* buffer, size_t length);
39   int(*Model_setOperandValueFromMemory)(ANeuralNetworksModel* model, int32_t index, const ANeuralNetworksMemory* memory, size_t offset, size_t length);
40   int(*Model_addOperation)(ANeuralNetworksModel* model, ANeuralNetworksOperationType type, uint32_t inputCount, const uint32_t* inputs, uint32_t outputCount, const uint32_t* outputs);
41   int(*Model_identifyInputsAndOutputs)(ANeuralNetworksModel* model, uint32_t inputCount, const uint32_t* inputs, uint32_t outputCount, const uint32_t* outputs);
42   int(*Model_relaxComputationFloat32toFloat16)(ANeuralNetworksModel* model, bool allow);
43   int(*Compilation_create)(ANeuralNetworksModel* model, ANeuralNetworksCompilation** compilation);
44   void(*Compilation_free)(ANeuralNetworksCompilation* compilation);
45   int(*Compilation_setPreference)(ANeuralNetworksCompilation* compilation, int32_t preference);
46   int(*Compilation_finish)(ANeuralNetworksCompilation* compilation);
47   int(*Execution_create)(ANeuralNetworksCompilation* compilation, ANeuralNetworksExecution** execution);
48   void(*Execution_free)(ANeuralNetworksExecution* execution);
49   int(*Execution_setInput)(ANeuralNetworksExecution* execution, int32_t index, const ANeuralNetworksOperandType* type, const void* buffer, size_t length);
50   int(*Execution_setInputFromMemory)(ANeuralNetworksExecution* execution, int32_t index, const ANeuralNetworksOperandType* type, const ANeuralNetworksMemory* memory, size_t offset, size_t length);
51   int(*Execution_setOutput)(ANeuralNetworksExecution* execution, int32_t index, const ANeuralNetworksOperandType* type, void* buffer, size_t length);
52   int(*Execution_setOutputFromMemory)(ANeuralNetworksExecution* execution, int32_t index, const ANeuralNetworksOperandType* type, const ANeuralNetworksMemory* memory, size_t offset, size_t length);
53   int(*Execution_startCompute)(ANeuralNetworksExecution* execution, ANeuralNetworksEvent** event);
54   int(*Event_wait)(ANeuralNetworksEvent* event);
55   void(*Event_free)(ANeuralNetworksEvent* event);
56   int(*Execution_getOutputOperandRank)(ANeuralNetworksExecution* execution, int32_t index, uint32_t* rank);
57   int(*Execution_getOutputOperandDimensions)(ANeuralNetworksExecution* execution, int32_t index, uint32_t* dimensions);
58 };
59 #ifdef __cplusplus
60 void nnapi_wrapper_load(struct nnapi_wrapper** nnapi, struct nnapi_wrapper** check_nnapi);
61 #endif
62 #endif
63