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