/
ort.fbs
325 lines (266 loc) · 6.07 KB
/
ort.fbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
namespace onnxruntime.fbs;
// Attribute
enum AttributeType : int32 {
UNDEFINED = 0,
FLOAT = 1,
INT = 2,
STRING = 3,
TENSOR = 4,
GRAPH = 5,
FLOATS = 6,
INTS = 7,
STRINGS = 8,
TENSORS = 9,
GRAPHS = 10,
SPARSE_TENSOR = 11,
SPARSE_TENSORS = 12,
}
// Shape
table Shape {
dim:[Dimension];
}
table Dimension {
value:DimensionValue;
denotation:string;
}
enum DimensionValueType : int8 {
UNKNOWN = 0,
VALUE = 1,
PARAM = 2,
}
table DimensionValue {
dim_type:DimensionValueType;
dim_value:int64;
dim_param:string;
}
// Tensor
enum TensorDataType : int32 {
UNDEFINED = 0,
FLOAT = 1,
UINT8 = 2,
INT8 = 3,
UINT16 = 4,
INT16 = 5,
INT32 = 6,
INT64 = 7,
STRING = 8,
BOOL = 9,
FLOAT16 = 10,
DOUBLE = 11,
UINT32 = 12,
UINT64 = 13,
COMPLEX64 = 14,
COMPLEX128 = 15,
BFLOAT16 = 16,
// Float 8 types. See https://onnx.ai/onnx/technical/float8.html.
FLOAT8E4M3FN = 17,
FLOAT8E4M3FNUZ = 18,
FLOAT8E5M2 = 19,
FLOAT8E5M2FNUZ = 20,
}
table TensorTypeAndShape {
elem_type:TensorDataType;
shape:Shape;
}
table MapType {
key_type:TensorDataType;
value_type:TypeInfo;
}
table SequenceType {
elem_type:TypeInfo;
}
// Node
enum NodeType : int32 {
Primitive = 0,
Fused = 1,
}
struct EdgeEnd {
node_index:uint32;
src_arg_index:int32;
dst_arg_index:int32;
}
table NodeEdge {
node_index:uint32;
input_edges:[EdgeEnd];
output_edges:[EdgeEnd];
}
table Node {
name:string;
doc_string:string;
domain:string;
since_version:int32;
index:uint32;
op_type:string;
type:NodeType;
execution_provider_type:string;
inputs:[string];
outputs:[string];
attributes:[Attribute];
input_arg_counts:[int32];
implicit_inputs:[string];
}
// ValueInfo
table ValueInfo {
name:string;
doc_string:string;
type:TypeInfo;
}
// TODO add support of SparseTensor, Opaque if needed
union TypeInfoValue {
tensor_type:TensorTypeAndShape,
sequence_type:SequenceType,
map_type:MapType,
}
table TypeInfo {
denotation:string;
value:TypeInfoValue;
}
// OpSetId
table OperatorSetId {
domain:string;
version:int64;
}
// For simplicity, we will have only two data fields
// - string_data for string
// - raw_data for all other types
table Tensor {
name:string;
doc_string:string;
dims:[int64];
data_type:TensorDataType;
raw_data:[uint8];
// string_data is least used
string_data:[string];
// offset into external data file to allow data >2GB to be handled. not used for string data.
// an external file writer/reader needs to be provided when serializing.
// int64 (vs uint64) so we can explicitly set to -1 when not used.
external_data_offset:int64 = -1;
}
table SparseTensor {
values:Tensor;
indices:Tensor;
dims:[int64];
}
table Attribute {
name:string;
doc_string:string;
type:AttributeType;
f:float32;
i:int64;
s:string;
t:Tensor;
g:Graph;
floats:[float32];
ints:[int64];
strings:[string];
tensors:[Tensor];
graphs:[Graph];
}
// runtime optimizations
/// nodes to consider for a runtime optimization
/// see corresponding type in onnxruntime/core/graph/runtime_optimization_record.h
table NodesToOptimizeIndices {
node_indices:[uint32];
num_inputs:uint32;
num_outputs:uint32;
has_variadic_input:bool;
has_variadic_output:bool;
num_variadic_inputs:uint32;
num_variadic_outputs:uint32;
}
/// deprecated: no longer using kernel def hashes
table DeprecatedNodeIndexAndKernelDefHash {
node_index:uint32;
kernel_def_hash:uint64;
}
/// a single runtime optimization
/// see corresponding type in onnxruntime/core/graph/runtime_optimization_record.h
table RuntimeOptimizationRecord {
action_id:string;
nodes_to_optimize_indices:NodesToOptimizeIndices;
produced_nodes:[DeprecatedNodeIndexAndKernelDefHash] (deprecated);
produced_op_ids:[string];
}
table RuntimeOptimizationRecordContainerEntry {
optimizer_name:string (key);
runtime_optimization_records:[RuntimeOptimizationRecord];
}
table RuntimeOptimizations {
/// mapping from optimizer name to [RuntimeOptimizationRecord]
records:[RuntimeOptimizationRecordContainerEntry];
}
table Graph {
initializers:[Tensor];
node_args:[ValueInfo];
nodes:[Node];
max_node_index:uint32;
node_edges:[NodeEdge];
inputs:[string];
outputs:[string];
sparse_initializers:[SparseTensor];
runtime_optimizations:RuntimeOptimizations;
}
table StringStringEntry {
key:string;
value:string;
}
table Model {
ir_version:int64;
opset_import:[OperatorSetId];
producer_name:string;
producer_version:string;
domain:string;
model_version:int64;
doc_string:string;
graph:Graph;
graph_doc_string:string;
metadata_props:[StringStringEntry];
}
/// deprecated: no longer using kernel def hashes
table DeprecatedKernelCreateInfos {
node_indices:[uint32];
kernel_def_hashes:[uint64];
}
/// deprecated: no longer using kernel def hashes
table DeprecatedSubGraphSessionState {
// graph_id can be used to binary search DeprecatedSubGraphSessionState in
// DeprecatedSessionState.sub_graph_session_states
graph_id:string (key);
session_state:DeprecatedSessionState;
}
/// deprecated: no longer using kernel def hashes
table DeprecatedSessionState {
kernels:DeprecatedKernelCreateInfos;
sub_graph_session_states:[DeprecatedSubGraphSessionState];
}
enum ArgType : int8 {
INPUT = 0,
OUTPUT = 1,
}
table ArgTypeAndIndex {
arg_type:ArgType;
index:uint32;
}
table KernelTypeStrArgsEntry {
kernel_type_str:string (key);
args:[ArgTypeAndIndex];
}
table OpIdKernelTypeStrArgsEntry {
op_id:string (key);
kernel_type_str_args:[KernelTypeStrArgsEntry];
}
table KernelTypeStrResolver {
op_kernel_type_str_args:[OpIdKernelTypeStrArgsEntry];
}
table InferenceSession {
// This is the ORT format model version
// The version number is defined as kOrtModelVersion in <repo root>/onnxruntime/core/flatbuffers/ort_format_version.h
ort_version:string;
model:Model;
session_state:DeprecatedSessionState (deprecated);
kernel_type_str_resolver:KernelTypeStrResolver;
}
root_type InferenceSession;
file_identifier "ORTM";