aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Yuan Yu <yuanbyu@google.com>2016-11-08 12:44:49 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-11-08 16:29:24 -0800
commit72b01b5ca054f85fe042a9941576ea8edf347f1f (patch)
treee3efbfe4a4b617d49cb8c952a903e69331d12006
parente76210f995e09f4fd812ad3335840d097033bbe7 (diff)
Give a friendly error message if parallel_iterations is set to be less than 1.
Change: 138551385
-rw-r--r--tensorflow/python/ops/control_flow_ops.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/tensorflow/python/ops/control_flow_ops.py b/tensorflow/python/ops/control_flow_ops.py
index ec66532afb..1efc2d5380 100644
--- a/tensorflow/python/ops/control_flow_ops.py
+++ b/tensorflow/python/ops/control_flow_ops.py
@@ -2572,6 +2572,7 @@ def while_loop(cond, body, loop_vars, shape_invariants=None,
`Tensor`, and `TensorArray` objects.
shape_invariants: The shape invariants for the loop variables.
parallel_iterations: The number of iterations allowed to run in parallel.
+ It must be a positive integer.
back_prop: Whether backprop is enabled for this while loop.
swap_memory: Whether GPU-CPU memory swap is enabled for this loop.
name: Optional name prefix for the returned tensors.
@@ -2625,6 +2626,8 @@ def while_loop(cond, body, loop_vars, shape_invariants=None,
raise TypeError("cond must be callable.")
if not callable(body):
raise TypeError("body must be callable.")
+ if parallel_iterations < 1:
+ raise TypeError("parallel_iterations must be a positive integer.")
if shape_invariants is not None:
nest.assert_same_structure(loop_vars, shape_invariants)