From 067a3a6c3f856e92abb48e561b2d54e8454bdf05 Mon Sep 17 00:00:00 2001 From: Gaurav Jain Date: Tue, 19 Mar 2019 11:15:32 -0700 Subject: [PATCH] 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 --- tensorflow/python/eager/context.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tensorflow/python/eager/context.py b/tensorflow/python/eager/context.py index ad7fe539512..bb87a51c589 100644 --- a/tensorflow/python/eager/context.py +++ b/tensorflow/python/eager/context.py @@ -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()