Skip to content

Commit

Permalink
Raise a nicer error message when trying to call gradients with while …
Browse files Browse the repository at this point in the history
…loop (tensorflow#18052)

* Produce a nicer error message when trying to call gradients on a while loop without properly serializing graph via MetaGraphDef

* Fix syntax and lint error

* Fix minor intent: Wrong continued indentation (add 2 spaces)
  • Loading branch information
imsheridan authored and rmlarsen committed Mar 29, 2018
1 parent 86868a1 commit 1d7c2fa
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tensorflow/python/ops/control_flow_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,9 @@ def __init__(self, forward_ctxt, outer_grad_state):
if outer_grad_state:
outer_forward_ctxt = outer_grad_state.forward_context
else:
if not hasattr(forward_ctxt, 'outer_context'):
raise ValueError("Failed to call gradients on a while loop without"
"properly serializing graph via MetaGraphDef")
outer_forward_ctxt = forward_ctxt.outer_context

# Add the forward loop counter.
Expand Down

0 comments on commit 1d7c2fa

Please sign in to comment.