88#include <stdio.h>
99#include <stdlib.h>
1010
11- WASI_NN_ERROR_TYPE
11+ #if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
12+ typedef wasi_ephemeral_nn_error wasi_nn_error_t ;
13+ #else
14+ typedef wasi_nn_error wasi_nn_error_t ;
15+ #endif
16+
17+ wasi_nn_error_t
1218wasm_load (char * model_name , WASI_NN_NAME (graph ) * g ,
1319 WASI_NN_NAME (execution_target ) target )
1420{
@@ -39,7 +45,7 @@ wasm_load(char *model_name, WASI_NN_NAME(graph) * g,
3945 arr .buf = buffer ;
4046 arr .size = result ;
4147
42- WASI_NN_ERROR_TYPE res = WASI_NN_NAME (load )(
48+ wasi_nn_error_t res = WASI_NN_NAME (load )(
4349 & arr , result , WASI_NN_ENCODING_NAME (tensorflowlite ), target , g );
4450#else
4551 WASI_NN_NAME (graph_builder_array ) arr ;
@@ -56,7 +62,7 @@ wasm_load(char *model_name, WASI_NN_NAME(graph) * g,
5662 arr .buf [0 ].size = result ;
5763 arr .buf [0 ].buf = buffer ;
5864
59- WASI_NN_ERROR_TYPE res = WASI_NN_NAME (load )(
65+ wasi_nn_error_t res = WASI_NN_NAME (load )(
6066 & arr , WASI_NN_ENCODING_NAME (tensorflowlite ), target , g );
6167#endif
6268
@@ -66,22 +72,22 @@ wasm_load(char *model_name, WASI_NN_NAME(graph) * g,
6672 return res ;
6773}
6874
69- WASI_NN_ERROR_TYPE
75+ wasi_nn_error_t
7076wasm_load_by_name (const char * model_name , WASI_NN_NAME (graph ) * g )
7177{
72- WASI_NN_ERROR_TYPE res =
78+ wasi_nn_error_t res =
7379 WASI_NN_NAME (load_by_name )(model_name , strlen (model_name ), g );
7480 return res ;
7581}
7682
77- WASI_NN_ERROR_TYPE
83+ wasi_nn_error_t
7884wasm_init_execution_context (WASI_NN_NAME (graph ) g ,
7985 WASI_NN_NAME (graph_execution_context ) * ctx )
8086{
8187 return WASI_NN_NAME (init_execution_context )(g , ctx );
8288}
8389
84- WASI_NN_ERROR_TYPE
90+ wasi_nn_error_t
8591wasm_set_input (WASI_NN_NAME (graph_execution_context ) ctx , float * input_tensor ,
8692 uint32_t * dim )
8793{
@@ -113,19 +119,19 @@ wasm_set_input(WASI_NN_NAME(graph_execution_context) ctx, float *input_tensor,
113119 tensor .data = (uint8_t * )input_tensor ;
114120#endif
115121
116- WASI_NN_ERROR_TYPE err = WASI_NN_NAME (set_input )(ctx , 0 , & tensor );
122+ wasi_nn_error_t err = WASI_NN_NAME (set_input )(ctx , 0 , & tensor );
117123
118124 free (dims .buf );
119125 return err ;
120126}
121127
122- WASI_NN_ERROR_TYPE
128+ wasi_nn_error_t
123129wasm_compute (WASI_NN_NAME (graph_execution_context ) ctx )
124130{
125131 return WASI_NN_NAME (compute )(ctx );
126132}
127133
128- WASI_NN_ERROR_TYPE
134+ wasi_nn_error_t
129135wasm_get_output (WASI_NN_NAME (graph_execution_context ) ctx , uint32_t index ,
130136 float * out_tensor , uint32_t * out_size )
131137{
@@ -144,8 +150,8 @@ run_inference(float *input, uint32_t *input_size, uint32_t *output_size,
144150{
145151 WASI_NN_NAME (graph ) graph ;
146152
147- WASI_NN_ERROR_TYPE res = wasm_load_by_name (model_name , & graph );
148-
153+ wasi_nn_error_t res = wasm_load_by_name (model_name , & graph );
154+
149155 if (res == WASI_NN_ERROR_NAME (not_found )) {
150156 NN_INFO_PRINTF ("Model %s is not loaded, you should pass its path "
151157 "through --wasi-nn-graph" ,
0 commit comments