Imported Upstream version 1.25.0
[platform/core/ml/nnfw.git] / compiler / tflchef / proto / tflchef.proto
1 syntax = "proto2";
2
3 package tflchef;
4
5 //
6 // Initial version
7 //  - Our initial version
8 //
9 // Version 1
10 //  - Backward compatible with Initial version
11 //  - Added Graph to represent sub graphs
12 //  - Added name, version(default as 1), graph in ModelRecipe
13 //
14
15 // This enum value corresponds to TensorType in TensorFlow Lite schema
16 enum TensorType {
17   FLOAT32 = 0;
18   FLOAT16 = 1;
19   INT32 = 2;
20   UINT8 = 3;
21   INT64 = 4;
22   STRING = 5;
23   BOOL = 6;
24   INT16 = 7;
25   INT8 = 9;
26 }
27
28 enum DimensionType {
29   DENSE = 0;
30   SPARSE_CSR = 1;
31 }
32
33 enum SparseIndexVecType {
34   SparseIdxVecType_NONE = 0;
35   INT32VEC = 1;
36   UINT16VEC = 2;
37   UINT8VEC = 3;
38 }
39
40 message TensorShape {
41   repeated uint32 dim = 3;
42 }
43
44 message ShapeSignature {
45   repeated int32 dim = 1;
46 }
47
48 message TensorFiller {
49   optional string tag = 1;
50   repeated string arg = 2;
51 }
52
53 message TensorQuantization {
54   repeated float min = 1;
55   repeated float max = 2;
56   repeated float scale = 3;
57   repeated int64 zero_point = 4;
58   optional int32 quantized_dimension = 5 [default = 0];
59 }
60
61 message TensorSparsity {
62   message TraversalOrder {
63     repeated int32 dim = 1;
64   }
65   message BlockMap {
66     repeated int32 dim = 1;
67   }
68   message IndexVec {
69     repeated int32 dim = 1;
70     optional SparseIndexVecType type = 2;
71   }
72   message DimMetaData {
73     optional DimensionType format = 1;
74     optional int32 dense_size = 2;
75     optional IndexVec array_segments = 3;
76     optional IndexVec array_indices = 4;
77   }
78
79   optional TraversalOrder traversal_order = 1;
80   optional BlockMap block_map = 2;
81   repeated DimMetaData dim_metadata = 3;
82 }
83
84 message Operand {
85   optional string name = 1;
86   optional TensorType type = 2;
87   optional TensorShape shape = 3;
88   optional TensorFiller filler = 4;
89   optional TensorQuantization quant = 5;
90   optional TensorSparsity sparsity = 6;
91   optional bool is_variable = 7 [default = false];
92   optional ShapeSignature shape_signature = 8;
93   // 'make_sparse' is to tell tflchef to make a sparse tensor
94   // as filling 'TensorSparsity' by hand can be difficult
95   // for now, last dimension will be SPARSE_CSR
96   // ex) shape [2, 3, 4] will have
97   //     TraversalOrder [0, 1, 2] with [DENSE, DENSE, SPARSE_CSR]
98   optional bool make_sparse = 9 [default = false];
99 }
100
101 // This enum value corresponds to Padding in TensorFlow Lite schema
102 enum Padding {
103   SAME = 0;
104   VALID = 1;
105 }
106
107 // This enum value corresponds to ActivationFunctionType in TensorFlow Lite schema
108 enum Activation {
109   NONE = 0;
110   RELU = 1;
111   RELU_N1_TO_1 = 2;
112   RELU6 = 3;
113   TANH = 4;
114   SIGN_BIT = 5;
115 }
116
117 // This enum value corresponds to MirrorPadMode in TensorFlow Lite schema
118 enum MirrorPadMode {
119   REFLECT = 0;
120   SYMMETRIC = 1;
121 }
122
123 message BidirectionalSequenceLSTMOptions {
124   optional Activation activation = 1 [default = NONE];
125   optional float cell_clip = 2 [default = 0.0];
126   optional float proj_clip = 3 [default = 0.0];
127   optional bool merge_outputs = 6 [default = false];
128   optional bool time_major = 4 [default = true];
129   optional bool asymmetric_quantize_inputs = 5 [default = false];  
130 }
131
132 message Conv2DOptions
133 {
134   optional Padding padding = 1 [default = VALID];
135   optional int32 stride_w = 2 [default = 1];
136   optional int32 stride_h = 3 [default = 1];
137   optional Activation activation = 4 [default = NONE];
138   optional int32 dilation_w_factor = 5 [default = 1];
139   optional int32 dilation_h_factor = 6 [default = 1];
140 }
141
142 message Pool2DOptions {
143   optional Padding padding = 1 [default = VALID];
144   optional int32 stride_w = 2 [default = 1];
145   optional int32 stride_h = 3 [default = 1];
146   optional int32 filter_width = 4 [default = 1];
147   optional int32 filter_height = 5 [ default = 1];
148   optional Activation activation = 6 [default = NONE];
149 }
150
151 message ConcatenationOptions {
152   optional int32 axis = 1 [default = 0];
153   optional Activation activation = 2 [default = NONE];
154 }
155
156 message ReshapeOptions {
157   repeated int32 new_shape = 1;
158 }
159
160 message DepthwiseConv2DOptions
161 {
162   optional Padding padding = 1 [default = VALID];
163   optional int32 stride_w = 2 [default = 1];
164   optional int32 stride_h = 3 [default = 1];
165   optional int32 depth_multiplier = 4 [default = 1];
166   optional Activation activation = 5 [default = NONE];
167   optional int32 dilation_w_factor = 6 [default = 1];
168   optional int32 dilation_h_factor = 7 [default = 1];
169 }
170
171 message ScatterNdOptions {
172   // None
173 }
174
175 message SubOptions {
176   optional Activation activation = 1 [default = NONE];
177 }
178
179 message DivOptions {
180   optional Activation activation = 1 [default = NONE];
181 }
182
183 message FloorDivOptions {
184   // None
185 }
186
187 message FloorModOptions {
188   // None
189 }
190
191 message FullyConnectedOptions {
192   optional Activation activation = 1 [default = NONE];
193   optional bool keep_num_dims = 2 [ default = false ];
194 }
195
196 message AddOptions {
197   optional Activation activation = 1 [default = NONE];
198 }
199
200 message AddNOptions {
201   // None
202 }
203
204 message ArgMaxOptions {
205   optional TensorType output_type = 1 [default = INT64];
206 }
207
208 message ArgMinOptions {
209   optional TensorType output_type = 1 [default = INT64];
210 }
211
212 message PackOptions {
213   optional int32 values_count = 1;
214   optional int32 axis = 2 [default = 0];
215 }
216
217 message PadOptions {
218   // None
219 }
220
221 message PadV2Options {
222   // None
223 }
224
225 message MirrorPadOptions {
226   optional MirrorPadMode mode = 1 [default = REFLECT];
227 }
228
229 message SoftmaxOptions {
230   optional float beta = 1 [default = 0.0];
231 }
232
233 message MulOptions {
234   optional Activation activation = 1 [default = NONE];
235 }
236
237 message NegOptions {
238   // None
239 }
240
241 message RangeOptions {
242   // None
243 }
244
245 message ReducerOptions {
246   optional bool keep_dims = 1 [ default = false ];
247 }
248
249 message SpaceToDepthOptions {
250   optional int32 block_size = 1;
251 }
252
253 message LogicalOrOptions {
254   // None
255 }
256
257 message LogicalNotOptions {
258   // None
259 }
260
261 message LogicalAndOptions {
262   // None
263 }
264
265 message TransposeOptions {
266   // None
267 }
268
269 message AbsOptions {
270   // None
271 }
272
273 message CosOptions {
274   // None
275 }
276
277 message EqualOptions {
278   // None
279 }
280
281 message ShapeOptions {
282   optional TensorType out_type = 1 [default = INT32];
283 }
284
285 message BatchToSpaceNDOptions {
286   // None
287 }
288
289 message SpaceToBatchNDOptions {
290   // None
291 }
292
293 message StridedSliceOptions {
294   optional int32 begin_mask = 1;
295   optional int32 end_mask = 2;
296   optional int32 ellipsis_mask = 3;
297   optional int32 new_axis_mask = 4;
298   optional int32 shrink_axis_mask = 5;
299 }
300
301 message SliceOptions {
302   // None
303 }
304
305 message ExpOptions {
306   // None
307 }
308
309 message ExpandDimsOptions {
310   // None
311 }
312
313 message UnpackOptions {
314   optional int32 num = 1;
315   optional int32 axis = 2 [default = 0];
316 }
317
318 message GatherOptions {
319   optional int32 axis = 1 [default = 0];
320 }
321
322 message TileOptions {
323   // None
324 }
325
326 message BatchMatMulOptions {
327   optional bool adj_x = 1 [default = false];
328   optional bool adj_y = 2 [default = false];
329 }
330
331 message IfOptions {
332   optional int32 then_subgraph_index = 1;
333   optional int32 else_subgraph_index = 2;
334 }
335
336 message WhileOptions {
337   optional int32 cond_subgraph_index = 1;
338   optional int32 body_subgraph_index = 2;
339 }
340
341 message CastOptions {
342   optional TensorType in_data_type = 1 [default = FLOAT32];
343   optional TensorType out_data_type = 2 [default = FLOAT32];
344 }
345
346 message SquareOptions {
347   // None
348 }
349
350 message MaximumMinimumOptions {
351   //None
352 }
353
354 message GreaterEqualOptions {
355   // None
356 }
357
358 message SelectOptions {
359   // None
360 }
361
362 message SelectV2Options {
363   // None
364 }
365
366 message SplitOptions {
367   optional int32 num_splits = 1;
368 }
369
370 message SplitVOptions {
371   optional int32 num_splits = 1;
372 }
373
374 message SquaredDifferenceOptions {
375   // None
376 }
377
378 message SVDFOptions {
379   optional int32 rank = 1 [default = 0];
380   optional Activation activation = 2 [default = NONE];
381   optional bool asymmetric_quantize_inputs = 3 [default = false];
382 }
383
384 message FillOptions {
385   // None
386 }
387
388 message GreaterOptions {
389   // None 
390 }
391
392 message L2NormOptions {
393   optional Activation activation = 1 [default = NONE];
394 }
395
396 message LessOptions {
397   // None
398 }
399
400 message LessEqualOptions {
401   // None
402 }
403
404 message LocalResponseNormalizationOptions {
405   optional int32 radius = 1 [default = 5];
406   optional float bias = 2 [default = 1.0];
407   optional float alpha = 3 [default = 1.0];
408   optional float beta = 4 [default = 0.5];
409 }
410
411 message MatMulOptions {
412   optional bool transpose_a = 1 [default = false];
413   optional bool transpose_b = 2 [default = false];
414 }
415
416 message SqueezeOptions {
417   repeated int32 squeeze_dim = 1;
418 }
419
420 message OneHotOptions {
421   optional int32 axis = 1 [default = -1];
422 }
423
424 message TopKV2Options {
425   // None
426 }
427
428 message LogSoftmaxOptions {
429   // None
430 }
431
432 message ZerosLikeOptions {
433   // None
434 }
435
436 message GatherNdOptions {
437   // None
438 }
439
440 message GeluOptions {
441   optional bool approximate = 1 [default = false];
442 }
443
444 message NonMaxSuppressionV4Options {
445   // None
446 }
447
448 message NonMaxSuppressionV5Options {
449   // None
450 }
451
452 message NotEqualOptions {
453   // None
454 }
455
456 message PowOptions {
457   // None
458 }
459
460 message LeakyReluOptions {
461   optional float alpha = 1 [default = 0.2];
462 }
463
464 message ResizeNearestNeighborOptions {
465   optional bool align_corners = 1 [default = false];
466 }
467
468 message ResizeBilinearOptions {
469   optional bool align_corners = 1 [default = false];
470   optional bool half_pixel_centers = 2 [default = false];
471 }
472
473 message DepthToSpaceOptions {
474   optional int32 block_size = 1;
475 }
476
477 message TransposeConvOptions {
478   optional Padding padding = 1 [default = VALID];
479   optional int32 stride_w = 2 [default = 1];
480   optional int32 stride_h = 3 [default = 1];
481   optional Activation activation = 4 [default = NONE];
482 }
483
484 message ReverseSequenceOptions {
485   optional int32 seq_dim = 1 [default = 0];
486   optional int32 batch_dim = 2 [default = 0];
487 }
488
489 message RankOptions {
490   // NONE
491 }
492
493 message SegmentSumOptions {
494   // NONE
495 }
496
497 message UnidirectionalSequenceLSTMOptions {
498   optional Activation activation = 1 [default = NONE];
499   optional float cell_clip = 2 [default = 0.0];
500   optional float proj_clip = 3 [default = 0.0];
501   optional bool time_major = 4 [default = false];
502   optional bool asymmetric_quantize_inputs = 5 [default = false];
503 }
504
505 message UniqueOptions {
506   optional TensorType idx_out_type = 1 [default = INT32];
507 }
508
509 message WhereOptions {
510  // None
511 }
512
513 message SparseToDenseOptions {
514   optional bool validate_indices = 1 [default = true];
515 }
516
517 message ReverseV2Options {
518   // None
519 }
520
521 message MatrixDiagOptions {
522   // NONE
523 }
524
525 message MatrixSetDiagOptions {
526   // NONE
527 }
528
529 message DequantizeOptions {
530   // NONE
531 }
532
533 message MaxPoolWithArgmaxOptions {
534   optional Padding padding = 1 [default = VALID];
535   optional int32 stride_w = 2 [default = 1];
536   optional int32 stride_h = 3 [default = 1];
537   optional int32 filter_width = 4 [default = 1];
538   optional int32 filter_height = 5 [ default = 1];
539   optional TensorType output_type = 6 [default = INT64];
540   optional bool include_batch_in_index = 7 [default = false];
541 }
542
543 message FakeQuantOptions {
544   optional float min = 1 [default = 0.0];
545   optional float max = 2 [default = 0.0];
546   optional int32 num_bits = 3 [default = 0];
547   optional bool narrow_range = 4 [default = false];
548 }
549
550 message DensifyOptions {
551   // NONE
552 }
553
554 message Operation {
555   optional string type = 1;
556   repeated string input = 2;
557   repeated string output = 3;
558   optional int32 version = 4 [default = 1];
559
560   optional Conv2DOptions conv2d_options = 100;
561   optional Pool2DOptions averagepool2d_options = 101;
562   optional ConcatenationOptions concatenation_options = 102;
563   optional Pool2DOptions maxpool2d_options = 103;
564   optional ReshapeOptions reshape_options = 104;
565   optional DepthwiseConv2DOptions depthwiseconv2d_options = 105;
566   optional SubOptions sub_options = 106;
567   optional DivOptions div_options = 107;
568   optional FullyConnectedOptions fullyconnected_options = 108;
569   optional AddOptions add_options = 109;
570   optional ArgMaxOptions argmax_options = 110;
571   optional PadOptions pad_options = 111;
572   optional SoftmaxOptions softmax_options = 112;
573   optional MulOptions mul_options = 113;
574   optional ReducerOptions mean_options = 114;
575   optional TransposeOptions transpose_options = 115;
576   optional PackOptions pack_options = 116;
577   optional LogicalOrOptions logical_or_options = 117;
578   optional LogicalNotOptions logical_not_options = 118;
579   optional LogicalAndOptions logical_and_options = 119;
580   optional AbsOptions abs_options = 120;
581   optional CosOptions cos_options = 121;
582   optional EqualOptions equal_options = 122;
583   optional ShapeOptions shape_options = 123;
584   optional FloorDivOptions floordiv_options = 124;
585   optional BatchToSpaceNDOptions batch_to_space_options = 125;
586   optional ExpOptions exp_options = 126;
587   optional UnpackOptions unpack_options = 127;
588   optional GatherOptions gather_options = 128;
589   optional BatchMatMulOptions batch_matmul_options = 129;
590   optional TileOptions tile_options = 130;
591   optional IfOptions if_options = 131;
592   optional WhileOptions while_options = 132;
593   optional SpaceToBatchNDOptions space_to_batch_nd_options = 133;
594   optional CastOptions cast_options = 134;
595   optional GreaterEqualOptions greaterequal_options = 135;
596   optional MaximumMinimumOptions maximum_options = 136;
597   optional StridedSliceOptions strided_slice_options = 137;
598   optional SquaredDifferenceOptions squared_difference_options = 138;
599   optional FillOptions fill_options = 139;
600   optional SelectOptions select_options = 140;
601   optional ReducerOptions reduce_prod_options = 141;
602   optional SplitOptions split_options = 142;
603   optional SplitVOptions split_v_options = 143;
604   optional ReducerOptions sum_options = 144;
605   optional GreaterOptions greater_options = 145;
606   optional SqueezeOptions squeeze_options = 146;
607   optional FloorModOptions floormod_options = 147;
608   optional OneHotOptions onehot_options = 148;
609   optional LessOptions less_options = 149;
610   optional ReducerOptions reduce_max_options = 150;
611   optional MaximumMinimumOptions minimum_options = 151;
612   optional ReducerOptions reduce_any_options = 152;
613   optional ZerosLikeOptions zeros_like_options = 153;
614   // ConcatEmbeddingsOptions 154
615   // LSHProjectionOptions 155
616   optional SVDFOptions svdf_options = 156;
617   // RNNOptions 157
618   optional L2NormOptions l2norm_options = 158;
619   optional LocalResponseNormalizationOptions local_response_normalization_options = 159;
620   // LSTMOptions 160
621   optional ResizeBilinearOptions resize_bilinear_options = 161;
622   // CallOptions 162
623   // SkipGramOptions 163
624   optional SpaceToDepthOptions space_to_depth_options = 164;
625   // EmbeddingLookupSparseOptions 165
626   // SequenceRNNOptions 166
627   optional TopKV2Options topk_v2_options = 167;
628   optional LogSoftmaxOptions log_softmax_options = 168;
629   optional DequantizeOptions dequantize_options = 169;
630   optional NegOptions neg_options = 170;
631   optional PadV2Options padv2_options = 171;
632   optional LessEqualOptions lessequal_options = 172;
633   optional SliceOptions slice_options = 173;
634   optional TransposeConvOptions transpose_conv_options = 174;
635   optional SparseToDenseOptions sparse_to_dense_options = 175;
636   optional PowOptions pow_options = 176;
637   optional ArgMinOptions argmin_options = 177;
638   optional FakeQuantOptions fakequant_options = 178;
639   optional BidirectionalSequenceLSTMOptions bidirectional_sequence_lstm_options = 179;
640   // BidirectionalSequenceRNNOptions 180
641   optional UnidirectionalSequenceLSTMOptions unidirectional_sequence_lstm_options = 181;
642   optional RangeOptions range_options = 182;
643   optional ResizeNearestNeighborOptions resize_nearest_neighbor_options = 183;
644   optional LeakyReluOptions leaky_relu_options = 184;
645   optional MirrorPadOptions mirrorpad_options = 185;
646   optional UniqueOptions unique_options = 186;
647   optional ReverseV2Options reversev2_options = 187;
648   // AddNOptions 188
649   optional GatherNdOptions gather_nd_options = 189;
650   optional WhereOptions where_options = 190;
651   optional RankOptions rank_options = 191;
652   optional ReverseSequenceOptions reverse_sequence_options = 192;
653   optional MatrixDiagOptions matrix_diag_options = 193;
654   // QuantizeOptions 194
655   optional MatrixSetDiagOptions matrix_set_diag_options = 195;
656   // HardSwishOptions 196
657   optional DepthToSpaceOptions depth_to_space_options = 197;
658   optional NonMaxSuppressionV4Options non_max_suppression_v4_options = 198;
659   optional NonMaxSuppressionV5Options non_max_suppression_v5_options = 199;
660   optional ScatterNdOptions scatter_nd_options = 200;
661   optional NotEqualOptions notequal_options = 201;
662   optional ExpandDimsOptions expand_dims_options = 202;
663   optional Pool2DOptions l2pool2d_options = 203;
664   optional ReducerOptions all_options = 204;
665   optional ReducerOptions reduce_min_options = 205;
666   optional SegmentSumOptions segment_sum_options = 206;
667   optional AddNOptions add_n_options = 207;
668   optional MatMulOptions matmul_options = 208;
669   optional MaxPoolWithArgmaxOptions max_pool_with_argmax_options = 209;
670   optional DensifyOptions densify_options = 210;
671   optional GeluOptions gelu_options = 211;
672   // NOTE if there are more than two options with same type of Options
673   // use the number not listed in the above reserve list
674 }
675
676 message TensorMap {
677   optional string name = 4;
678   // use tensor as name of the Operand or use tensor_index as order number.
679   // either one should exist.
680   optional string tensor = 5;
681   optional uint32 tensor_index = 6;
682 }
683
684 message SignatureDef {
685   repeated TensorMap inputs = 4;
686   repeated TensorMap outputs = 5;
687   optional string signature_key = 6;
688   // optional string key = 10; obsolete in TF2.8.0
689   optional uint32 subgraph_index = 12;
690 }
691
692 // For additional subgraphs
693 message Graph {
694   repeated Operand operand = 1;
695   repeated Operation operation = 2;
696   repeated string input = 3;
697   repeated string output = 4;
698   optional string name = 5;
699 }
700
701 message ModelRecipe {
702   repeated Operand operand = 1;
703   repeated Operation operation = 2;
704   repeated string input = 3;
705   repeated string output = 4;
706   optional string name = 5;
707   optional uint32 version = 6 [default = 1];
708   repeated Graph graph = 7;
709   repeated SignatureDef signature_def = 8;
710 }