diff options
author | Skye Wanderman-Milne <skyewm@google.com> | 2018-10-10 08:28:08 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-10-10 08:33:21 -0700 |
commit | 131f6f8429ffa0511a3d5a6a595843d3d96ec942 (patch) | |
tree | 65eea249647113fb07f037e1eaac66103a5f513d /tensorflow/python/ops/cond_v2_impl.py | |
parent | f146d586bf93b918d6f3e014b230abee49170a52 (diff) |
cond_v2: raise an error if pred is a Python bool.
This is to match the existing behavior of tf.cond.
PiperOrigin-RevId: 216534084
Diffstat (limited to 'tensorflow/python/ops/cond_v2_impl.py')
-rw-r--r-- | tensorflow/python/ops/cond_v2_impl.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tensorflow/python/ops/cond_v2_impl.py b/tensorflow/python/ops/cond_v2_impl.py index c9aa4d4889..81d9cba042 100644 --- a/tensorflow/python/ops/cond_v2_impl.py +++ b/tensorflow/python/ops/cond_v2_impl.py @@ -52,6 +52,9 @@ _gradients_impl = None def cond_v2(pred, true_fn, false_fn, name="cond"): """Like tf.cond, except emits a single If op.""" + if isinstance(pred, bool): + raise TypeError("pred must not be a Python bool", pred) + if not name: name = "cond" |