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 27FLOAT16 = dtypes.float16 28INT32 = dtypes.int32 29INT64 = dtypes.int64 30STRING = dtypes.string 31QUANTIZED_UINT8 = dtypes.uint8 32INT8 = dtypes.int8 33INT16 = dtypes.int16 34COMPLEX64 = dtypes.complex64 35TENSORFLOW_GRAPHDEF = _toco_flags_pb2.TENSORFLOW_GRAPHDEF 36TFLITE = _toco_flags_pb2.TFLITE 37GRAPHVIZ_DOT = _toco_flags_pb2.GRAPHVIZ_DOT 38 39_tf_export(v1=["lite.constants.FLOAT"]).export_constant(__name__, "FLOAT") 40_tf_export(v1=["lite.constants.FLOAT16"]).export_constant(__name__, "FLOAT16") 41_tf_export(v1=["lite.constants.INT32"]).export_constant(__name__, "INT32") 42_tf_export(v1=["lite.constants.INT64"]).export_constant(__name__, "INT64") 43_tf_export(v1=["lite.constants.STRING"]).export_constant(__name__, "STRING") 44_tf_export(v1=["lite.constants.QUANTIZED_UINT8"]).export_constant( 45 __name__, "QUANTIZED_UINT8") 46_tf_export(v1=["lite.constants.INT8"]).export_constant(__name__, "INT8") 47_tf_export(v1=["lite.constants.INT16"]).export_constant(__name__, "INT16") 48_tf_export(v1=["lite.constants.TFLITE"]).export_constant(__name__, "TFLITE") 49_tf_export(v1=["lite.constants.GRAPHVIZ_DOT"]).export_constant( 50 __name__, "GRAPHVIZ_DOT") 51 52# Currently the default mode of operation is to shell to another python process 53# to protect against crashes. However, it breaks some dependent targets because 54# it forces us to depend on an external py_binary. The experimental API doesn't 55# have that drawback. 56EXPERIMENTAL_USE_TOCO_API_DIRECTLY = False 57 58 59_allowed_symbols = [ 60 "FLOAT", 61 "FLOAT16", 62 "INT32", 63 "INT64", 64 "STRING", 65 "QUANTIZED_UINT8", 66 "INT8", 67 "INT16", 68 "COMPLEX64", 69 "TENSORFLOW_GRAPHDEF", 70 "TFLITE", 71 "GRAPHVIZ_DOT", 72 "EXPERIMENTAL_USE_TOCO_API_DIRECTLY", 73] 74remove_undocumented(__name__, _allowed_symbols) 75