7 // - Our initial version
10 // - Backward compatible with Initial version
11 // - Added Graph to represent sub graphs
12 // - Added name, version(default as 1), graph in ModelRecipe
15 // This enum value corresponds to TensorType in TensorFlow Lite schema
32 enum SparseIndexVecType {
33 SparseIdxVecType_NONE = 0;
40 repeated uint32 dim = 3;
43 message ShapeSignature {
44 repeated int32 dim = 1;
47 message TensorFiller {
48 optional string tag = 1;
49 repeated string arg = 2;
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];
60 message TensorSparsity {
61 message TraversalOrder {
62 repeated int32 dim = 1;
65 repeated int32 dim = 1;
68 repeated int32 dim = 1;
69 optional SparseIndexVecType type = 2;
72 optional DimensionType format = 1;
73 optional int32 dense_size = 2;
74 optional IndexVec array_segments = 3;
75 optional IndexVec array_indices = 4;
78 optional TraversalOrder traversal_order = 1;
79 optional BlockMap block_map = 2;
80 repeated DimMetaData dim_metadata = 3;
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];
100 // This enum value corresponds to Padding in TensorFlow Lite schema
106 // This enum value corresponds to ActivationFunctionType in TensorFlow Lite schema
116 // This enum value corresponds to MirrorPadMode in TensorFlow Lite schema
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];
131 message Conv2DOptions
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];
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];
150 message ConcatenationOptions {
151 optional int32 axis = 1 [default = 0];
152 optional Activation activation = 2 [default = NONE];
155 message ReshapeOptions {
156 repeated int32 new_shape = 1;
159 message DepthwiseConv2DOptions
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];
170 message ScatterNdOptions {
175 optional Activation activation = 1 [default = NONE];
179 optional Activation activation = 1 [default = NONE];
182 message FloorDivOptions {
186 message FloorModOptions {
190 message FullyConnectedOptions {
191 optional Activation activation = 1 [default = NONE];
192 optional bool keep_num_dims = 2 [ default = false ];
196 optional Activation activation = 1 [default = NONE];
199 message AddNOptions {
203 message ArgMaxOptions {
204 optional TensorType output_type = 1 [default = INT64];
207 message ArgMinOptions {
208 optional TensorType output_type = 1 [default = INT64];
211 message PackOptions {
212 optional int32 values_count = 1;
213 optional int32 axis = 2 [default = 0];
220 message PadV2Options {
224 message MirrorPadOptions {
225 optional MirrorPadMode mode = 1 [default = REFLECT];
228 message SoftmaxOptions {
229 optional float beta = 1 [default = 0.0];
233 optional Activation activation = 1 [default = NONE];
240 message RangeOptions {
244 message ReducerOptions {
245 optional bool keep_dims = 1 [ default = false ];
248 message SpaceToDepthOptions {
249 optional int32 block_size = 1;
252 message LogicalOrOptions {
256 message LogicalNotOptions {
260 message LogicalAndOptions {
264 message TransposeOptions {
276 message EqualOptions {
280 message ShapeOptions {
281 optional TensorType out_type = 1 [default = INT32];
284 message BatchToSpaceNDOptions {
288 message SpaceToBatchNDOptions {
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;
300 message SliceOptions {
308 message ExpandDimsOptions {
312 message UnpackOptions {
313 optional int32 num = 1;
314 optional int32 axis = 2 [default = 0];
317 message GatherOptions {
318 optional int32 axis = 1 [default = 0];
321 message TileOptions {
325 message BatchMatMulOptions {
326 optional bool adj_x = 1 [default = false];
327 optional bool adj_y = 2 [default = false];
331 optional int32 then_subgraph_index = 1;
332 optional int32 else_subgraph_index = 2;
335 message WhileOptions {
336 optional int32 cond_subgraph_index = 1;
337 optional int32 body_subgraph_index = 2;
340 message CastOptions {
341 optional TensorType in_data_type = 1 [default = FLOAT32];
342 optional TensorType out_data_type = 2 [default = FLOAT32];
345 message SquareOptions {
349 message MaximumMinimumOptions {
353 message GreaterEqualOptions {
357 message SelectOptions {
361 message SelectV2Options {
365 message SplitOptions {
366 optional int32 num_splits = 1;
369 message SplitVOptions {
370 optional int32 num_splits = 1;
373 message SquaredDifferenceOptions {
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];
383 message FillOptions {
387 message GreaterOptions {
391 message L2NormOptions {
392 optional Activation activation = 1 [default = NONE];
395 message LessOptions {
399 message LessEqualOptions {
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];
410 message MatMulOptions {
411 optional bool transpose_a = 1 [default = false];
412 optional bool transpose_b = 2 [default = false];
415 message SqueezeOptions {
416 repeated int32 squeeze_dim = 1;
419 message OneHotOptions {
420 optional int32 axis = 1 [default = -1];
423 message TopKV2Options {
427 message LogSoftmaxOptions {
431 message ZerosLikeOptions {
435 message GatherNdOptions {
439 message NonMaxSuppressionV4Options {
443 message NonMaxSuppressionV5Options {
447 message NotEqualOptions {
455 message LeakyReluOptions {
456 optional float alpha = 1 [default = 0.2];
459 message ResizeNearestNeighborOptions {
460 optional bool align_corners = 1 [default = false];
463 message ResizeBilinearOptions {
464 optional bool align_corners = 1 [default = false];
465 optional bool half_pixel_centers = 2 [default = false];
468 message DepthToSpaceOptions {
469 optional int32 block_size = 1;
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];
478 message ReverseSequenceOptions {
479 optional int32 seq_dim = 1 [default = 0];
480 optional int32 batch_dim = 2 [default = 0];
483 message RankOptions {
487 message SegmentSumOptions {
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];
499 message UniqueOptions {
500 optional TensorType idx_out_type = 1 [default = INT32];
503 message WhereOptions {
507 message SparseToDenseOptions {
508 optional bool validate_indices = 1 [default = true];
511 message ReverseV2Options {
515 message MatrixDiagOptions {
519 message MatrixSetDiagOptions {
523 message DequantizeOptions {
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];
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];
544 message DensifyOptions {
549 optional string type = 1;
550 repeated string input = 2;
551 repeated string output = 3;
552 optional int32 version = 4 [default = 1];
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;
612 optional L2NormOptions l2norm_options = 158;
613 optional LocalResponseNormalizationOptions local_response_normalization_options = 159;
615 optional ResizeBilinearOptions resize_bilinear_options = 161;
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;
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
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;
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;
685 // For additional subgraphs
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;
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;