Skip to content

Commit 4747d61

Browse files
committed
Use clang-format-18 to format source file
1 parent 5357fb5 commit 4747d61

File tree

9 files changed

+59
-49
lines changed

9 files changed

+59
-49
lines changed

core/iwasm/common/wasm_native.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ wasm_runtime_get_wasi_nn_registry(WASMModuleInstanceCommon *module_inst_comm)
486486

487487
void
488488
wasm_runtime_set_wasi_nn_registry(WASMModuleInstanceCommon *module_inst_comm,
489-
WASINNRegistry *wasi_nn_ctx)
489+
WASINNRegistry *wasi_nn_ctx)
490490
{
491491
wasm_native_set_context(module_inst_comm, g_wasi_nn_registry_key,
492492
wasi_nn_ctx);

core/iwasm/common/wasm_runtime_common.c

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,9 +1804,11 @@ wasm_runtime_wasi_nn_graph_registry_args_set_defaults(WASINNRegistry *args)
18041804

18051805
bool
18061806
wasm_runtime_wasi_nn_registry_set_args(WASINNRegistry *registry,
1807-
const char **model_names, const uint32_t **encoding,
1808-
const uint32_t **target, uint32_t n_graphs,
1809-
const char **graph_paths)
1807+
const char **model_names,
1808+
const uint32_t **encoding,
1809+
const uint32_t **target,
1810+
uint32_t n_graphs,
1811+
const char **graph_paths)
18101812
{
18111813
if (!registry || !model_names || !encoding || !target || !graph_paths) {
18121814
return false;
@@ -1818,11 +1820,16 @@ wasm_runtime_wasi_nn_registry_set_args(WASINNRegistry *registry,
18181820
}
18191821

18201822
registry->n_graphs = n_graphs;
1821-
registry->target = (uint32_t **)wasm_runtime_malloc(sizeof(uint32_t *) * n_graphs);
1822-
registry->encoding = (uint32_t **)wasm_runtime_malloc(sizeof(uint32_t *) * n_graphs);
1823-
registry->loaded = (uint32_t **)wasm_runtime_malloc(sizeof(uint32_t *) * n_graphs);
1824-
registry->model_names = (uint32_t **)wasm_runtime_malloc(sizeof(uint32_t *) * n_graphs);
1825-
registry->graph_paths = (uint32_t **)wasm_runtime_malloc(sizeof(uint32_t *) * n_graphs);
1823+
registry->target =
1824+
(uint32_t **)wasm_runtime_malloc(sizeof(uint32_t *) * n_graphs);
1825+
registry->encoding =
1826+
(uint32_t **)wasm_runtime_malloc(sizeof(uint32_t *) * n_graphs);
1827+
registry->loaded =
1828+
(uint32_t **)wasm_runtime_malloc(sizeof(uint32_t *) * n_graphs);
1829+
registry->model_names =
1830+
(uint32_t **)wasm_runtime_malloc(sizeof(uint32_t *) * n_graphs);
1831+
registry->graph_paths =
1832+
(uint32_t **)wasm_runtime_malloc(sizeof(uint32_t *) * n_graphs);
18261833
memset(registry->target, 0, sizeof(uint32_t *) * n_graphs);
18271834
memset(registry->encoding, 0, sizeof(uint32_t *) * n_graphs);
18281835
memset(registry->loaded, 0, sizeof(uint32_t *) * n_graphs);
@@ -1858,15 +1865,15 @@ wasm_runtime_wasi_nn_registry_destroy(WASINNRegistry *registry)
18581865
for (uint32_t i = 0; i < registry->n_graphs; i++)
18591866
if (registry->graph_paths[i]) {
18601867
wasm_runtime_free(registry->graph_paths[i]);
1861-
if (registry->model_names[i])
1862-
wasm_runtime_free(registry->model_names[i]);
1868+
if (registry->model_names[i])
1869+
wasm_runtime_free(registry->model_names[i]);
18631870
}
1864-
if (registry->encoding)
1865-
wasm_runtime_free(registry->encoding);
1866-
if (registry->target)
1867-
wasm_runtime_free(registry->target);
1868-
if (registry->loaded)
1869-
wasm_runtime_free(registry->loaded);
1871+
if (registry->encoding)
1872+
wasm_runtime_free(registry->encoding);
1873+
if (registry->target)
1874+
wasm_runtime_free(registry->target);
1875+
if (registry->loaded)
1876+
wasm_runtime_free(registry->loaded);
18701877
wasm_runtime_free(registry);
18711878
}
18721879
}

core/iwasm/common/wasm_runtime_common.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -805,9 +805,11 @@ wasm_runtime_instantiation_args_set_wasi_nn_registry(
805805

806806
WASM_RUNTIME_API_EXTERN bool
807807
wasm_runtime_wasi_nn_registry_set_args(WASINNRegistry *registry,
808-
const char **model_names, const uint32_t **encoding,
809-
const uint32_t **target, uint32_t n_graphs,
810-
const char **graph_paths);
808+
const char **model_names,
809+
const uint32_t **encoding,
810+
const uint32_t **target,
811+
uint32_t n_graphs,
812+
const char **graph_paths);
811813
#endif
812814

813815
/* See wasm_export.h for description */
@@ -1465,14 +1467,14 @@ wasm_runtime_check_and_update_last_used_shared_heap(
14651467
#if WASM_ENABLE_WASI_NN != 0 || WASM_ENABLE_WASI_EPHEMERAL_NN != 0
14661468
WASM_RUNTIME_API_EXTERN void
14671469
wasm_runtime_set_wasi_nn_registry(WASMModuleInstanceCommon *module_inst,
1468-
WASINNRegistry *wasi_ctx);
1470+
WASINNRegistry *wasi_ctx);
14691471

14701472
WASM_RUNTIME_API_EXTERN WASINNRegistry *
14711473
wasm_runtime_get_wasi_nn_registry(WASMModuleInstanceCommon *module_inst_comm);
14721474

14731475
WASM_RUNTIME_API_EXTERN void
14741476
wasm_runtime_set_wasi_nn_registry(WASMModuleInstanceCommon *module_inst_comm,
1475-
WASINNRegistry *wasi_nn_ctx);
1477+
WASINNRegistry *wasi_nn_ctx);
14761478
#endif
14771479

14781480
#ifdef __cplusplus

core/iwasm/include/wasm_export.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ wasm_runtime_get_wasi_nn_registry(const wasm_module_inst_t module_inst);
802802

803803
WASM_RUNTIME_API_EXTERN void
804804
wasm_runtime_set_wasi_nn_registry(wasm_module_inst_t module_inst,
805-
struct WASINNRegistry *wasi_ctx);
805+
struct WASINNRegistry *wasi_ctx);
806806

807807
WASM_RUNTIME_API_EXTERN int
808808
wasm_runtime_wasi_nn_registry_create(struct WASINNRegistry **registryp);

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,7 @@ wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len,
578578

579579
bool is_loaded = false;
580580
uint32 model_idx = 0;
581-
uint32_t global_n_graphs =
582-
wasi_nn_registry->n_graphs;
581+
uint32_t global_n_graphs = wasi_nn_registry->n_graphs;
583582
for (model_idx = 0; model_idx < global_n_graphs; model_idx++) {
584583
char *model_name = wasi_nn_registry->model_names[model_idx];
585584

@@ -590,8 +589,10 @@ wasi_nn_load_by_name(wasm_exec_env_t exec_env, char *name, uint32_t name_len,
590589
is_loaded = wasi_nn_registry->loaded[model_idx];
591590
char *global_model_path_i = wasi_nn_registry->graph_paths[model_idx];
592591

593-
graph_encoding encoding = (graph_encoding)(wasi_nn_registry->encoding[model_idx]);
594-
execution_target target = (execution_target)(wasi_nn_registry->target[model_idx]);
592+
graph_encoding encoding =
593+
(graph_encoding)(wasi_nn_registry->encoding[model_idx]);
594+
execution_target target =
595+
(execution_target)(wasi_nn_registry->target[model_idx]);
595596

596597
// res = ensure_backend(instance, autodetect, wasi_nn_ctx);
597598
res = ensure_backend(instance, encoding, wasi_nn_ctx);

core/iwasm/libraries/wasi-nn/src/wasi_nn_backend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ load(void *ctx, graph_builder_array *builder, graph_encoding encoding,
1818

1919
__attribute__((visibility("default"))) wasi_nn_error
2020
load_by_name(void *tflite_ctx, const char *name, uint32_t namelen,
21-
execution_target target, graph *g);
21+
execution_target target, graph *g);
2222

2323
__attribute__((visibility("default"))) wasi_nn_error
2424
load_by_name_with_config(void *ctx, const char *name, uint32_t namelen,

core/iwasm/libraries/wasi-nn/test/utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ run_inference(float *input, uint32_t *input_size, uint32_t *output_size,
151151
WASI_NN_NAME(graph) graph;
152152

153153
wasi_nn_error_t res = wasm_load_by_name(model_name, &graph);
154-
154+
155155
if (res == WASI_NN_ERROR_NAME(not_found)) {
156156
NN_INFO_PRINTF("Model %s is not loaded, you should pass its path "
157157
"through --wasi-nn-graph",

core/iwasm/libraries/wasi-nn/test/utils.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,27 @@ typedef wasi_nn_error wasi_nn_error_t;
3535
/* wasi-nn wrappers */
3636

3737
wasi_nn_error_t
38-
wasm_load(char *model_name, WASI_NN_NAME(graph) *g, WASI_NN_NAME(execution_target) target);
38+
wasm_load(char *model_name, WASI_NN_NAME(graph) * g,
39+
WASI_NN_NAME(execution_target) target);
3940

40-
wasi_nn_error_t
41-
wasm_init_execution_context(WASI_NN_NAME(graph) g, WASI_NN_NAME(graph_execution_context) *ctx);
41+
wasi_nn_error_t wasm_init_execution_context(
42+
WASI_NN_NAME(graph) g, WASI_NN_NAME(graph_execution_context) * ctx);
4243

4344
wasi_nn_error_t
44-
wasm_set_input(WASI_NN_NAME(graph_execution_context) ctx, float *input_tensor, uint32_t *dim);
45+
wasm_set_input(WASI_NN_NAME(graph_execution_context) ctx, float *input_tensor,
46+
uint32_t *dim);
4547

46-
wasi_nn_error_t
47-
wasm_compute(WASI_NN_NAME(graph_execution_context) ctx);
48+
wasi_nn_error_t wasm_compute(WASI_NN_NAME(graph_execution_context) ctx);
4849

4950
wasi_nn_error_t
50-
wasm_get_output(WASI_NN_NAME(graph_execution_context) ctx, uint32_t index, float *out_tensor,
51-
uint32_t *out_size);
51+
wasm_get_output(WASI_NN_NAME(graph_execution_context) ctx, uint32_t index,
52+
float *out_tensor, uint32_t *out_size);
5253

5354
/* Utils */
5455

5556
float *
56-
run_inference(float *input, uint32_t *input_size,
57-
uint32_t *output_size, char *model_name,
58-
uint32_t num_output_tensors);
57+
run_inference(float *input, uint32_t *input_size, uint32_t *output_size,
58+
char *model_name, uint32_t num_output_tensors);
5959

6060
input_info
6161
create_input(int *dims);

product-mini/platforms/common/libc_wasi.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,13 @@ wasi_nn_parse(char **argv, wasi_nn_parse_context_t *ctx)
285285
ctx->target[ctx->n_graphs] = (uint32_t)str2target(tokens[2]);
286286
ctx->graph_paths[ctx->n_graphs] = tokens[3];
287287

288-
if ((!ctx->model_names[ctx->n_graphs]) ||
289-
(ctx->encoding[ctx->n_graphs] == wasi_nn_unknown_backend) ||
290-
(ctx->target[ctx->n_graphs] == wasi_nn_unsupported_target)) {
291-
ret = LIBC_WASI_PARSE_RESULT_NEED_HELP;
292-
printf("Invalid arguments for wasi-nn.\n");
293-
goto fail;
294-
}
288+
if ((!ctx->model_names[ctx->n_graphs])
289+
|| (ctx->encoding[ctx->n_graphs] == wasi_nn_unknown_backend)
290+
|| (ctx->target[ctx->n_graphs] == wasi_nn_unsupported_target)) {
291+
ret = LIBC_WASI_PARSE_RESULT_NEED_HELP;
292+
printf("Invalid arguments for wasi-nn.\n");
293+
goto fail;
294+
}
295295

296296
ctx->n_graphs++;
297297
fail:
@@ -305,8 +305,8 @@ wasi_nn_set_init_args(struct InstantiationArgs2 *args,
305305
wasi_nn_parse_context_t *ctx)
306306
{
307307
wasm_runtime_wasi_nn_registry_set_args(nn_registry, ctx->model_names,
308-
ctx->encoding, ctx->target, ctx->n_graphs,
309-
ctx->graph_paths);
308+
ctx->encoding, ctx->target,
309+
ctx->n_graphs, ctx->graph_paths);
310310
wasm_runtime_instantiation_args_set_wasi_nn_registry(args, nn_registry);
311311
}
312312
#endif

0 commit comments

Comments
 (0)