@@ -1700,25 +1700,25 @@ wasm_runtime_instantiation_args_destroy(struct InstantiationArgs2 *p)
17001700struct wasi_nn_graph_registry ;
17011701
17021702void
1703- wasm_runtime_wasi_nn_graph_registry_args_set_defaults (struct wasi_nn_graph_registry * args )
1703+ wasm_runtime_wasi_nn_graph_registry_args_set_defaults (
1704+ struct wasi_nn_graph_registry * args )
17041705{
17051706 memset (args , 0 , sizeof (* args ));
17061707}
17071708
17081709bool
1709- wasi_nn_graph_registry_set_args (struct wasi_nn_graph_registry * registry , const char * encoding ,
1710- const char * target , uint32_t n_graphs ,
1711- const char * * graph_paths )
1710+ wasi_nn_graph_registry_set_args (struct wasi_nn_graph_registry * registry ,
1711+ const char * encoding , const char * target ,
1712+ uint32_t n_graphs , const char * * graph_paths )
17121713{
1713- if (!registry || !encoding || !target || !graph_paths )
1714- {
1714+ if (!registry || !encoding || !target || !graph_paths ) {
17151715 return false;
17161716 }
17171717 registry -> encoding = strdup (encoding );
17181718 registry -> target = strdup (target );
17191719 registry -> n_graphs = n_graphs ;
1720- registry -> graph_paths = (uint32_t * * )malloc (sizeof (uint32_t * ) * n_graphs );
1721- memset (registry -> graph_paths , 0 , sizeof (uint32_t * ) * n_graphs );
1720+ registry -> graph_paths = (uint32_t * * )malloc (sizeof (uint32_t * ) * n_graphs );
1721+ memset (registry -> graph_paths , 0 , sizeof (uint32_t * ) * n_graphs );
17221722 for (uint32_t i = 0 ; i < registry -> n_graphs ; i ++ )
17231723 registry -> graph_paths [i ] = strdup (graph_paths [i ]);
17241724
@@ -1740,12 +1740,11 @@ wasi_nn_graph_registry_create(struct wasi_nn_graph_registry **registryp)
17401740void
17411741wasi_nn_graph_registry_destroy (struct wasi_nn_graph_registry * registry )
17421742{
1743- if (registry )
1744- {
1743+ if (registry ) {
17451744 for (uint32_t i = 0 ; i < registry -> n_graphs ; i ++ )
1746- if (registry -> graph_paths [i ])
1747- {
1748- // wasi_nn_graph_registry_unregister_graph(registry, registry->name[i]);
1745+ if (registry -> graph_paths [i ]) {
1746+ // wasi_nn_graph_registry_unregister_graph(registry,
1747+ // registry->name[i]);
17491748 free (registry -> graph_paths [i ]);
17501749 }
17511750 if (registry -> encoding )
@@ -8153,27 +8152,27 @@ wasm_runtime_check_and_update_last_used_shared_heap(
81538152#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
81548153bool
81558154wasm_runtime_init_wasi_nn_global_ctx (WASMModuleInstanceCommon * module_inst ,
8156- const char * encoding , const char * target ,
8157- const uint32_t n_graphs , char * graph_paths [],
8158- char * error_buf , uint32_t error_buf_size )
8155+ const char * encoding , const char * target ,
8156+ const uint32_t n_graphs ,
8157+ char * graph_paths [], char * error_buf ,
8158+ uint32_t error_buf_size )
81598159{
81608160 WASINNGlobalContext * ctx ;
81618161 bool ret = false;
81628162
81638163 ctx = runtime_malloc (sizeof (* ctx ), module_inst , error_buf , error_buf_size );
81648164 if (!ctx )
81658165 return false;
8166-
8166+
81678167 ctx -> encoding = strdup (encoding );
81688168 ctx -> target = strdup (target );
81698169 ctx -> n_graphs = n_graphs ;
8170- ctx -> loaded = (uint32_t * )malloc (sizeof (uint32_t ) * n_graphs );
8170+ ctx -> loaded = (uint32_t * )malloc (sizeof (uint32_t ) * n_graphs );
81718171 memset (ctx -> loaded , 0 , sizeof (uint32_t ) * n_graphs );
8172-
8173- ctx -> graph_paths = (uint32_t * * )malloc (sizeof (uint32_t * ) * n_graphs );
8174- memset (ctx -> graph_paths , 0 , sizeof (uint32_t * ) * n_graphs );
8175- for (uint32_t i = 0 ; i < n_graphs ; i ++ )
8176- {
8172+
8173+ ctx -> graph_paths = (uint32_t * * )malloc (sizeof (uint32_t * ) * n_graphs );
8174+ memset (ctx -> graph_paths , 0 , sizeof (uint32_t * ) * n_graphs );
8175+ for (uint32_t i = 0 ; i < n_graphs ; i ++ ) {
81778176 ctx -> graph_paths [i ] = strdup (graph_paths [i ]);
81788177 }
81798178
@@ -8187,10 +8186,10 @@ wasm_runtime_init_wasi_nn_global_ctx(WASMModuleInstanceCommon *module_inst,
81878186void
81888187wasm_runtime_destroy_wasi_nn_global_ctx (WASMModuleInstanceCommon * module_inst )
81898188{
8190- WASINNGlobalContext * wasi_nn_global_ctx = wasm_runtime_get_wasi_nn_global_ctx (module_inst );
8189+ WASINNGlobalContext * wasi_nn_global_ctx =
8190+ wasm_runtime_get_wasi_nn_global_ctx (module_inst );
81918191
8192- for (uint32 i = 0 ; i < wasi_nn_global_ctx -> n_graphs ; i ++ )
8193- {
8192+ for (uint32 i = 0 ; i < wasi_nn_global_ctx -> n_graphs ; i ++ ) {
81948193 // All graphs will be unregistered in deinit()
81958194 if (wasi_nn_global_ctx -> graph_paths [i ])
81968195 free (wasi_nn_global_ctx -> graph_paths [i ]);
@@ -8206,7 +8205,8 @@ wasm_runtime_destroy_wasi_nn_global_ctx(WASMModuleInstanceCommon *module_inst)
82068205}
82078206
82088207uint32_t
8209- wasm_runtime_get_wasi_nn_global_ctx_ngraphs (WASINNGlobalContext * wasi_nn_global_ctx )
8208+ wasm_runtime_get_wasi_nn_global_ctx_ngraphs (
8209+ WASINNGlobalContext * wasi_nn_global_ctx )
82108210{
82118211 if (wasi_nn_global_ctx )
82128212 return wasi_nn_global_ctx -> n_graphs ;
@@ -8215,7 +8215,8 @@ wasm_runtime_get_wasi_nn_global_ctx_ngraphs(WASINNGlobalContext *wasi_nn_global_
82158215}
82168216
82178217char *
8218- wasm_runtime_get_wasi_nn_global_ctx_graph_paths_i (WASINNGlobalContext * wasi_nn_global_ctx , uint32_t idx )
8218+ wasm_runtime_get_wasi_nn_global_ctx_graph_paths_i (
8219+ WASINNGlobalContext * wasi_nn_global_ctx , uint32_t idx )
82198220{
82208221 if (wasi_nn_global_ctx && (idx < wasi_nn_global_ctx -> n_graphs ))
82218222 return wasi_nn_global_ctx -> graph_paths [idx ];
@@ -8224,7 +8225,8 @@ wasm_runtime_get_wasi_nn_global_ctx_graph_paths_i(WASINNGlobalContext *wasi_nn_g
82248225}
82258226
82268227uint32_t
8227- wasm_runtime_get_wasi_nn_global_ctx_loaded_i (WASINNGlobalContext * wasi_nn_global_ctx , uint32_t idx )
8228+ wasm_runtime_get_wasi_nn_global_ctx_loaded_i (
8229+ WASINNGlobalContext * wasi_nn_global_ctx , uint32_t idx )
82288230{
82298231 if (wasi_nn_global_ctx && (idx < wasi_nn_global_ctx -> n_graphs ))
82308232 return wasi_nn_global_ctx -> loaded [idx ];
@@ -8233,25 +8235,28 @@ wasm_runtime_get_wasi_nn_global_ctx_loaded_i(WASINNGlobalContext *wasi_nn_global
82338235}
82348236
82358237uint32_t
8236- wasm_runtime_set_wasi_nn_global_ctx_loaded_i (WASINNGlobalContext * wasi_nn_global_ctx , uint32_t idx , uint32_t value )
8238+ wasm_runtime_set_wasi_nn_global_ctx_loaded_i (
8239+ WASINNGlobalContext * wasi_nn_global_ctx , uint32_t idx , uint32_t value )
82378240{
82388241 if (wasi_nn_global_ctx && (idx < wasi_nn_global_ctx -> n_graphs ))
82398242 wasi_nn_global_ctx -> loaded [idx ] = value ;
82408243
82418244 return 0 ;
82428245}
82438246
8244- char *
8245- wasm_runtime_get_wasi_nn_global_ctx_encoding (WASINNGlobalContext * wasi_nn_global_ctx )
8247+ char *
8248+ wasm_runtime_get_wasi_nn_global_ctx_encoding (
8249+ WASINNGlobalContext * wasi_nn_global_ctx )
82468250{
82478251 if (wasi_nn_global_ctx )
82488252 return wasi_nn_global_ctx -> encoding ;
82498253
82508254 return NULL ;
82518255}
82528256
8253- char *
8254- wasm_runtime_get_wasi_nn_global_ctx_target (WASINNGlobalContext * wasi_nn_global_ctx )
8257+ char *
8258+ wasm_runtime_get_wasi_nn_global_ctx_target (
8259+ WASINNGlobalContext * wasi_nn_global_ctx )
82558260{
82568261 if (wasi_nn_global_ctx )
82578262 return wasi_nn_global_ctx -> target ;
0 commit comments