Skip to content

File tree

1 file changed

+9
-7
lines changed
  • core/iwasm/libraries/wasi-nn/include

1 file changed

+9
-7
lines changed

core/iwasm/libraries/wasi-nn/include/wasi_nn.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#include <stdint.h>
1616
#include "wasi_nn_types.h"
1717

18+
#define WASI_NN_IMPORT(name) \
19+
__attribute__((import_module("wasi_nn"), import_name(name)))
20+
1821
/**
1922
* @brief Load an opaque sequence of bytes to use for inference.
2023
*
@@ -26,12 +29,11 @@
2629
*/
2730
wasi_nn_error
2831
load(graph_builder_array *builder, graph_encoding encoding,
29-
execution_target target, graph *g)
30-
__attribute__((import_module("wasi_nn")));
32+
execution_target target, graph *g) WASI_NN_IMPORT("load");
3133

3234
wasi_nn_error
3335
load_by_name(const char *name, uint32_t name_len, graph *g)
34-
__attribute__((import_module("wasi_nn")));
36+
WASI_NN_IMPORT("load_by_name");
3537

3638
/**
3739
* INFERENCE
@@ -47,7 +49,7 @@ load_by_name(const char *name, uint32_t name_len, graph *g)
4749
*/
4850
wasi_nn_error
4951
init_execution_context(graph g, graph_execution_context *ctx)
50-
__attribute__((import_module("wasi_nn")));
52+
WASI_NN_IMPORT("init_execution_context");
5153

5254
/**
5355
* @brief Define the inputs to use for inference.
@@ -59,7 +61,7 @@ init_execution_context(graph g, graph_execution_context *ctx)
5961
*/
6062
wasi_nn_error
6163
set_input(graph_execution_context ctx, uint32_t index, tensor *tensor)
62-
__attribute__((import_module("wasi_nn")));
64+
WASI_NN_IMPORT("set_input");
6365

6466
/**
6567
* @brief Compute the inference on the given inputs.
@@ -68,7 +70,7 @@ set_input(graph_execution_context ctx, uint32_t index, tensor *tensor)
6870
* @return wasi_nn_error Execution status.
6971
*/
7072
wasi_nn_error
71-
compute(graph_execution_context ctx) __attribute__((import_module("wasi_nn")));
73+
compute(graph_execution_context ctx) WASI_NN_IMPORT("compute");
7274

7375
/**
7476
* @brief Extract the outputs after inference.
@@ -85,6 +87,6 @@ compute(graph_execution_context ctx) __attribute__((import_module("wasi_nn")));
8587
wasi_nn_error
8688
get_output(graph_execution_context ctx, uint32_t index,
8789
tensor_data output_tensor, uint32_t *output_tensor_size)
88-
__attribute__((import_module("wasi_nn")));
90+
WASI_NN_IMPORT("get_output");
8991

9092
#endif

0 commit comments

Comments
 (0)