1# Copyright 2018 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# ==============================================================================
15"""Constants for TFLite."""
16
17from __future__ import absolute_import
18from __future__ import division
19from __future__ import print_function
20
21from tensorflow.lite.toco import toco_flags_pb2 as _toco_flags_pb2
22from tensorflow.python.framework import dtypes
23from tensorflow.python.util.all_util import remove_undocumented
24from tensorflow.python.util.tf_export import tf_export as _tf_export
25
26FLOAT = dtypes.float32
27INT32 = dtypes.int32
28INT64 = dtypes.int64
29STRING = dtypes.string
30QUANTIZED_UINT8 = dtypes.uint8
31COMPLEX64 = dtypes.complex64
32TENSORFLOW_GRAPHDEF = _toco_flags_pb2.TENSORFLOW_GRAPHDEF
33TFLITE = _toco_flags_pb2.TFLITE
34GRAPHVIZ_DOT = _toco_flags_pb2.GRAPHVIZ_DOT
35
36_tf_export(v1=["lite.constants.FLOAT"]).export_constant(__name__, "FLOAT")
37_tf_export(v1=["lite.constants.INT32"]).export_constant(__name__, "INT32")
38_tf_export(v1=["lite.constants.INT64"]).export_constant(__name__, "INT64")
39_tf_export(v1=["lite.constants.STRING"]).export_constant(__name__, "STRING")
40_tf_export(v1=["lite.constants.QUANTIZED_UINT8"]).export_constant(
41    __name__, "QUANTIZED_UINT8")
42_tf_export("lite.constants.TFLITE").export_constant(__name__, "TFLITE")
43_tf_export("lite.constants.GRAPHVIZ_DOT").export_constant(
44    __name__, "GRAPHVIZ_DOT")
45
46# Currently the default mode of operation is to shell to another python process
47# to protect against crashes. However, it breaks some dependent targets because
48# it forces us to depend on an external py_binary. The experimental API doesn't
49# have that drawback.
50EXPERIMENTAL_USE_TOCO_API_DIRECTLY = False
51
52
53_allowed_symbols = [
54    "FLOAT",
55    "INT32",
56    "INT64",
57    "STRING",
58    "QUANTIZED_UINT8",
59    "COMPLEX64",
60    "TENSORFLOW_GRAPHDEF",
61    "TFLITE",
62    "GRAPHVIZ_DOT",
63    "EXPERIMENTAL_USE_TOCO_API_DIRECTLY",
64]
65remove_undocumented(__name__, _allowed_symbols)
66