IS_IN_GRAPH_MODE should not force-init the eager context.

This caused hard to diagnose failures in enable_eager_execution calls.

PiperOrigin-RevId: 225050519
This commit is contained in:
Sergei Lebedev 2018-12-11 12:30:48 -08:00 committed by TensorFlower Gardener
parent 806ccc2cf7
commit e3d751c2a8

View File

@ -923,6 +923,10 @@ def add_function(fdef):
# but they do all import this file. Note that IS_IN_GRAPH_MODE and
# in_graph_mode are both parameterless functions.
def _tmp_in_graph_mode():
if context_safe() is None:
# Context not yet initialized. Assume graph mode following the
# default implementation in `is_in_graph_mode`.
return True
return not executing_eagerly()