Home | History | Annotate | Download | only in python
      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 
     17 from __future__ import absolute_import
     18 from __future__ import division
     19 from __future__ import print_function
     20 
     21 from tensorflow.lite.toco import toco_flags_pb2 as _toco_flags_pb2
     22 from tensorflow.python.framework import dtypes
     23 from tensorflow.python.util.all_util import remove_undocumented
     24 from tensorflow.python.util.tf_export import tf_export as _tf_export
     25 
     26 FLOAT = dtypes.float32
     27 INT32 = dtypes.int32
     28 INT64 = dtypes.int64
     29 STRING = dtypes.string
     30 QUANTIZED_UINT8 = dtypes.uint8
     31 COMPLEX64 = dtypes.complex64
     32 TENSORFLOW_GRAPHDEF = _toco_flags_pb2.TENSORFLOW_GRAPHDEF
     33 TFLITE = _toco_flags_pb2.TFLITE
     34 GRAPHVIZ_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.
     50 EXPERIMENTAL_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 ]
     65 remove_undocumented(__name__, _allowed_symbols)
     66