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