1# Copyright 2019 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"""Contains global variables related to mixed precision. 16 17This is not part of mixed_precision.py to avoid a circular dependency. 18mixed_precision.py depends on Session, and Session depends on this file. 19""" 20 21from __future__ import absolute_import 22from __future__ import division 23from __future__ import print_function 24 25 26# Whether the mixed precision graph rewrite has been enabled or not with 27# `enable_mixed_precision_graph_rewrite`. Used to turn on auto_mixed_precision 28# in ConfigProtos passed to Sessions. 29mixed_precision_graph_rewrite_is_enabled = False 30 31# True if a Session has been created without the mixed precision graph rewrite 32# being enabled. Used to give a warning if mixed precision is enabled after a 33# Session has already been created. 34non_mixed_precision_session_created = False 35 36# Whether the global tf.keras.mixed_precision.Policy uses mixed precision. Used 37# to raise an error message if both a mixed Policy and the graph rewrite are 38# used at the same time. 39using_mixed_precision_policy = False 40