diff options
author | 2017-10-30 07:12:07 -0700 | |
---|---|---|
committer | 2017-10-30 07:18:35 -0700 | |
commit | 2e54fd6de78d84af6b26f537ee25c5a625adce3b (patch) | |
tree | 76d3a58c6c0200f24ce576989a782d547e51eb50 | |
parent | 32ab30cb0a6bc86a6423c9078cfdddac79d79451 (diff) |
Adds eager execution compatibility note in Readers, Queues, and QueueRunner.
Raises a RuntimeError in base classes for QueueBase, ReaderBase, and QueueRunner.
PiperOrigin-RevId: 173888425
-rw-r--r-- | tensorflow/python/ops/data_flow_ops.py | 33 | ||||
-rw-r--r-- | tensorflow/python/ops/io_ops.py | 44 | ||||
-rw-r--r-- | tensorflow/python/training/queue_runner_impl.py | 11 |
3 files changed, 84 insertions, 4 deletions
diff --git a/tensorflow/python/ops/data_flow_ops.py b/tensorflow/python/ops/data_flow_ops.py index 62845a9f8b..c186eb5b7e 100644 --- a/tensorflow/python/ops/data_flow_ops.py +++ b/tensorflow/python/ops/data_flow_ops.py @@ -123,6 +123,11 @@ class QueueBase(object): @{tf.RandomShuffleQueue} for concrete implementations of this class, and instructions on how to create them. + + @compatibility(eager) + Queues are not compatible with eager execution. Instead, please + use `tf.data` to get data into your model. + @end_compatibility """ def __init__(self, dtypes, shapes, names, queue_ref): @@ -146,12 +151,12 @@ class QueueBase(object): Raises: ValueError: If one of the arguments is invalid. - ValueError: If eager execution is enabled. + RuntimeError: If eager execution is enabled. """ if context.in_eager_mode(): - raise ValueError( - "Queues are not supported in TensorFlow with eager execution. " - "Instead, use tf.data to get data into your model.") + raise RuntimeError( + "Queues are not supported when eager execution is enabled. " + "Instead, please use tf.data to get data into your model.") self._dtypes = dtypes if shapes is not None: if len(shapes) != len(dtypes): @@ -595,6 +600,11 @@ class RandomShuffleQueue(QueueBase): See @{tf.QueueBase} for a description of the methods on this class. + + @compatibility(eager) + Queues are not compatible with eager execution. Instead, please + use `tf.data` to get data into your model. + @end_compatibility """ def __init__(self, capacity, min_after_dequeue, dtypes, shapes=None, @@ -668,6 +678,11 @@ class FIFOQueue(QueueBase): See @{tf.QueueBase} for a description of the methods on this class. + + @compatibility(eager) + Queues are not compatible with eager execution. Instead, please + use `tf.data` to get data into your model. + @end_compatibility """ def __init__(self, capacity, dtypes, shapes=None, names=None, @@ -719,6 +734,11 @@ class PaddingFIFOQueue(QueueBase): See @{tf.QueueBase} for a description of the methods on this class. + + @compatibility(eager) + Queues are not compatible with eager execution. Instead, please + use `tf.data` to get data into your model. + @end_compatibility """ def __init__(self, capacity, dtypes, shapes, names=None, shared_name=None, @@ -781,6 +801,11 @@ class PriorityQueue(QueueBase): See @{tf.QueueBase} for a description of the methods on this class. + + @compatibility(eager) + Queues are not compatible with eager execution. Instead, please + use `tf.data` to get data into your model. + @end_compatibility """ def __init__(self, capacity, types, shapes=None, names=None, shared_name=None, diff --git a/tensorflow/python/ops/io_ops.py b/tensorflow/python/ops/io_ops.py index bd879ac423..670bb9a9c2 100644 --- a/tensorflow/python/ops/io_ops.py +++ b/tensorflow/python/ops/io_ops.py @@ -70,6 +70,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +from tensorflow.python.eager import context from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.lib.io import python_io @@ -152,6 +153,11 @@ class ReaderBase(object): contains the work units and the Reader dequeues from the queue when it is asked to produce a record (via Read()) but it has finished the last work unit. + + @compatibility(eager) + Readers are not compatible with eager execution. Instead, please + use `tf.data` to get data into your model. + @end_compatibility """ def __init__(self, reader_ref, supports_serialize=False): @@ -161,7 +167,15 @@ class ReaderBase(object): reader_ref: The operation that implements the reader. supports_serialize: True if the reader implementation can serialize its state. + + Raises: + RuntimeError: If eager execution is enabled. """ + if context.in_eager_mode(): + raise RuntimeError( + "Readers are not supported when eager execution is enabled. " + "Instead, please use tf.data to get data into your model.") + self._reader_ref = reader_ref self._supports_serialize = supports_serialize @@ -347,6 +361,11 @@ class WholeFileReader(ReaderBase): be a filename (key) and the contents of that file (value). See ReaderBase for supported methods. + + @compatibility(eager) + Readers are not compatible with eager execution. Instead, please + use `tf.data` to get data into your model. + @end_compatibility """ def __init__(self, name=None): @@ -367,6 +386,11 @@ class TextLineReader(ReaderBase): Newlines are stripped from the output. See ReaderBase for supported methods. + + @compatibility(eager) + Readers are not compatible with eager execution. Instead, please + use `tf.data` to get data into your model. + @end_compatibility """ # TODO(josh11b): Support serializing and restoring state. @@ -390,6 +414,11 @@ class FixedLengthRecordReader(ReaderBase): """A Reader that outputs fixed-length records from a file. See ReaderBase for supported methods. + + @compatibility(eager) + Readers are not compatible with eager execution. Instead, please + use `tf.data` to get data into your model. + @end_compatibility """ # TODO(josh11b): Support serializing and restoring state. @@ -427,6 +456,11 @@ class TFRecordReader(ReaderBase): """A Reader that outputs the records from a TFRecords file. See ReaderBase for supported methods. + + @compatibility(eager) + Readers are not compatible with eager execution. Instead, please + use `tf.data` to get data into your model. + @end_compatibility """ # TODO(josh11b): Support serializing and restoring state. @@ -452,6 +486,11 @@ class LMDBReader(ReaderBase): """A Reader that outputs the records from a LMDB file. See ReaderBase for supported methods. + + @compatibility(eager) + Readers are not compatible with eager execution. Instead, please + use `tf.data` to get data into your model. + @end_compatibility """ def __init__(self, name=None, options=None): """Create a LMDBReader. @@ -474,6 +513,11 @@ class IdentityReader(ReaderBase): work string and output (work, work). See ReaderBase for supported methods. + + @compatibility(eager) + Readers are not compatible with eager execution. Instead, please + use `tf.data` to get data into your model. + @end_compatibility """ def __init__(self, name=None): diff --git a/tensorflow/python/training/queue_runner_impl.py b/tensorflow/python/training/queue_runner_impl.py index d3b473ee46..4e7c81d7b2 100644 --- a/tensorflow/python/training/queue_runner_impl.py +++ b/tensorflow/python/training/queue_runner_impl.py @@ -44,6 +44,11 @@ class QueueRunner(object): and reporting exceptions, etc. The `QueueRunner`, combined with the `Coordinator`, helps handle these issues. + + @compatibility(eager) + QueueRunners are not compatible with eager execution. Instead, please + use `tf.data` to get data into your model. + @end_compatibility """ def __init__(self, queue=None, enqueue_ops=None, close_op=None, @@ -80,7 +85,13 @@ class QueueRunner(object): ValueError: If both `queue_runner_def` and `queue` are both specified. ValueError: If `queue` or `enqueue_ops` are not provided when not restoring from `queue_runner_def`. + RuntimeError: If eager execution is enabled. """ + if context.in_eager_mode(): + raise RuntimeError( + "QueueRunners are not supported when eager execution is enabled. " + "Instead, please use tf.data to get data into your model.") + if queue_runner_def: if queue or enqueue_ops: raise ValueError("queue_runner_def and queue are mutually exclusive.") |