More tolerant control flow grad code. It currently fails sometimes inside tf.function
PiperOrigin-RevId: 314213428 Change-Id: I0b0d1ae88401016d3b617cf843192708bda3e695
This commit is contained in:
parent
c98e236060
commit
926090c4d4
@ -210,6 +210,8 @@ def _EnterGrad(op, grad):
|
||||
# pylint: disable=protected-access
|
||||
grad_ctxt = graph._get_control_flow_context()
|
||||
# pylint: enable=protected-access
|
||||
if grad_ctxt is None:
|
||||
return grad
|
||||
if not grad_ctxt.back_prop:
|
||||
# Skip gradient computation, if the attribute `back_prop` is false.
|
||||
return grad
|
||||
|
Loading…
Reference in New Issue
Block a user