|
| 1 | +;; This WITX version of the wasi-nn API is retained for consistency only. See the `wasi-nn.wit.md` |
| 2 | +;; version for the official specification and documentation. |
| 3 | + |
| 4 | +(typename $buffer_size u32) |
| 5 | +(typename $nn_errno |
| 6 | + (enum (@witx tag u16) |
| 7 | + $success |
| 8 | + $invalid_argument |
| 9 | + $invalid_encoding |
| 10 | + $missing_memory |
| 11 | + $busy |
| 12 | + $runtime_error |
| 13 | + ) |
| 14 | +) |
| 15 | +(typename $tensor_dimensions (list u32)) |
| 16 | +(typename $tensor_type |
| 17 | + (enum (@witx tag u8) |
| 18 | + $f16 |
| 19 | + $f32 |
| 20 | + $u8 |
| 21 | + $i32 |
| 22 | + ) |
| 23 | +) |
| 24 | +(typename $tensor_data (list u8)) |
| 25 | +(typename $tensor |
| 26 | + (record |
| 27 | + (field $dimensions $tensor_dimensions) |
| 28 | + (field $type $tensor_type) |
| 29 | + (field $data $tensor_data) |
| 30 | + ) |
| 31 | +) |
| 32 | +(typename $graph_builder (list u8)) |
| 33 | +(typename $graph_builder_array (list $graph_builder)) |
| 34 | +(typename $graph (handle)) |
| 35 | +(typename $graph_encoding |
| 36 | + (enum (@witx tag u8) |
| 37 | + $openvino |
| 38 | + $onnx |
| 39 | + $tensorflow |
| 40 | + $pytorch |
| 41 | + ) |
| 42 | +) |
| 43 | +(typename $execution_target |
| 44 | + (enum (@witx tag u8) |
| 45 | + $cpu |
| 46 | + $gpu |
| 47 | + $tpu |
| 48 | + ) |
| 49 | +) |
| 50 | +(typename $graph_execution_context (handle)) |
| 51 | + |
| 52 | +(module $wasi_ephemeral_nn |
| 53 | + (import "memory" (memory)) |
| 54 | + (@interface func (export "load") |
| 55 | + (param $builder $graph_builder_array) |
| 56 | + (param $encoding $graph_encoding) |
| 57 | + (param $target $execution_target) |
| 58 | + (result $error (expected $graph (error $nn_errno))) |
| 59 | + ) |
| 60 | + (@interface func (export "init_execution_context") |
| 61 | + (param $graph $graph) |
| 62 | + (result $error (expected $graph_execution_context (error $nn_errno))) |
| 63 | + ) |
| 64 | + (@interface func (export "set_input") |
| 65 | + (param $context $graph_execution_context) |
| 66 | + (param $index u32) |
| 67 | + (param $tensor $tensor) |
| 68 | + (result $error (expected (error $nn_errno))) |
| 69 | + ) |
| 70 | + (@interface func (export "get_output") |
| 71 | + (param $context $graph_execution_context) |
| 72 | + (param $index u32) |
| 73 | + (param $out_buffer (@witx pointer u8)) |
| 74 | + (param $out_buffer_max_size $buffer_size) |
| 75 | + (result $error (expected $buffer_size (error $nn_errno))) |
| 76 | + ) |
| 77 | + (@interface func (export "compute") |
| 78 | + (param $context $graph_execution_context) |
| 79 | + (result $error (expected (error $nn_errno))) |
| 80 | + ) |
| 81 | +) |
| 82 | + |
0 commit comments