summaryrefslogtreecommitdiff
path: root/compiler/tflchef/proto/tflchef.proto
blob: 55785c35dcbf1faeb32587e76d34f07ecf78a6c9 (plain)
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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
syntax = "proto2";

package tflchef;

//
// Initial version
//  - Our initial version
//
// Version 1
//  - Backward compatible with Initial version
//  - Added Graph to represent sub graphs
//  - Added name, version(default as 1), graph in ModelRecipe
//

// This enum value corresponds to TensorType in TensorFlow Lite schema
enum TensorType {
  FLOAT32 = 0;
  INT32 = 2;
  UINT8 = 3;
  INT64 = 4;
  BOOL = 6;
}

message TensorShape {
  repeated uint32 dim = 3;
}

message TensorFiller {
  optional string tag = 1;
  repeated string arg = 2;
}

message TensorQuantization {
  repeated float min = 1;
  repeated float max = 2;
  repeated float scale = 3;
  repeated int64 zero_point = 4;
  optional int32 quantized_dimension = 5 [default = 0];
}

message Operand {
  optional string name = 1;
  optional TensorType type = 2;
  optional TensorShape shape = 3;
  optional TensorFiller filler = 4;
  optional TensorQuantization quant = 5;
}

// This enum value corresponds to Padding in TensorFlow Lite schema
enum Padding {
  SAME = 0;
  VALID = 1;
}

// This enum value corresponds to ActivationFunctionType in TensorFlow Lite schema
enum Activation {
  NONE = 0;
  RELU = 1;
  RELU_N1_TO_1 = 2;
  RELU6 = 3;
}

// This enum value corresponds to MirrorPadMode in TensorFlow Lite schema
enum MirrorPadMode {
  REFLECT = 0;
  SYMMETRIC = 1;
}

message Conv2DOptions
{
  optional Padding padding = 1 [default = VALID];
  optional int32 stride_w = 2 [default = 1];
  optional int32 stride_h = 3 [default = 1];
  optional Activation activation = 4 [default = NONE];
  optional int32 dilation_w_factor = 5 [default = 1];
  optional int32 dilation_h_factor = 6 [default = 1];
}

message Pool2DOptions {
  optional Padding padding = 1 [default = VALID];
  optional int32 stride_w = 2 [default = 1];
  optional int32 stride_h = 3 [default = 1];
  optional int32 filter_width = 4 [default = 1];
  optional int32 filter_height = 5 [ default = 1];
  optional Activation activation = 6 [default = NONE];
}

message ConcatenationOptions {
  optional int32 axis = 1 [default = 0];
  optional Activation activation = 2 [default = NONE];
}

message ReshapeOptions {
  repeated int32 new_shape = 1;
}

message DepthwiseConv2DOptions
{
  optional Padding padding = 1 [default = VALID];
  optional int32 stride_w = 2 [default = 1];
  optional int32 stride_h = 3 [default = 1];
  optional int32 depth_multiplier = 4 [default = 1];
  optional Activation activation = 5 [default = NONE];
  optional int32 dilation_w_factor = 6 [default = 1];
  optional int32 dilation_h_factor = 7 [default = 1];
}

message ScatterNdOptions {
  // None
}

message SubOptions {
  optional Activation activation = 1 [default = NONE];
}

message DivOptions {
  optional Activation activation = 1 [default = NONE];
}

message FloorDivOptions {
  // None
}

message FloorModOptions {
  // None
}

message FullyConnectedOptions {
  optional Activation activation = 1 [default = NONE];
}

message AddOptions {
  optional Activation activation = 1 [default = NONE];
}

message AddNOptions {
  // None
}

message ArgMaxOptions {
  optional TensorType output_type = 1 [default = INT64];
}

message ArgMinOptions {
  optional TensorType output_type = 1 [default = INT64];
}

message PackOptions {
  optional int32 values_count = 1;
  optional int32 axis = 2 [default = 0];
}

message PadOptions {
  // None
}

message MirrorPadOptions {
  optional MirrorPadMode mode = 1 [default = REFLECT];
}

message SoftmaxOptions {
  optional float beta = 1 [default = 0.0];
}

message MulOptions {
  optional Activation activation = 1 [default = NONE];
}

message NegOptions {
  // None
}

message RangeOptions {
  // None
}

message ReducerOptions {
  optional bool keep_dims = 1 [ default = false ];
}

message SpaceToDepthOptions {
  optional int32 block_size = 1;
}

message LogicalOrOptions {
  // None
}

message LogicalNotOptions {
  // None
}

message LogicalAndOptions {
  // None
}

message TransposeOptions {
  // None
}

message AbsOptions {
  // None
}

message CosOptions {
  // None
}

message EqualOptions {
  // None
}

message ShapeOptions {
  optional TensorType out_type = 1 [default = INT32];
}

message BatchToSpaceNDOptions {
  // None
}

message SpaceToBatchNDOptions {
  // None
}

message StridedSliceOptions {
  optional int32 begin_mask = 1;
  optional int32 end_mask = 2;
  optional int32 ellipsis_mask = 3;
  optional int32 new_axis_mask = 4;
  optional int32 shrink_axis_mask = 5;
}

message SliceOptions {
  // None
}

message ExpOptions {
  // None
}

message ExpandDimsOptions {
  // None
}

message UnpackOptions {
  optional int32 num = 1;
  optional int32 axis = 2 [default = 0];
}

message GatherOptions {
  optional int32 axis = 1 [default = 0];
}

message TileOptions {
  // None
}

message BatchMatMulOptions {
  optional bool adj_x = 1 [default = false];
  optional bool adj_y = 2 [default = false];
}

message IfOptions {
  optional int32 then_subgraph_index = 1;
  optional int32 else_subgraph_index = 2;
}

message WhileOptions {
  optional int32 cond_subgraph_index = 1;
  optional int32 body_subgraph_index = 2;
}

message CastOptions {
  optional TensorType in_data_type = 1 [default = FLOAT32];
  optional TensorType out_data_type = 2 [default = FLOAT32];
}

message SquareOptions {
  // None
}

message MaximumMinimumOptions {
  //None
}

message GreaterEqualOptions {
  // None
}

message SelectOptions {
  // None
}

message SelectV2Options {
  // None
}

message SplitOptions {
  optional int32 num_splits = 1;
}

message SplitVOptions {
  optional int32 num_splits = 1;
}

message SquaredDifferenceOptions {
  // None
}

message FillOptions {
  // None
}

message GreaterOptions {
  // None 
}

message L2NormOptions {
  optional Activation activation = 1 [default = NONE];
}

message LessOptions {
  // None
}

message LessEqualOptions {
  // None
}

message LocalResponseNormalizationOptions {
  optional int32 radius = 1 [default = 5];
  optional float bias = 2 [default = 1.0];
  optional float alpha = 3 [default = 1.0];
  optional float beta = 4 [default = 0.5];
}

message MatMulOptions {
  optional bool transpose_a = 1 [default = false];
  optional bool transpose_b = 2 [default = false];
}

message SqueezeOptions {
  repeated int32 squeeze_dim = 1;
}

message OneHotOptions {
  optional int32 axis = 1 [default = -1];
}

message TopKV2Options {
  // None
}

message LogSoftmaxOptions {
  // None
}

message ZerosLikeOptions {
  // None
}

message GatherNdOptions {
  // None
}

message NotEqualOptions {
  // None
}

message PowOptions {
  // None
}

message LeakyReluOptions {
  optional float alpha = 1 [default = 0.2];
}

message ResizeNearestNeighborOptions {
  optional bool align_corners = 1 [default = false];
}

message ResizeBilinearOptions {
  optional bool align_corners = 1 [default = false];
  optional bool half_pixel_centers = 2 [default = false];
}

message DepthToSpaceOptions {
  optional int32 block_size = 1;
}

message TransposeConvOptions {
  optional Padding padding = 1 [default = VALID];
  optional int32 stride_w = 2 [default = 1];
  optional int32 stride_h = 3 [default = 1];
}

message ReverseSequenceOptions {
  optional int32 seq_dim = 1 [default = 0];
  optional int32 batch_dim = 2 [default = 0];
}

message RankOptions {
  // NONE
}

message SegmentSumOptions {
  // NONE
}

message UniqueOptions {
  optional TensorType idx_out_type = 1 [default = INT32];
}

message WhereOptions {
 // None
}

message SparseToDenseOptions {
  optional bool validate_indices = 1 [default = true];
}

message ReverseV2Options {
  // None
}

message MatrixDiagOptions {
  // NONE
}

message MatrixSetDiagOptions {
  // NONE
}

message Operation {
  optional string type = 1;
  repeated string input = 2;
  repeated string output = 3;
  optional int32 version = 4 [default = 1];

  optional Conv2DOptions conv2d_options = 100;
  optional Pool2DOptions averagepool2d_options = 101;
  optional ConcatenationOptions concatenation_options = 102;
  optional Pool2DOptions maxpool2d_options = 103;
  optional ReshapeOptions reshape_options = 104;
  optional DepthwiseConv2DOptions depthwiseconv2d_options = 105;
  optional SubOptions sub_options = 106;
  optional DivOptions div_options = 107;
  optional FullyConnectedOptions fullyconnected_options = 108;
  optional AddOptions add_options = 109;
  optional ArgMaxOptions argmax_options = 110;
  optional PadOptions pad_options = 111;
  optional SoftmaxOptions softmax_options = 112;
  optional MulOptions mul_options = 113;
  optional ReducerOptions mean_options = 114;
  optional TransposeOptions transpose_options = 115;
  optional PackOptions pack_options = 116;
  optional LogicalOrOptions logical_or_options = 117;
  optional LogicalNotOptions logical_not_options = 118;
  optional LogicalAndOptions logical_and_options = 119;
  optional AbsOptions abs_options = 120;
  optional CosOptions cos_options = 121;
  optional EqualOptions equal_options = 122;
  optional ShapeOptions shape_options = 123;
  optional FloorDivOptions floordiv_options = 124;
  optional BatchToSpaceNDOptions batch_to_space_options = 125;
  optional ExpOptions exp_options = 126;
  optional UnpackOptions unpack_options = 127;
  optional GatherOptions gather_options = 128;
  optional BatchMatMulOptions batch_matmul_options = 129;
  optional TileOptions tile_options = 130;
  optional IfOptions if_options = 131;
  optional WhileOptions while_options = 132;
  optional SpaceToBatchNDOptions space_to_batch_nd_options = 133;
  optional CastOptions cast_options = 134;
  optional GreaterEqualOptions greaterequal_options = 135;
  optional MaximumMinimumOptions maximum_options = 136;
  optional StridedSliceOptions strided_slice_options = 137;
  optional SquaredDifferenceOptions squared_difference_options = 138;
  optional FillOptions fill_options = 139;
  optional SelectOptions select_options = 140;
  optional ReducerOptions reduce_prod_options = 141;
  optional SplitOptions split_options = 142;
  optional SplitVOptions split_v_options = 143;
  optional ReducerOptions sum_options = 144;
  optional GreaterOptions greater_options = 145;
  optional SqueezeOptions squeeze_options = 146;
  optional FloorModOptions floormod_options = 147;
  optional OneHotOptions onehot_options = 148;
  optional LessOptions less_options = 149;
  optional ReducerOptions reduce_max_options = 150;
  optional MaximumMinimumOptions minimum_options = 151;
  optional ReducerOptions reduce_any_options = 152;
  optional ZerosLikeOptions zeros_like_options = 153;
  // ConcatEmbeddingsOptions 154
  // LSHProjectionOptions 155
  // SVDFOptions 156
  // RNNOptions 157
  optional L2NormOptions l2norm_options = 158;
  optional LocalResponseNormalizationOptions local_response_normalization_options = 159;
  // LSTMOptions 160
  optional ResizeBilinearOptions resize_bilinear_options = 161;
  // CallOptions 162
  // SkipGramOptions 163
  optional SpaceToDepthOptions space_to_depth_options = 164;
  // EmbeddingLookupSparseOptions 165
  // SequenceRNNOptions 166
  optional TopKV2Options topk_v2_options = 167;
  optional LogSoftmaxOptions log_softmax_options = 168;
  // DequantizeOptions 169
  optional NegOptions neg_options = 170;
  // PadV2Options 171
  optional LessEqualOptions lessequal_options = 172;
  optional SliceOptions slice_options = 173;
  optional TransposeConvOptions transpose_conv_options = 174;
  optional SparseToDenseOptions sparse_to_dense_options = 175;
  optional PowOptions pow_options = 176;
  optional ArgMinOptions argmin_options = 177;
  // FakeQuantOptions 178
  // BidirectionalSequenceLSTMOptions 179
  // BidirectionalSequenceRNNOptions 180
  // UnidirectionalSequenceLSTMOptions 181
  optional RangeOptions range_options = 182;
  optional ResizeNearestNeighborOptions resize_nearest_neighbor_options = 183;
  optional LeakyReluOptions leaky_relu_options = 184;
  optional MirrorPadOptions mirrorpad_options = 185;
  optional UniqueOptions unique_options = 186;
  optional ReverseV2Options reversev2_options = 187;
  // AddNOptions 188
  optional GatherNdOptions gather_nd_options = 189;
  optional WhereOptions where_options = 190;
  optional RankOptions rank_options = 191;
  optional ReverseSequenceOptions reverse_sequence_options = 192;
  optional MatrixDiagOptions matrix_diag_options = 193;
  // QuantizeOptions 194
  optional MatrixSetDiagOptions matrix_set_diag_options = 195;
  // HardSwishOptions 196
  optional DepthToSpaceOptions depth_to_space_options = 197;
  // NonMaxSuppressionV4Options 198
  // NonMaxSuppressionV5Options 199
  optional ScatterNdOptions scatter_nd_options = 200;
  optional NotEqualOptions notequal_options = 201;
  optional ExpandDimsOptions expand_dims_options = 202;
  optional Pool2DOptions l2pool2d_options = 203;
  optional ReducerOptions all_options = 204;
  optional ReducerOptions reduce_min_options = 205;
  optional SegmentSumOptions segment_sum_options = 206;
  optional AddNOptions add_n_options = 207;
  optional MatMulOptions matmul_options = 208;

  // NOTE if there are more than two options with same type of Options
  // use the number not listed in the above reserve list
}

// For additional subgraphs
message Graph {
  repeated Operand operand = 1;
  repeated Operation operation = 2;
  repeated string input = 3;
  repeated string output = 4;
  optional string name = 5;
}

message ModelRecipe {
  repeated Operand operand = 1;
  repeated Operation operation = 2;
  repeated string input = 3;
  repeated string output = 4;
  optional string name = 5;
  optional uint32 version = 6 [default = 1];
  repeated Graph graph = 7;
}