Skip to content

Commit 8dbba46

Browse files
committed
Use clang-format-18 to format files
1 parent 12d8a18 commit 8dbba46

6 files changed

Lines changed: 43 additions & 39 deletions

File tree

core/iwasm/common/wasm_runtime_common.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,14 +1805,14 @@ wasm_runtime_wasi_nn_graph_registry_args_set_defaults(WASINNArguments *args)
18051805
}
18061806

18071807
bool
1808-
wasi_nn_graph_registry_set_args(WASINNArguments *registry, const char **encoding,
1809-
const char **target, uint32_t n_graphs,
1810-
const char **graph_paths)
1808+
wasi_nn_graph_registry_set_args(WASINNArguments *registry,
1809+
const char **encoding, const char **target,
1810+
uint32_t n_graphs, const char **graph_paths)
18111811
{
18121812
if (!registry || !encoding || !target || !graph_paths) {
18131813
return false;
18141814
}
1815-
1815+
18161816
registry->n_graphs = n_graphs;
18171817
registry->target = (uint32_t **)malloc(sizeof(uint32_t *) * n_graphs);
18181818
registry->encoding = (uint32_t **)malloc(sizeof(uint32_t *) * n_graphs);
@@ -1821,8 +1821,7 @@ wasi_nn_graph_registry_set_args(WASINNArguments *registry, const char **encoding
18211821
memset(registry->encoding, 0, sizeof(uint32_t *) * n_graphs);
18221822
memset(registry->graph_paths, 0, sizeof(uint32_t *) * n_graphs);
18231823

1824-
for (uint32_t i = 0; i < registry->n_graphs; i++)
1825-
{
1824+
for (uint32_t i = 0; i < registry->n_graphs; i++) {
18261825
registry->graph_paths[i] = strdup(graph_paths[i]);
18271826
registry->encoding[i] = strdup(encoding[i]);
18281827
registry->target[i] = strdup(target[i]);
@@ -1850,10 +1849,10 @@ wasi_nn_graph_registry_destroy(WASINNArguments *registry)
18501849
for (uint32_t i = 0; i < registry->n_graphs; i++)
18511850
if (registry->graph_paths[i]) {
18521851
free(registry->graph_paths[i]);
1853-
if (registry->encoding[i])
1854-
free(registry->encoding[i]);
1855-
if (registry->target[i])
1856-
free(registry->target[i]);
1852+
if (registry->encoding[i])
1853+
free(registry->encoding[i]);
1854+
if (registry->target[i])
1855+
free(registry->target[i]);
18571856
}
18581857
free(registry);
18591858
}

core/iwasm/common/wasm_runtime_common.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,9 +811,9 @@ wasm_runtime_instantiation_args_set_wasi_nn_graph_registry(
811811
struct InstantiationArgs2 *p, WASINNArguments *registry);
812812

813813
WASM_RUNTIME_API_EXTERN bool
814-
wasi_nn_graph_registry_set_args(WASINNArguments *registry, const char **encoding,
815-
const char **target, uint32_t n_graphs,
816-
const char **graph_paths);
814+
wasi_nn_graph_registry_set_args(WASINNArguments *registry,
815+
const char **encoding, const char **target,
816+
uint32_t n_graphs, const char **graph_paths);
817817
#endif
818818

819819
/* See wasm_export.h for description */

core/iwasm/include/wasm_export.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -803,27 +803,27 @@ wasm_runtime_get_wasi_nn_global_ctx(const wasm_module_inst_t module_inst);
803803

804804
WASM_RUNTIME_API_EXTERN uint32_t
805805
wasm_runtime_get_wasi_nn_global_ctx_ngraphs(
806-
WASINNGlobalContext * wasi_nn_global_ctx);
806+
WASINNGlobalContext *wasi_nn_global_ctx);
807807

808808
WASM_RUNTIME_API_EXTERN char *
809809
wasm_runtime_get_wasi_nn_global_ctx_graph_paths_i(
810-
WASINNGlobalContext * wasi_nn_global_ctx, uint32_t idx);
810+
WASINNGlobalContext *wasi_nn_global_ctx, uint32_t idx);
811811

812812
WASM_RUNTIME_API_EXTERN uint32_t
813813
wasm_runtime_get_wasi_nn_global_ctx_loaded_i(
814-
WASINNGlobalContext * wasi_nn_global_ctx, uint32_t idx);
814+
WASINNGlobalContext *wasi_nn_global_ctx, uint32_t idx);
815815

816816
WASM_RUNTIME_API_EXTERN uint32_t
817817
wasm_runtime_set_wasi_nn_global_ctx_loaded_i(
818-
WASINNGlobalContext * wasi_nn_global_ctx, uint32_t idx, uint32_t value);
818+
WASINNGlobalContext *wasi_nn_global_ctx, uint32_t idx, uint32_t value);
819819

820820
WASM_RUNTIME_API_EXTERN char *
821821
wasm_runtime_get_wasi_nn_global_ctx_encoding_i(
822-
WASINNGlobalContext * wasi_nn_global_ctx, uint32_t idx);
822+
WASINNGlobalContext *wasi_nn_global_ctx, uint32_t idx);
823823

824824
WASM_RUNTIME_API_EXTERN char *
825825
wasm_runtime_get_wasi_nn_global_ctx_target_i(
826-
WASINNGlobalContext * wasi_nn_global_ctx, uint32_t idx);
826+
WASINNGlobalContext *wasi_nn_global_ctx, uint32_t idx);
827827

828828
/**
829829
* Instantiate a WASM module, with specified instantiation arguments

core/iwasm/libraries/wasi-nn/src/wasi_nn.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -651,30 +651,33 @@ wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len,
651651
continue;
652652
}
653653
is_loaded = wasm_runtime_get_wasi_nn_global_ctx_loaded_i(
654-
wasi_nn_global_ctx, model_idx);
654+
wasi_nn_global_ctx, model_idx);
655655
free(model_name);
656656

657-
graph_encoding encoding = str2encoding(
658-
wasm_runtime_get_wasi_nn_global_ctx_encoding_i(wasi_nn_global_ctx, model_idx));
659-
execution_target target = str2target(
660-
wasm_runtime_get_wasi_nn_global_ctx_target_i(wasi_nn_global_ctx, model_idx));
657+
graph_encoding encoding =
658+
str2encoding(wasm_runtime_get_wasi_nn_global_ctx_encoding_i(
659+
wasi_nn_global_ctx, model_idx));
660+
execution_target target =
661+
str2target(wasm_runtime_get_wasi_nn_global_ctx_target_i(
662+
wasi_nn_global_ctx, model_idx));
661663

662664
// res = ensure_backend(instance, autodetect, wasi_nn_ctx);
663665
res = ensure_backend(instance, encoding, wasi_nn_ctx);
664666
if (res != success)
665667
goto fail;
666668

667669
if (!is_loaded && (model_idx < MAX_GLOBAL_GRAPHS_PER_INST)
668-
&& (model_idx < global_n_graphs)) {
669-
NN_DBG_PRINTF("Model is not yet loaded, will add to global context");
670+
&& (model_idx < global_n_graphs)) {
671+
NN_DBG_PRINTF(
672+
"Model is not yet loaded, will add to global context");
670673
call_wasi_nn_func(wasi_nn_ctx->backend, load_by_name, res,
671-
wasi_nn_ctx->backend_ctx, global_model_path_i,
672-
strlen(global_model_path_i), encoding, target, g);
674+
wasi_nn_ctx->backend_ctx, global_model_path_i,
675+
strlen(global_model_path_i), encoding, target, g);
673676
if (res != success)
674677
goto fail;
675678

676679
wasm_runtime_set_wasi_nn_global_ctx_loaded_i(wasi_nn_global_ctx,
677-
model_idx, 1);
680+
model_idx, 1);
678681
res = success;
679682
break;
680683
}
@@ -691,8 +694,8 @@ wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len,
691694
}
692695
else if (model_idx >= global_n_graphs) {
693696
NN_ERR_PRINTF("Model %s is not loaded, you should pass its path "
694-
"through --wasi-nn-graph",
695-
nul_terminated_name);
697+
"through --wasi-nn-graph",
698+
nul_terminated_name);
696699
res = not_found;
697700
}
698701
fail:

product-mini/platforms/common/libc_wasi.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ wasi_nn_parse(char **argv, wasi_nn_parse_context_t *ctx)
194194

195195
if (ctx->n_graphs >= sizeof(ctx->graph_paths) / sizeof(char *)) {
196196
printf("Only allow max graph number %d\n",
197-
(int)(sizeof(ctx->graph_paths) / sizeof(char *)));
197+
(int)(sizeof(ctx->graph_paths) / sizeof(char *)));
198198
return LIBC_WASI_PARSE_RESULT_BAD_PARAM;
199199
}
200200

@@ -221,7 +221,7 @@ wasi_nn_parse(char **argv, wasi_nn_parse_context_t *ctx)
221221
ctx->encoding[ctx->n_graphs] = strdup(tokens[0]);
222222
ctx->target[ctx->n_graphs] = strdup(tokens[1]);
223223
ctx->graph_paths[ctx->n_graphs++] = strdup(tokens[2]);
224-
224+
225225
fail:
226226
if (token)
227227
free(token);
@@ -230,15 +230,16 @@ wasi_nn_parse(char **argv, wasi_nn_parse_context_t *ctx)
230230
}
231231

232232
static void
233-
wasi_nn_set_init_args(struct InstantiationArgs2 *args, struct WASINNArguments *nn_registry, wasi_nn_parse_context_t *ctx)
233+
wasi_nn_set_init_args(struct InstantiationArgs2 *args,
234+
struct WASINNArguments *nn_registry,
235+
wasi_nn_parse_context_t *ctx)
234236
{
235-
wasi_nn_graph_registry_set_args(nn_registry, ctx->encoding, ctx->target, ctx->n_graphs,
236-
ctx->graph_paths);
237+
wasi_nn_graph_registry_set_args(nn_registry, ctx->encoding, ctx->target,
238+
ctx->n_graphs, ctx->graph_paths);
237239
wasm_runtime_instantiation_args_set_wasi_nn_graph_registry(args,
238240
nn_registry);
239241

240-
for (uint32_t i = 0; i < ctx->n_graphs; i++)
241-
{
242+
for (uint32_t i = 0; i < ctx->n_graphs; i++) {
242243
if (ctx->graph_paths[i])
243244
free(ctx->graph_paths[i]);
244245
if (ctx->encoding[i])

product-mini/platforms/posix/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,8 @@ main(int argc, char *argv[])
845845
wasm_proposal_print_status();
846846
return 0;
847847
}
848-
#if WASM_ENABLE_LIBC_WASI != 0 && (WASM_ENABLE_WASI_NN != 0 || WASM_ENABLE_WASI_EPHEMERAL_NN != 0)
848+
#if WASM_ENABLE_LIBC_WASI != 0 \
849+
&& (WASM_ENABLE_WASI_NN != 0 || WASM_ENABLE_WASI_EPHEMERAL_NN != 0)
849850
else if (!strncmp(argv[0], "--wasi-nn-graph=", 16)) {
850851
libc_wasi_parse_result_t result =
851852
wasi_nn_parse(argv, &wasi_nn_parse_ctx);

0 commit comments

Comments
 (0)