Prefetch samples. Args: features: Nest structure of tensors to prefetch. feed_dict: (Optional.) A dictionary that maps graph elements to values. Each key in `feed_dict` can be one of the following types: * `tf.Tensor` or `tf.compat.v1.placeholder`: the value should be a tensor
(
features,
feed_dict={},
capacity=1,
num_threads=1,
num_clients=1,
timeout_millis=300000,
closed_exception_types=(errors.OUT_OF_RANGE,),
ignored_exception_types=(),
use_stage_subgraph_thread_pool=False,
stage_subgraph_thread_pool_id = 0,
stage_subgraph_stream_id = 0,
name=None)
| 90 | |
| 91 | @tf_export(v1=["staged"]) |
| 92 | def staged( |
| 93 | features, |
| 94 | feed_dict={}, |
| 95 | capacity=1, |
| 96 | num_threads=1, |
| 97 | num_clients=1, |
| 98 | timeout_millis=300000, |
| 99 | closed_exception_types=(errors.OUT_OF_RANGE,), |
| 100 | ignored_exception_types=(), |
| 101 | use_stage_subgraph_thread_pool=False, |
| 102 | stage_subgraph_thread_pool_id = 0, |
| 103 | stage_subgraph_stream_id = 0, |
| 104 | name=None): |
| 105 | """Prefetch samples. |
| 106 | |
| 107 | Args: |
| 108 | features: Nest structure of tensors to prefetch. |
| 109 | feed_dict: (Optional.) A dictionary that maps graph elements to values. |
| 110 | Each key in `feed_dict` can be one of the following types: |
| 111 | * `tf.Tensor` or `tf.compat.v1.placeholder`: the value should be a tensor. |
| 112 | * `tf.SparseTensor`: the value should be a `tf.compat.v1.SparseTensorValue`. |
| 113 | * a nested tuple of `Tensor`s or `SparseTensor`s, the value should be a |
| 114 | nested tuple with the same structure that maps to their corresponding |
| 115 | values as above. |
| 116 | capacity: (Optional.) Max number of samples to keep in the buffer. |
| 117 | num_threads: (Optional.) Number of threads for prefetching. 1 by |
| 118 | default. |
| 119 | num_clients: (Optional.) Number of clients of prefetched sample. 1 by |
| 120 | default. |
| 121 | timeout_millis: (Optional.) Max milliseconds put op can take, 5 min by |
| 122 | default. |
| 123 | closed_exception_types: (Optional.) Exception types indicating that the |
| 124 | prefetching is normally finished. Defaults to |
| 125 | `(errors.OUT_OF_RANGE,)`. |
| 126 | ignored_exception_types: (Optional.) Exception types indicating that the |
| 127 | prefetching can continue. Defaults to `()`. |
| 128 | use_stage_subgraph_thread_pool: (Optional.) Use stage subgraph thread pool |
| 129 | to run stage graph or not. |
| 130 | stage_subgraph_thread_pool_id: (Optional.) Specifies the stage subgraph |
| 131 | thread pool to use when enable use_stage_subgraph_thread_pool. 0 by default. |
| 132 | stage_subgraph_stream_id: (Optional.) Specifies which stream to use for the |
| 133 | Stage subgraph. The default value is 0. |
| 134 | name: (Optional.) Name of prefetching operations. |
| 135 | |
| 136 | Returns: |
| 137 | Prefetched sample. |
| 138 | """ |
| 139 | if num_threads < 1: |
| 140 | raise ValueError('num_threads must >= 1') |
| 141 | |
| 142 | if name is None: |
| 143 | name = ops.get_default_graph().unique_name(PREFETCH) |
| 144 | with ops.name_scope(name): |
| 145 | local_device = control_flow_ops.no_op().device |
| 146 | tensor_or_sparse_tensor_or_nones = nest.flatten(features) |
| 147 | |
| 148 | tensor_or_nones = [] |
| 149 | for t in tensor_or_sparse_tensor_or_nones: |
nothing calls this directly
no test coverage detected