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
31 enum SparseIndexVecType {
32 SparseIdxVecType_NONE = 0;
39 repeated uint32 dim = 3;
42 message ShapeSignature {
43 repeated int32 dim = 1;
46 message TensorFiller {
47 optional string tag = 1;
48 repeated string arg = 2;
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];
59 message TensorSparsity {
60 message TraversalOrder {
61 repeated int32 dim = 1;
64 repeated int32 dim = 1;
67 repeated int32 dim = 1;
68 optional SparseIndexVecType type = 2;
71 optional DimensionType format = 1;
72 optional int32 dense_size = 2;
73 optional IndexVec array_segments = 3;
74 optional IndexVec array_indices = 4;
77 optional TraversalOrder traversal_order = 1;
78 optional BlockMap block_map = 2;
79 repeated DimMetaData dim_metadata = 3;
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;
93 // This enum value corresponds to Padding in TensorFlow Lite schema
99 // This enum value corresponds to ActivationFunctionType in TensorFlow Lite schema
109 // This enum value corresponds to MirrorPadMode in TensorFlow Lite schema
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];
124 message Conv2DOptions
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];
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];
143 message ConcatenationOptions {
144 optional int32 axis = 1 [default = 0];
145 optional Activation activation = 2 [default = NONE];
148 message ReshapeOptions {
149 repeated int32 new_shape = 1;
152 message DepthwiseConv2DOptions
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];
163 message ScatterNdOptions {
168 optional Activation activation = 1 [default = NONE];
172 optional Activation activation = 1 [default = NONE];
175 message FloorDivOptions {
179 message FloorModOptions {
183 message FullyConnectedOptions {
184 optional Activation activation = 1 [default = NONE];
188 optional Activation activation = 1 [default = NONE];
191 message AddNOptions {
195 message ArgMaxOptions {
196 optional TensorType output_type = 1 [default = INT64];
199 message ArgMinOptions {
200 optional TensorType output_type = 1 [default = INT64];
203 message PackOptions {
204 optional int32 values_count = 1;
205 optional int32 axis = 2 [default = 0];
212 message PadV2Options {
216 message MirrorPadOptions {
217 optional MirrorPadMode mode = 1 [default = REFLECT];
220 message SoftmaxOptions {
221 optional float beta = 1 [default = 0.0];
225 optional Activation activation = 1 [default = NONE];
232 message RangeOptions {
236 message ReducerOptions {
237 optional bool keep_dims = 1 [ default = false ];
240 message SpaceToDepthOptions {
241 optional int32 block_size = 1;
244 message LogicalOrOptions {
248 message LogicalNotOptions {
252 message LogicalAndOptions {
256 message TransposeOptions {
268 message EqualOptions {
272 message ShapeOptions {
273 optional TensorType out_type = 1 [default = INT32];
276 message BatchToSpaceNDOptions {
280 message SpaceToBatchNDOptions {
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;
292 message SliceOptions {
300 message ExpandDimsOptions {
304 message UnpackOptions {
305 optional int32 num = 1;
306 optional int32 axis = 2 [default = 0];
309 message GatherOptions {
310 optional int32 axis = 1 [default = 0];
313 message TileOptions {
317 message BatchMatMulOptions {
318 optional bool adj_x = 1 [default = false];
319 optional bool adj_y = 2 [default = false];
323 optional int32 then_subgraph_index = 1;
324 optional int32 else_subgraph_index = 2;
327 message WhileOptions {
328 optional int32 cond_subgraph_index = 1;
329 optional int32 body_subgraph_index = 2;
332 message CastOptions {
333 optional TensorType in_data_type = 1 [default = FLOAT32];
334 optional TensorType out_data_type = 2 [default = FLOAT32];
337 message SquareOptions {
341 message MaximumMinimumOptions {
345 message GreaterEqualOptions {
349 message SelectOptions {
353 message SelectV2Options {
357 message SplitOptions {
358 optional int32 num_splits = 1;
361 message SplitVOptions {
362 optional int32 num_splits = 1;
365 message SquaredDifferenceOptions {
369 message FillOptions {
373 message GreaterOptions {
377 message L2NormOptions {
378 optional Activation activation = 1 [default = NONE];
381 message LessOptions {
385 message LessEqualOptions {
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];
396 message MatMulOptions {
397 optional bool transpose_a = 1 [default = false];
398 optional bool transpose_b = 2 [default = false];
401 message SqueezeOptions {
402 repeated int32 squeeze_dim = 1;
405 message OneHotOptions {
406 optional int32 axis = 1 [default = -1];
409 message TopKV2Options {
413 message LogSoftmaxOptions {
417 message ZerosLikeOptions {
421 message GatherNdOptions {
425 message NonMaxSuppressionV4Options {
429 message NonMaxSuppressionV5Options {
433 message NotEqualOptions {
441 message LeakyReluOptions {
442 optional float alpha = 1 [default = 0.2];
445 message ResizeNearestNeighborOptions {
446 optional bool align_corners = 1 [default = false];
449 message ResizeBilinearOptions {
450 optional bool align_corners = 1 [default = false];
451 optional bool half_pixel_centers = 2 [default = false];
454 message DepthToSpaceOptions {
455 optional int32 block_size = 1;
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];
464 message ReverseSequenceOptions {
465 optional int32 seq_dim = 1 [default = 0];
466 optional int32 batch_dim = 2 [default = 0];
469 message RankOptions {
473 message SegmentSumOptions {
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];
485 message UniqueOptions {
486 optional TensorType idx_out_type = 1 [default = INT32];
489 message WhereOptions {
493 message SparseToDenseOptions {
494 optional bool validate_indices = 1 [default = true];
497 message ReverseV2Options {
501 message MatrixDiagOptions {
505 message MatrixSetDiagOptions {
509 message DequantizeOptions {
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];
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];
531 optional string type = 1;
532 repeated string input = 2;
533 repeated string output = 3;
534 optional int32 version = 4 [default = 1];
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
594 optional L2NormOptions l2norm_options = 158;
595 optional LocalResponseNormalizationOptions local_response_normalization_options = 159;
597 optional ResizeBilinearOptions resize_bilinear_options = 161;
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;
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
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;
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;
666 // For additional subgraphs
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;
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;