From e3d751c2a85a74b74c5eacf038721f2c67eb2da5 Mon Sep 17 00:00:00 2001 From: Sergei Lebedev Date: Tue, 11 Dec 2018 12:30:48 -0800 Subject: [PATCH] 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 --- tensorflow/python/eager/context.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tensorflow/python/eager/context.py b/tensorflow/python/eager/context.py index cbbe5cf49e2..848b300ebae 100644 --- a/tensorflow/python/eager/context.py +++ b/tensorflow/python/eager/context.py @@ -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() -- GitLab