Public API to switch between eager execution and graph building.
authorAlexandre Passos <apassos@google.com>
Fri, 25 May 2018 20:20:13 +0000 (13:20 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Fri, 25 May 2018 20:23:08 +0000 (13:23 -0700)
commit68430112b2ca5c160db6dd412d43f572ec69e72f
tree90b2c71f25bd56ddcc179bfd0855bf858f9a6384
parentb6ae98b4ac1ec3051d81f3133b827d6bb305aa2b
Public API to switch between eager execution and graph building.

Now, after tf.enable_eager_execution() has been executed, entering the context
manager of a tf.Graph will enable graph mode. So, for example

```
tf.enable_eager_execution()
with tf.Graph().as_default():
  c = tf.constant(1.0)  # this is a graph tensor
c2 = tf.constant(1.0)  # this is an eager tensor
```

The main use-case of this is allowing documentation writers to make a single
notebook which starts with eager execution and seamlessly transitions to
building graphs.

This also makes many explicit enablings of graph mode in the code redundant
(a cleanup cl will follow).

PiperOrigin-RevId: 198092991
15 files changed:
tensorflow/contrib/distribute/python/mirrored_strategy.py
tensorflow/contrib/distribute/python/monitor_test.py
tensorflow/contrib/eager/python/saver_test.py
tensorflow/contrib/opt/python/training/adamax_test.py
tensorflow/contrib/optimizer_v2/momentum_test.py
tensorflow/python/framework/ops.py
tensorflow/python/framework/ops_test.py
tensorflow/python/framework/test_util.py
tensorflow/python/framework/test_util_test.py
tensorflow/python/kernel_tests/accumulate_n_eager_test.py
tensorflow/python/kernel_tests/py_func_test.py
tensorflow/python/ops/variables.py
tensorflow/python/training/adam_test.py
tensorflow/python/training/momentum_test.py
tensorflow/python/training/training_util.py