[tf.data] Do not crash when combining .cache().take().repeat()
authorBrennan Saeta <saeta@google.com>
Thu, 22 Mar 2018 01:02:01 +0000 (18:02 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Thu, 22 Mar 2018 01:04:21 +0000 (18:04 -0700)
commitc7334fef9d1173525f6111b8ab50360b6531d76b
tree4b632a7befa81386a7f4ec50ac1d1371745fd05c
parent8e4e9f7ceaa78f76b7f0aaa7a607e80e67f0d912
[tf.data] Do not crash when combining .cache().take().repeat()

Currently, if the .cache() iterator is not fully consumed before
being repeated, it will cause an exception to be raised to Python.
Instead, cache should act as an identity transformation and log
an error, as this will not affect the correctness of the user's
program (at the cost of an unexpected performance cost: i.e. not
actually caching).

PiperOrigin-RevId: 189999552
tensorflow/core/kernels/data/cache_dataset_ops.cc
tensorflow/python/data/kernel_tests/cache_dataset_op_test.py