From 131f6f8429ffa0511a3d5a6a595843d3d96ec942 Mon Sep 17 00:00:00 2001 From: Skye Wanderman-Milne Date: Wed, 10 Oct 2018 08:28:08 -0700 Subject: cond_v2: raise an error if pred is a Python bool. This is to match the existing behavior of tf.cond. PiperOrigin-RevId: 216534084 --- tensorflow/python/ops/cond_v2_impl.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tensorflow/python/ops/cond_v2_impl.py') 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" -- cgit v1.2.3