• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
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 ADAPTER_WRAPPER_H
17 #define ADAPTER_WRAPPER_H
18 
19 #include "protocol/retcode_inner/aie_retcode_inner.h"
20 #include "liteipc_adapter.h"
21 
22 #include "protocol/struct_definition/aie_info_define.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /**
29  * Allocate client ID and generate adapter for client.
30  *
31  * @return Returns client ID if the operation is successful, returns INVALID_CLIENT_ID otherwise.
32  */
33 extern int GenerateClient();
34 
35 /**
36  * Generate transaction ID and load certain algorithm based on the information transferred from client.
37  *
38  * @param [in] clientInfo Client information.
39  * @param [in] algorithmInfo Algorithm information.
40  * @param [in] inputInfo Data information needed to load algorithm plugin.
41  * @param [out] outputInfo The returned data information after loading the algorithm plugin.
42  * @return Returns 0 if the operation is successful, returns a non-zero value otherwise.
43  */
44 extern int LoadAlgoWrapper(const ClientInfo *clientInfo, const AlgorithmInfo *algoInfo,
45     const DataInfo *inputInfo, DataInfo *outputInfo);
46 
47 /**
48  * Execute algorithm inference synchronously.
49  *
50  * @param [in] clientInfo Client information.
51  * @param [in] AlgorithmInfo Algorithm information.
52  * @param [in] inputInfo Data information needed to synchronous execution algorithm.
53  * @param [out] outputInfo Algorithm inference results.
54  * @return Returns 0 if the operation is successful, returns a non-zero value otherwise.
55  */
56 extern int SyncExecAlgoWrapper(const ClientInfo *clientInfo, const AlgorithmInfo *algoInfo,
57     const DataInfo *inputInfo, DataInfo *outputInfo);
58 
59 /**
60  * Execute algorithm inference asynchronously.
61  *
62  * @param [in] clientInfo Client information.
63  * @param [in] AlgorithmInfo Algorithm information.
64  * @param [in] inputInfo Data information needed to synchronous execution algorithm.
65  * @return Returns 0 if the operation is successful, returns a non-zero value otherwise.
66  */
67 extern int AsyncExecAlgoWrapper(const ClientInfo *clientInfo, const AlgorithmInfo *algoInfo, const DataInfo *inputInfo);
68 
69 /**
70  * Unload algorithm plugin and model based on algorithm information and client information.
71  *
72  * @param [in] clientInfo Client information.
73  * @param [in] algorithmInfo Algorithm information.
74  * @param [in] inputInfo Data information needed to load algorithm plugin.
75  * @return Returns 0 if the operation is successful, returns a non-zero value otherwise.
76  */
77 extern int UnloadAlgoWrapper(const ClientInfo *clientInfo, const AlgorithmInfo *algoInfo, const DataInfo *inputInfo);
78 
79 /**
80  * Delete client adapter.
81  *
82  * @param [in] clientInfo Client information.
83  * @return Returns 0 if the operation is successful, returns a non-zero value otherwise.
84  */
85 extern int RemoveAdapterWrapper(const ClientInfo *clientInfo);
86 
87 /**
88  * Set the configuration parameters of the engine or plugin.
89  *
90  * @param [in] clientInfo Client information.
91  * @param [in] optionType The type of setting option.
92  * @param [in] inputInfo Configuration parameter needed to set up the engine or plugin.
93  * @return Returns 0 if the operation is successful, returns a non-zero value otherwise.
94  */
95 extern int SetOptionWrapper(const ClientInfo *clientInfo, int optionType, const DataInfo *inputInfo);
96 
97 /**
98  * Get the configuration parameters of the engine or plugin.
99  *
100  * @param [in] clientInfo Client information.
101  * @param [in] optionType The type of getting option.
102  * @param [in] inputInfo Parameter information for getting options.
103  * @param [out] outputInfo The configuration parameter information.
104  * @return Returns 0 if the operation is successful, returns a non-zero value otherwise.
105  */
106 extern int GetOptionWrapper(const ClientInfo *clientInfo, int optionType, const DataInfo *inputInfo,
107     DataInfo *outputInfo);
108 
109 /**
110  * Save listener to call client async process, and register server async handler.
111  *
112  * @param [in] clientInfo Client information.
113  * @param [in] sid Client async callback SVC handle identity
114  * @return Returns 0 if the operation is successful, returns a non-zero value otherwise.
115  */
116 extern int RegisterCallbackWrapper(const ClientInfo *clientInfo, SvcIdentity *sid);
117 
118 /**
119  * Delete listener to call client async process, and stop server async handler.
120  *
121  * @param [in] clientInfo Client information.
122  * @return Returns 0 if the operation is successful, returns a non-zero value otherwise.
123  */
124 extern int UnregisterCallbackWrapper(const ClientInfo *clientInfo);
125 
126 #ifdef __cplusplus
127 };
128 #endif
129 
130 #endif // ADAPTER_WRAPPER_H
131