1# Copyright 2016 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"""Global configuration.""" 16 17from __future__ import absolute_import 18from __future__ import division 19from __future__ import print_function 20 21from tensorflow.python.autograph import utils 22 23 24PYTHON_LITERALS = { 25 'None': None, 26 'False': False, 27 'True': True, 28 'float': float, 29} 30 31 32def _internal_name(name): 33 """This function correctly resolves internal and external names.""" 34 reference_name = utils.__name__ 35 36 reference_root = 'tensorflow.' 37 # If the TF module is foo.tensorflow, then all other modules 38 # are then assumed to be prefixed by 'foo'. 39 40 if reference_name.startswith(reference_root): 41 return name 42 43 reference_begin = reference_name.find('.' + reference_root) 44 assert reference_begin > 0 45 46 root_prefix = reference_name[:reference_begin] 47 return root_prefix + '.' + name 48 49 50DEFAULT_UNCOMPILED_MODULES = set(( 51 ('tensorflow',), 52 (_internal_name('tensorflow'),), 53 # TODO(mdan): Remove once the conversion process is optimized. 54 ('tensorflow_probability',), 55 (_internal_name('tensorflow_probability'),), 56)) 57 58 59COMPILED_IMPORT_STATEMENTS = ( 60 'from __future__ import print_function', 61) 62