1111#include <string.h>
1212#include <stdint.h>
1313
14- #include "wasi_nn.h"
1514#include "wasi_nn_private.h"
1615#include "wasi_nn_app_native.h"
1716#include "wasi_nn_tensorflowlite.hpp"
2423
2524/* Definition of 'wasi_nn.h' structs in WASM app format (using offset) */
2625
27- typedef error (* LOAD )(void * , graph_builder_array * , graph_encoding ,
28- execution_target , graph * );
29- typedef error (* INIT_EXECUTION_CONTEXT )(void * , graph ,
30- graph_execution_context * );
31- typedef error (* SET_INPUT )(void * , graph_execution_context , uint32_t , tensor * );
32- typedef error (* COMPUTE )(void * , graph_execution_context );
33- typedef error (* GET_OUTPUT )(void * , graph_execution_context , uint32_t ,
34- tensor_data , uint32_t * );
26+ typedef wasi_nn_error (* LOAD )(void * , graph_builder_array * , graph_encoding ,
27+ execution_target , graph * );
28+ typedef wasi_nn_error (* INIT_EXECUTION_CONTEXT )(void * , graph ,
29+ graph_execution_context * );
30+ typedef wasi_nn_error (* SET_INPUT )(void * , graph_execution_context , uint32_t ,
31+ tensor * );
32+ typedef wasi_nn_error (* COMPUTE )(void * , graph_execution_context );
33+ typedef wasi_nn_error (* GET_OUTPUT )(void * , graph_execution_context , uint32_t ,
34+ tensor_data , uint32_t * );
3535
3636typedef struct {
3737 LOAD load ;
@@ -177,7 +177,7 @@ is_encoding_implemented(graph_encoding encoding)
177177 && lookup [encoding ].get_output ;
178178}
179179
180- static error
180+ static wasi_nn_error
181181is_model_initialized (WASINNContext * wasi_nn_ctx )
182182{
183183 if (!wasi_nn_ctx -> is_model_loaded ) {
@@ -190,12 +190,12 @@ is_model_initialized(WASINNContext *wasi_nn_ctx)
190190/* WASI-NN implementation */
191191
192192#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
193- error
193+ wasi_nn_error
194194wasi_nn_load (wasm_exec_env_t exec_env , graph_builder_wasm * builder ,
195195 uint32_t builder_wasm_size , graph_encoding encoding ,
196196 execution_target target , graph * g )
197197#else /* WASM_ENABLE_WASI_EPHEMERAL_NN == 0 */
198- error
198+ wasi_nn_error
199199wasi_nn_load (wasm_exec_env_t exec_env , graph_builder_array_wasm * builder ,
200200 graph_encoding encoding , execution_target target , graph * g )
201201#endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */
@@ -211,7 +211,7 @@ wasi_nn_load(wasm_exec_env_t exec_env, graph_builder_array_wasm *builder,
211211 wasm_module_inst_t instance = wasm_runtime_get_module_inst (exec_env );
212212 bh_assert (instance );
213213
214- error res ;
214+ wasi_nn_error res ;
215215 graph_builder_array builder_native = { 0 };
216216#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
217217 if (success
@@ -249,7 +249,7 @@ wasi_nn_load(wasm_exec_env_t exec_env, graph_builder_array_wasm *builder,
249249 return res ;
250250}
251251
252- error
252+ wasi_nn_error
253253wasi_nn_init_execution_context (wasm_exec_env_t exec_env , graph g ,
254254 graph_execution_context * ctx )
255255{
@@ -259,7 +259,7 @@ wasi_nn_init_execution_context(wasm_exec_env_t exec_env, graph g,
259259 bh_assert (instance );
260260 WASINNContext * wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx (instance );
261261
262- error res ;
262+ wasi_nn_error res ;
263263 if (success != (res = is_model_initialized (wasi_nn_ctx )))
264264 return res ;
265265
@@ -278,7 +278,7 @@ wasi_nn_init_execution_context(wasm_exec_env_t exec_env, graph g,
278278 return res ;
279279}
280280
281- error
281+ wasi_nn_error
282282wasi_nn_set_input (wasm_exec_env_t exec_env , graph_execution_context ctx ,
283283 uint32_t index , tensor_wasm * input_tensor )
284284{
@@ -289,7 +289,7 @@ wasi_nn_set_input(wasm_exec_env_t exec_env, graph_execution_context ctx,
289289 bh_assert (instance );
290290 WASINNContext * wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx (instance );
291291
292- error res ;
292+ wasi_nn_error res ;
293293 if (success != (res = is_model_initialized (wasi_nn_ctx )))
294294 return res ;
295295
@@ -310,7 +310,7 @@ wasi_nn_set_input(wasm_exec_env_t exec_env, graph_execution_context ctx,
310310 return res ;
311311}
312312
313- error
313+ wasi_nn_error
314314wasi_nn_compute (wasm_exec_env_t exec_env , graph_execution_context ctx )
315315{
316316 NN_DBG_PRINTF ("Running wasi_nn_compute [ctx=%d]..." , ctx );
@@ -319,7 +319,7 @@ wasi_nn_compute(wasm_exec_env_t exec_env, graph_execution_context ctx)
319319 bh_assert (instance );
320320 WASINNContext * wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx (instance );
321321
322- error res ;
322+ wasi_nn_error res ;
323323 if (success != (res = is_model_initialized (wasi_nn_ctx )))
324324 return res ;
325325
@@ -330,12 +330,12 @@ wasi_nn_compute(wasm_exec_env_t exec_env, graph_execution_context ctx)
330330}
331331
332332#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
333- error
333+ wasi_nn_error
334334wasi_nn_get_output (wasm_exec_env_t exec_env , graph_execution_context ctx ,
335335 uint32_t index , tensor_data output_tensor ,
336336 uint32_t output_tensor_len , uint32_t * output_tensor_size )
337337#else /* WASM_ENABLE_WASI_EPHEMERAL_NN == 0 */
338- error
338+ wasi_nn_error
339339wasi_nn_get_output (wasm_exec_env_t exec_env , graph_execution_context ctx ,
340340 uint32_t index , tensor_data output_tensor ,
341341 uint32_t * output_tensor_size )
@@ -348,7 +348,7 @@ wasi_nn_get_output(wasm_exec_env_t exec_env, graph_execution_context ctx,
348348 bh_assert (instance );
349349 WASINNContext * wasi_nn_ctx = wasm_runtime_get_wasi_nn_ctx (instance );
350350
351- error res ;
351+ wasi_nn_error res ;
352352 if (success != (res = is_model_initialized (wasi_nn_ctx )))
353353 return res ;
354354
0 commit comments