diff options
author | Skye Wanderman-Milne <skyewm@google.com> | 2017-12-07 13:34:55 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-12-07 13:38:53 -0800 |
commit | 7772360b9f9e466437a3ecadeb9c5ca28ccbbc50 (patch) | |
tree | 381e5a0cb5bb0df7d6b5a5219ed5166e6b29f93b /tensorflow/python/kernel_tests/control_flow_ops_py_test.py | |
parent | 25adb9cd6a098f467023c5850040baf76b71c4ac (diff) |
Raise exception on bad while loop shapes sooner.
This change moves the _EnforceShapeInvariant call inside
_AddNextAndBackEdge, instead of after it. This is so we can do the
check before calling Operation._update_input, which throws a shape
error with the C API enabled.
PiperOrigin-RevId: 178287233
Diffstat (limited to 'tensorflow/python/kernel_tests/control_flow_ops_py_test.py')
-rw-r--r-- | tensorflow/python/kernel_tests/control_flow_ops_py_test.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tensorflow/python/kernel_tests/control_flow_ops_py_test.py b/tensorflow/python/kernel_tests/control_flow_ops_py_test.py index 20eb923e72..38ea8f7de4 100644 --- a/tensorflow/python/kernel_tests/control_flow_ops_py_test.py +++ b/tensorflow/python/kernel_tests/control_flow_ops_py_test.py @@ -914,7 +914,13 @@ class ControlFlowTest(test.TestCase): self.assertTrue(r[1].get_shape()[0].value is None) self.assertEqual(r[1].get_shape()[1], tensor_shape.Dimension(2)) - with self.assertRaisesRegexp(ValueError, "not an invariant for"): + with self.assertRaisesRegexp( + ValueError, + r"The shape for while_1/Merge_1:0 is not an invariant for the loop. " + r"It enters the loop with shape \(2, 2\), but has shape \(4, 2\) " + r"after one iteration. Provide shape invariants using either the " + r"`shape_invariants` argument of tf.while_loop or set_shape\(\) on " + r"the loop variables."): r = control_flow_ops.while_loop(c, b, [i, m]) def testWhileShapeInferenceSparseTensor(self): |