• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2021 The TensorFlow Authors. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15namespace tflite;
16
17// The original model format.
18enum ModelType : int32 {
19  NONE = 0,
20  TF_SAVED_MODEL = 1,
21  KERAS_MODEL = 2,
22  TF_CONCRETE_FUNCTIONS = 3,
23  TF_GRAPH_DEF = 4,
24  TF_SESSION = 5,
25  JAX = 6
26}
27
28// The environment during conversion.
29table Environment {
30  // TensorFlow version string, e.g., "2.4.1".
31  tensorflow_version:string;
32
33  // TensorFlow Lite Converter API used.
34  api_version:uint;
35
36  // Original model format.
37  model_type:ModelType;
38}
39
40// The model optimization modes.
41// When adding a new optimization mode, it must be canonical with the existing
42// ones. The thousand part of the value represents the optimization technique
43// and the later part is to distinguish different modes of that technique.
44enum ModelOptimizationMode : int32 {
45  PTQ_FLOAT16 = 1001,
46  PTQ_DYNAMIC_RANGE = 1002,
47  PTQ_FULL_INTEGER = 1003,
48  PTQ_INT16 = 1004,
49  QUANTIZATION_AWARE_TRAINING = 2000,
50  RANDOM_SPARSITY = 3001,
51  BLOCK_SPARSITY = 3002,
52  STRUCTURED_SPARSITY = 3003,
53}
54
55// The block size used for sparsity.
56table SparsityBlockSize {
57  values:[uint];
58}
59
60table ConversionOptions {
61  // Applied the optimization techniques.
62  model_optimization_modes:[ModelOptimizationMode];
63
64  // Boolean indicating whether to allow custom ops.
65  allow_custom_ops:bool;
66
67  // Boolean indicating whether to convert unsupported ops to select
68  // TensorFlow ops.
69  enable_select_tf_ops:bool;
70
71  // Boolean indicating whether to convert all TensorFlow ops to select
72  // TensorFlow ops.
73  force_select_tf_ops:bool;
74
75  // The block size used for sparsity.
76  sparsity_block_sizes:[SparsityBlockSize];
77}
78
79table ConversionMetadata {
80  // Metadata about the environment during conversion.
81  environment:Environment;
82
83  // Conversion options used.
84  options:ConversionOptions;
85}
86
87root_type ConversionMetadata;
88