Skip to content

Commit d040489

Browse files
authored
Switch to wit-abi v0.2.0 (#18)
In WebAssembly/wit-abi-up-to-date#4 and WebAssembly/wasi-tools#4, the `wit-abi` tool was updated to include the new syntax. This changes what syntax we can use: in particular, `unit` instead of `_`. The generated `abi.md` file now looks differently, with slightly different names and no more included documentation.
1 parent 2b4ae11 commit d040489

File tree

3 files changed

+22
-58
lines changed

3 files changed

+22
-58
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v2
14-
- uses: WebAssembly/wit-abi-up-to-date@v3
14+
- uses: WebAssembly/wit-abi-up-to-date@v4
1515
with:
16-
wit-abi-tag: wit-abi-0.1.0
16+
wit-abi-tag: wit-abi-0.2.0

wasi-nn.abi.md

Lines changed: 18 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,15 @@
22

33
## <a href="#tensor_dimensions" name="tensor_dimensions"></a> `tensor-dimensions`: list<`u32`>
44

5-
The dimensions of a tensor.
6-
7-
The array length matches the tensor rank and each element in the array
8-
describes the size of each dimension.
95

106
Size: 8, Alignment: 4
117

12-
## <a href="#tensor_type" name="tensor_type"></a> `tensor-type`: variant
8+
## <a href="#tensor_type" name="tensor_type"></a> `tensor-type`: enum
139

14-
The type of the elements in a tensor.
1510

1611
Size: 1, Alignment: 1
1712

18-
### Variant Cases
13+
### Enum Cases
1914

2015
- <a href="tensor_type.fp16" name="tensor_type.fp16"></a> [`fp16`](#tensor_type.fp16)
2116

@@ -31,43 +26,27 @@ Size: 1, Alignment: 1
3126

3227
## <a href="#tensor_data" name="tensor_data"></a> `tensor-data`: list<`u8`>
3328

34-
The tensor data.
35-
36-
Initially coneived as a sparse representation, each empty cell would be filled with zeros and
37-
the array length must match the product of all of the dimensions and the number of bytes in the
38-
type (e.g., a 2x2 tensor with 4-byte f32 elements would have a data array of length 16).
39-
Naturally, this representation requires some knowledge of how to lay out data in memory--e.g.,
40-
using row-major ordering--and could perhaps be improved.
4129

4230
Size: 8, Alignment: 4
4331

4432
## <a href="#tensor" name="tensor"></a> `tensor`: record
4533

46-
A tensor.
4734

4835
Size: 20, Alignment: 4
4936

5037
### Record Fields
5138

5239
- <a href="tensor.dimensions" name="tensor.dimensions"></a> [`dimensions`](#tensor.dimensions): [`tensor-dimensions`](#tensor_dimensions)
5340

54-
Describe the size of the tensor (e.g., 2x2x2x2 -> [2, 2, 2, 2]). To represent a tensor
55-
containing a single value, use `[1]` for the tensor dimensions.
5641

5742
- <a href="tensor.tensor_type" name="tensor.tensor_type"></a> [`tensor-type`](#tensor.tensor_type): [`tensor-type`](#tensor_type)
5843

59-
Describe the type of element in the tensor (e.g., f32).
6044

6145
- <a href="tensor.data" name="tensor.data"></a> [`data`](#tensor.data): [`tensor-data`](#tensor_data)
6246

63-
Contains the tensor data.
6447

6548
## <a href="#graph_builder" name="graph_builder"></a> `graph-builder`: list<`u8`>
6649

67-
The graph initialization data.
68-
69-
This consists of an array of buffers because implementing backends may encode their graph IR in
70-
parts (e.g., OpenVINO stores its IR and weights separately).
7150

7251
Size: 8, Alignment: 4
7352

@@ -76,14 +55,12 @@ Size: 8, Alignment: 4
7655

7756
Size: 8, Alignment: 4
7857

79-
## <a href="#graph_encoding" name="graph_encoding"></a> `graph-encoding`: variant
58+
## <a href="#graph_encoding" name="graph_encoding"></a> `graph-encoding`: enum
8059

81-
Describes the encoding of the graph. This allows the API to be implemented by various backends
82-
that encode (i.e., serialize) their graph IR with different formats.
8360

8461
Size: 1, Alignment: 1
8562

86-
### Variant Cases
63+
### Enum Cases
8764

8865
- <a href="graph_encoding.openvino" name="graph_encoding.openvino"></a> [`openvino`](#graph_encoding.openvino)
8966

@@ -94,13 +71,12 @@ Size: 1, Alignment: 1
9471
- <a href="graph_encoding.tensorflow" name="graph_encoding.tensorflow"></a> [`tensorflow`](#graph_encoding.tensorflow)
9572

9673

97-
## <a href="#execution_target" name="execution_target"></a> `execution-target`: variant
74+
## <a href="#execution_target" name="execution_target"></a> `execution-target`: enum
9875

99-
Define where the graph should be executed.
10076

10177
Size: 1, Alignment: 1
10278

103-
### Variant Cases
79+
### Enum Cases
10480

10581
- <a href="execution_target.cpu" name="execution_target.cpu"></a> [`cpu`](#execution_target.cpu)
10682

@@ -111,102 +87,90 @@ Size: 1, Alignment: 1
11187
- <a href="execution_target.tpu" name="execution_target.tpu"></a> [`tpu`](#execution_target.tpu)
11288

11389

114-
## <a href="#error" name="error"></a> `error`: variant
90+
## <a href="#error" name="error"></a> `error`: enum
11591

116-
Error codes returned by functions in this API.
11792

11893
Size: 1, Alignment: 1
11994

120-
### Variant Cases
95+
### Enum Cases
12196

12297
- <a href="error.success" name="error.success"></a> [`success`](#error.success)
12398

124-
No error occurred.
12599

126100
- <a href="error.invalid_argument" name="error.invalid_argument"></a> [`invalid-argument`](#error.invalid_argument)
127101

128-
Caller module passed an invalid argument.
129102

130103
- <a href="error.invalid_encoding" name="error.invalid_encoding"></a> [`invalid-encoding`](#error.invalid_encoding)
131104

132-
Invalid encocing.
133105

134106
- <a href="error.missing_memory" name="error.missing_memory"></a> [`missing-memory`](#error.missing_memory)
135107

136-
Caller module is missing a memory export.
137108

138109
- <a href="error.busy" name="error.busy"></a> [`busy`](#error.busy)
139110

140-
Device or resource busy.
141111

142112
- <a href="error.runtime_error" name="error.runtime_error"></a> [`runtime-error`](#error.runtime_error)
143113

144-
Runtime Error.
145114

146115
# Functions
147116

148117
----
149118

150119
#### <a href="#load" name="load"></a> `load`
151120

152-
Load an opaque sequence of bytes to use for inference.
153121
##### Params
154122

155123
- <a href="#load.builder" name="load.builder"></a> `builder`: [`graph-builder-array`](#graph_builder_array)
156124
- <a href="#load.encoding" name="load.encoding"></a> `encoding`: [`graph-encoding`](#graph_encoding)
157125
- <a href="#load.target" name="load.target"></a> `target`: [`execution-target`](#execution_target)
158-
##### Results
126+
##### Result
159127

160-
- <a href="#load." name="load."></a> ``: expected<handle<graph>, [`error`](#error)>
128+
- expected<handle<graph>, [`error`](#error)>
161129

162130
----
163131

164132
#### <a href="#init_execution_context" name="init_execution_context"></a> `init-execution-context`
165133

166-
Create an execution instance of a loaded graph.
167134
##### Params
168135

169136
- <a href="#init_execution_context.graph" name="init_execution_context.graph"></a> `graph`: handle<graph>
170-
##### Results
137+
##### Result
171138

172-
- <a href="#init_execution_context." name="init_execution_context."></a> ``: expected<handle<graph-execution-context>, [`error`](#error)>
139+
- expected<handle<graph-execution-context>, [`error`](#error)>
173140

174141
----
175142

176143
#### <a href="#set_input" name="set_input"></a> `set-input`
177144

178-
Define the inputs to use for inference.
179145
##### Params
180146

181147
- <a href="#set_input.ctx" name="set_input.ctx"></a> `ctx`: handle<graph-execution-context>
182148
- <a href="#set_input.index" name="set_input.index"></a> `index`: `u32`
183149
- <a href="#set_input.tensor" name="set_input.tensor"></a> `tensor`: [`tensor`](#tensor)
184-
##### Results
150+
##### Result
185151

186-
- <a href="#set_input." name="set_input."></a> ``: expected<_, [`error`](#error)>
152+
- expected<`unit`, [`error`](#error)>
187153

188154
----
189155

190156
#### <a href="#compute" name="compute"></a> `compute`
191157

192-
Compute the inference on the given inputs.
193158
##### Params
194159

195160
- <a href="#compute.ctx" name="compute.ctx"></a> `ctx`: handle<graph-execution-context>
196-
##### Results
161+
##### Result
197162

198-
- <a href="#compute." name="compute."></a> ``: expected<_, [`error`](#error)>
163+
- expected<`unit`, [`error`](#error)>
199164

200165
----
201166

202167
#### <a href="#get_output" name="get_output"></a> `get-output`
203168

204-
Extract the outputs after inference.
205169
##### Params
206170

207171
- <a href="#get_output.ctx" name="get_output.ctx"></a> `ctx`: handle<graph-execution-context>
208172
- <a href="#get_output.index" name="get_output.index"></a> `index`: `u32`
209-
##### Results
173+
##### Result
210174

211-
- <a href="#get_output." name="get_output."></a> ``: expected<[`tensor`](#tensor), [`error`](#error)>
175+
- expected<[`tensor`](#tensor), [`error`](#error)>
212176

wasi-nn.wit.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ index:
107107

108108
```wit
109109
// Define the inputs to use for inference.
110-
set-input: function(ctx: graph-execution-context, index: u32, tensor: tensor) -> expected<_, error>
110+
set-input: function(ctx: graph-execution-context, index: u32, tensor: tensor) -> expected<unit, error>
111111
112112
// Compute the inference on the given inputs.
113-
compute: function(ctx: graph-execution-context) -> expected<_, error>
113+
compute: function(ctx: graph-execution-context) -> expected<unit, error>
114114
115115
// Extract the outputs after inference.
116116
get-output: function(ctx: graph-execution-context, index: u32) -> expected<tensor, error>

0 commit comments

Comments
 (0)