Skip to content

Commit c35a1af

Browse files
committed
fix wasi-nn abi definitions
sync with a more appropriate version of the definitions. as we use the "wasi_ephemeral_nn", which is p1-based, it seems more appropriate to use definitions from witx, not wit. it's a bit unfortunate p2-based wasi-nn made incompatible changes from p1.
1 parent 207da7b commit c35a1af

File tree

3 files changed

+8
-21
lines changed

3 files changed

+8
-21
lines changed

core/iwasm/libraries/wasi-nn/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ There is a big difference between the two sets of functions, `tensor_type`.
3737

3838
```c
3939
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
40-
typedef enum { fp16 = 0, fp32, fp64, bf16, u8, i32, i64 } tensor_type;
40+
typedef enum { fp16 = 0, fp32, fp64, u8, i32, i64 } tensor_type;
4141
#else
4242
typedef enum { fp16 = 0, fp32, up8, ip32 } tensor_type;
4343
#endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */

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

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,19 @@ extern "C" {
1919
*/
2020

2121
// sync up with
22-
// https://github.com/WebAssembly/wasi-nn/blob/main/wit/wasi-nn.wit#L136 Error
23-
// codes returned by functions in this API.
22+
// https://github.com/WebAssembly/wasi-nn/blob/71320d95b8c6d43f9af7f44e18b1839db85d89b4/wasi-nn.witx#L5-L17
23+
// Error codes returned by functions in this API.
2424
typedef enum {
25-
// No error occurred.
2625
success = 0,
27-
// Caller module passed an invalid argument.
2826
invalid_argument,
29-
// Invalid encoding.
3027
invalid_encoding,
31-
// The operation timed out.
32-
timeout,
33-
// Runtime Error.
28+
missing_memory,
29+
busy,
3430
runtime_error,
35-
// Unsupported operation.
3631
unsupported_operation,
37-
// Graph is too large.
3832
too_large,
39-
// Graph not found.
4033
not_found,
41-
// The operation is insecure or has insufficient privilege to be performed.
42-
// e.g., cannot access a hardware feature requested
43-
security,
44-
// The operation failed for an unspecified reason.
45-
unknown,
34+
4635
// for WasmEdge-wasi-nn
4736
end_of_sequence = 100, // End of Sequence Found.
4837
context_full = 101, // Context Full.
@@ -66,9 +55,9 @@ typedef struct {
6655

6756
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
6857
// sync up with
69-
// https://github.com/WebAssembly/wasi-nn/blob/main/wit/wasi-nn.wit#L27
58+
// https://github.com/WebAssembly/wasi-nn/blob/71320d95b8c6d43f9af7f44e18b1839db85d89b4/wasi-nn.witx#L19-L28
7059
// The type of the elements in a tensor.
71-
typedef enum { fp16 = 0, fp32, fp64, bf16, u8, i32, i64 } tensor_type;
60+
typedef enum { fp16 = 0, fp32, fp64, u8, i32, i64 } tensor_type;
7261
#else
7362
typedef enum { fp16 = 0, fp32, up8, ip32 } tensor_type;
7463
#endif /* WASM_ENABLE_WASI_EPHEMERAL_NN != 0 */

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ wasi_nn_tensor_type_to_openvino_element_type(tensor_type wasi_nn_type)
161161
#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
162162
case fp64:
163163
return F64;
164-
case bf16:
165-
return BF16;
166164
case i64:
167165
return I64;
168166
case u8:

0 commit comments

Comments
 (0)