2
2
3
3
## <a href =" #tensor_dimensions " name =" tensor_dimensions " ></a > ` tensor-dimensions ` : list<` u32 ` >
4
4
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.
9
5
10
6
Size: 8, Alignment: 4
11
7
12
- ## <a href =" #tensor_type " name =" tensor_type " ></a > ` tensor-type ` : variant
8
+ ## <a href =" #tensor_type " name =" tensor_type " ></a > ` tensor-type ` : enum
13
9
14
- The type of the elements in a tensor.
15
10
16
11
Size: 1, Alignment: 1
17
12
18
- ### Variant Cases
13
+ ### Enum Cases
19
14
20
15
- <a href =" tensor_type.fp16 " name =" tensor_type.fp16 " ></a > [ ` fp16 ` ] ( #tensor_type.fp16 )
21
16
@@ -31,43 +26,27 @@ Size: 1, Alignment: 1
31
26
32
27
## <a href =" #tensor_data " name =" tensor_data " ></a > ` tensor-data ` : list<` u8 ` >
33
28
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.
41
29
42
30
Size: 8, Alignment: 4
43
31
44
32
## <a href =" #tensor " name =" tensor " ></a > ` tensor ` : record
45
33
46
- A tensor.
47
34
48
35
Size: 20, Alignment: 4
49
36
50
37
### Record Fields
51
38
52
39
- <a href =" tensor.dimensions " name =" tensor.dimensions " ></a > [ ` dimensions ` ] ( #tensor.dimensions ) : [ ` tensor-dimensions ` ] ( #tensor_dimensions )
53
40
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.
56
41
57
42
- <a href =" tensor.tensor_type " name =" tensor.tensor_type " ></a > [ ` tensor-type ` ] ( #tensor.tensor_type ) : [ ` tensor-type ` ] ( #tensor_type )
58
43
59
- Describe the type of element in the tensor (e.g., f32).
60
44
61
45
- <a href =" tensor.data " name =" tensor.data " ></a > [ ` data ` ] ( #tensor.data ) : [ ` tensor-data ` ] ( #tensor_data )
62
46
63
- Contains the tensor data.
64
47
65
48
## <a href =" #graph_builder " name =" graph_builder " ></a > ` graph-builder ` : list<` u8 ` >
66
49
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).
71
50
72
51
Size: 8, Alignment: 4
73
52
@@ -76,14 +55,12 @@ Size: 8, Alignment: 4
76
55
77
56
Size: 8, Alignment: 4
78
57
79
- ## <a href =" #graph_encoding " name =" graph_encoding " ></a > ` graph-encoding ` : variant
58
+ ## <a href =" #graph_encoding " name =" graph_encoding " ></a > ` graph-encoding ` : enum
80
59
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.
83
60
84
61
Size: 1, Alignment: 1
85
62
86
- ### Variant Cases
63
+ ### Enum Cases
87
64
88
65
- <a href =" graph_encoding.openvino " name =" graph_encoding.openvino " ></a > [ ` openvino ` ] ( #graph_encoding.openvino )
89
66
@@ -94,13 +71,12 @@ Size: 1, Alignment: 1
94
71
- <a href =" graph_encoding.tensorflow " name =" graph_encoding.tensorflow " ></a > [ ` tensorflow ` ] ( #graph_encoding.tensorflow )
95
72
96
73
97
- ## <a href =" #execution_target " name =" execution_target " ></a > ` execution-target ` : variant
74
+ ## <a href =" #execution_target " name =" execution_target " ></a > ` execution-target ` : enum
98
75
99
- Define where the graph should be executed.
100
76
101
77
Size: 1, Alignment: 1
102
78
103
- ### Variant Cases
79
+ ### Enum Cases
104
80
105
81
- <a href =" execution_target.cpu " name =" execution_target.cpu " ></a > [ ` cpu ` ] ( #execution_target.cpu )
106
82
@@ -111,102 +87,90 @@ Size: 1, Alignment: 1
111
87
- <a href =" execution_target.tpu " name =" execution_target.tpu " ></a > [ ` tpu ` ] ( #execution_target.tpu )
112
88
113
89
114
- ## <a href =" #error " name =" error " ></a > ` error ` : variant
90
+ ## <a href =" #error " name =" error " ></a > ` error ` : enum
115
91
116
- Error codes returned by functions in this API.
117
92
118
93
Size: 1, Alignment: 1
119
94
120
- ### Variant Cases
95
+ ### Enum Cases
121
96
122
97
- <a href =" error.success " name =" error.success " ></a > [ ` success ` ] ( #error.success )
123
98
124
- No error occurred.
125
99
126
100
- <a href =" error.invalid_argument " name =" error.invalid_argument " ></a > [ ` invalid-argument ` ] ( #error.invalid_argument )
127
101
128
- Caller module passed an invalid argument.
129
102
130
103
- <a href =" error.invalid_encoding " name =" error.invalid_encoding " ></a > [ ` invalid-encoding ` ] ( #error.invalid_encoding )
131
104
132
- Invalid encocing.
133
105
134
106
- <a href =" error.missing_memory " name =" error.missing_memory " ></a > [ ` missing-memory ` ] ( #error.missing_memory )
135
107
136
- Caller module is missing a memory export.
137
108
138
109
- <a href =" error.busy " name =" error.busy " ></a > [ ` busy ` ] ( #error.busy )
139
110
140
- Device or resource busy.
141
111
142
112
- <a href =" error.runtime_error " name =" error.runtime_error " ></a > [ ` runtime-error ` ] ( #error.runtime_error )
143
113
144
- Runtime Error.
145
114
146
115
# Functions
147
116
148
117
----
149
118
150
119
#### <a href =" #load " name =" load " ></a > ` load `
151
120
152
- Load an opaque sequence of bytes to use for inference.
153
121
##### Params
154
122
155
123
- <a href =" #load.builder " name =" load.builder " ></a > ` builder ` : [ ` graph-builder-array ` ] ( #graph_builder_array )
156
124
- <a href =" #load.encoding " name =" load.encoding " ></a > ` encoding ` : [ ` graph-encoding ` ] ( #graph_encoding )
157
125
- <a href =" #load.target " name =" load.target " ></a > ` target ` : [ ` execution-target ` ] ( #execution_target )
158
- ##### Results
126
+ ##### Result
159
127
160
- - < a href = " #load. " name = " load. " ></ a > ``: expected<handle<graph >, [ ` error ` ] ( #error ) >
128
+ - expected<handle<graph >, [ ` error ` ] ( #error ) >
161
129
162
130
----
163
131
164
132
#### <a href =" #init_execution_context " name =" init_execution_context " ></a > ` init-execution-context `
165
133
166
- Create an execution instance of a loaded graph.
167
134
##### Params
168
135
169
136
- <a href =" #init_execution_context.graph " name =" init_execution_context.graph " ></a > ` graph ` : handle<graph >
170
- ##### Results
137
+ ##### Result
171
138
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 ) >
173
140
174
141
----
175
142
176
143
#### <a href =" #set_input " name =" set_input " ></a > ` set-input `
177
144
178
- Define the inputs to use for inference.
179
145
##### Params
180
146
181
147
- <a href =" #set_input.ctx " name =" set_input.ctx " ></a > ` ctx ` : handle<graph-execution-context >
182
148
- <a href =" #set_input.index " name =" set_input.index " ></a > ` index ` : ` u32 `
183
149
- <a href =" #set_input.tensor " name =" set_input.tensor " ></a > ` tensor ` : [ ` tensor ` ] ( #tensor )
184
- ##### Results
150
+ ##### Result
185
151
186
- - < a href = " #set_input. " name = " set_input. " ></ a > ``: expected< _ , [ ` error ` ] ( #error ) >
152
+ - expected< ` unit ` , [ ` error ` ] ( #error ) >
187
153
188
154
----
189
155
190
156
#### <a href =" #compute " name =" compute " ></a > ` compute `
191
157
192
- Compute the inference on the given inputs.
193
158
##### Params
194
159
195
160
- <a href =" #compute.ctx " name =" compute.ctx " ></a > ` ctx ` : handle<graph-execution-context >
196
- ##### Results
161
+ ##### Result
197
162
198
- - < a href = " #compute. " name = " compute. " ></ a > ``: expected< _ , [ ` error ` ] ( #error ) >
163
+ - expected< ` unit ` , [ ` error ` ] ( #error ) >
199
164
200
165
----
201
166
202
167
#### <a href =" #get_output " name =" get_output " ></a > ` get-output `
203
168
204
- Extract the outputs after inference.
205
169
##### Params
206
170
207
171
- <a href =" #get_output.ctx " name =" get_output.ctx " ></a > ` ctx ` : handle<graph-execution-context >
208
172
- <a href =" #get_output.index " name =" get_output.index " ></a > ` index ` : ` u32 `
209
- ##### Results
173
+ ##### Result
210
174
211
- - < a href = " #get_output. " name = " get_output. " ></ a > ``: expected<[ ` tensor ` ] ( #tensor ) , [ ` error ` ] ( #error ) >
175
+ - expected<[ ` tensor ` ] ( #tensor ) , [ ` error ` ] ( #error ) >
212
176
0 commit comments