Avoid creating Context with executing_eagerly()

This is just a small step in the direction of cleaning up some of these
calls. In general, we need to avoid implicitly creating a context unless
the caller really wanted to.

PiperOrigin-RevId: 239229861
This commit is contained in:
Gaurav Jain 2019-03-19 11:15:32 -07:00 committed by TensorFlower Gardener
parent 30af2e9ee1
commit 067a3a6c3f

View File

@ -1025,6 +1025,9 @@ def executing_eagerly():
but may also be enabled within the context of a Python function via
tf.contrib.eager.py_func.
"""
if context_safe() is None:
return default_execution_mode == EAGER_MODE
return context().executing_eagerly()