|
15 | 15 | #include <stdint.h>
|
16 | 16 | #include "wasi_nn_types.h"
|
17 | 17 |
|
| 18 | +#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 |
| 19 | +#define WASI_NN_IMPORT(name) \ |
| 20 | + __attribute__((import_module("wasi_ephemeral_nn"), import_name(name))) |
| 21 | +#else |
18 | 22 | #define WASI_NN_IMPORT(name) \
|
19 | 23 | __attribute__((import_module("wasi_nn"), import_name(name)))
|
| 24 | +#endif |
20 | 25 |
|
21 | 26 | /**
|
22 | 27 | * @brief Load an opaque sequence of bytes to use for inference.
|
23 | 28 | *
|
24 | 29 | * @param builder Model builder.
|
| 30 | + * @param builder_len The size of model builder. |
25 | 31 | * @param encoding Model encoding.
|
26 | 32 | * @param target Execution target.
|
27 | 33 | * @param g Graph.
|
28 | 34 | * @return wasi_nn_error Execution status.
|
29 | 35 | */
|
| 36 | +#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 |
| 37 | +wasi_nn_error |
| 38 | +load(graph_builder *builder, uint32_t builder_len, graph_encoding encoding, |
| 39 | + execution_target target, graph *g) WASI_NN_IMPORT("load"); |
| 40 | +#else |
30 | 41 | wasi_nn_error
|
31 | 42 | load(graph_builder_array *builder, graph_encoding encoding,
|
32 | 43 | execution_target target, graph *g) WASI_NN_IMPORT("load");
|
| 44 | +#endif |
33 | 45 |
|
34 | 46 | wasi_nn_error
|
35 | 47 | load_by_name(const char *name, uint32_t name_len, graph *g)
|
@@ -84,9 +96,16 @@ compute(graph_execution_context ctx) WASI_NN_IMPORT("compute");
|
84 | 96 | * copied number of bytes.
|
85 | 97 | * @return wasi_nn_error Execution status.
|
86 | 98 | */
|
| 99 | +#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0 |
| 100 | +wasi_nn_error |
| 101 | +get_output(graph_execution_context ctx, uint32_t index, |
| 102 | + tensor_data output_tensor, uint32_t output_tensor_max_size, |
| 103 | + uint32_t *output_tensor_size) WASI_NN_IMPORT("get_output"); |
| 104 | +#else |
87 | 105 | wasi_nn_error
|
88 | 106 | get_output(graph_execution_context ctx, uint32_t index,
|
89 | 107 | tensor_data output_tensor, uint32_t *output_tensor_size)
|
90 | 108 | WASI_NN_IMPORT("get_output");
|
| 109 | +#endif |
91 | 110 |
|
92 | 111 | #endif
|
0 commit comments