TFE: Fix bug encountered when using `optimizer.apply_gradients` in a defun.
authorAkshay Agrawal <akshayka@google.com>
Mon, 19 Mar 2018 20:38:23 +0000 (13:38 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Mon, 19 Mar 2018 20:46:30 +0000 (13:46 -0700)
commita78c5033e005f76b83df4fd97d0074fcc990f603
tree06a64f64e135d32355a1c47694c20cfbff06c359
parenteb03b44049328404eb5578efda0729ca1a4f0a11
TFE: Fix bug encountered when using `optimizer.apply_gradients` in a defun.

Prior to this change, `Optimizer` assumed that `not
context.executing_eagerly()` implied that every variable that it was to update
was constructed in a graph. That assumption is incorrect --- TensorFlow
functions can mutate variables captured from or lifted into the eager context. As such, this change removes that assumption.

Fixes #17792

PiperOrigin-RevId: 189633630
tensorflow/python/eager/function_test.py
tensorflow/python/ops/variables.py
tensorflow/python/training/optimizer.py