MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / prefetch_join

Function prefetch_join

tensorflow/python/ops/prefetch.py:241–386  ·  view source on GitHub ↗

Prefetch samples from thread_to_features list. `Unlike `prefetch`, `prefetch_join` runs different ops in different threads. `prefetch_join` can be used to support datasets with many sources. Args: thread_to_features: List of nest structure of tensors for each thread. feed_dict: (Opti

(
    thread_to_features,
    feed_dict={},
    capacity=1,
    num_clients=1,
    timeout_millis=300000,
    closed_exception_types=(errors.OUT_OF_RANGE,),
    ignored_exception_types=(),
    name=None)

Source from the content-addressed store, hash-verified

239
240@tf_export(v1=["prefetch_join"])
241def prefetch_join(
242 thread_to_features,
243 feed_dict={},
244 capacity=1,
245 num_clients=1,
246 timeout_millis=300000,
247 closed_exception_types=(errors.OUT_OF_RANGE,),
248 ignored_exception_types=(),
249 name=None):
250 """Prefetch samples from thread_to_features list.
251
252 `Unlike `prefetch`, `prefetch_join` runs different ops in different threads.
253 `prefetch_join` can be used to support datasets with many sources.
254
255 Args:
256 thread_to_features: List of nest structure of tensors for each thread.
257 feed_dict: (Optional.) A dictionary that maps graph elements to values.
258 Each key in `feed_dict` can be one of the following types:
259 * `tf.Tensor` or `tf.compat.v1.placeholder`: the value should be a tensor.
260 * `tf.SparseTensor`: the value should be a `tf.compat.v1.SparseTensorValue`.
261 * a nested tuple of `Tensor`s or `SparseTensor`s, the value should be a
262 nested tuple with the same structure that maps to their corresponding
263 values as above.
264 capacity: (Optional.) Max number of samples to keep in the buffer.
265 num_clients: (Optional.) Number of clients of prefetched sample. 1 by
266 default.
267 timeout_millis: (Optional.) Max milliseconds put op can take, 5 min by
268 default.
269 closed_exception_types: (Optional.) Exception types indicating that the
270 prefetching is normally finished. Defaults to
271 `(tf.errors.OutOfRangeError, StopIteration)`.
272 ignored_exception_types: (Optional.) Exception types indicating that the
273 prefetching can continue. Defaults to `()`.
274 name: (Optional.) Name of prefetching operations.
275
276 Returns:
277 Prefetched sample.
278 """
279 if len(thread_to_features) < 1:
280 raise ValueError('thread_to_features must has at least one element')
281
282 if name is None:
283 name = ops.get_default_graph().unique_name(PREFETCH)
284 with ops.name_scope(name):
285 local_device = control_flow_ops.no_op().device
286 with ops.device(local_device):
287 cancel_fetching = gen_tensor_buffer_ops.tensor_buffer_cancel(
288 shared_name=name,
289 shared_capacity=capacity)
290 resume_fetching = gen_tensor_buffer_ops.tensor_buffer_cancel(
291 is_cancelled=False,
292 shared_name=name,
293 shared_capacity=capacity)
294 close_fetching = gen_tensor_buffer_ops.tensor_buffer_close(
295 shared_name=name,
296 shared_capacity=capacity)
297
298 thread_to_tensor_dtypes = []

Callers

nothing calls this directly

Calls 9

unique_nameMethod · 0.80
name_scopeMethod · 0.45
deviceMethod · 0.45
flattenMethod · 0.45
appendMethod · 0.45
extendMethod · 0.45
identityMethod · 0.45
set_shapeMethod · 0.45

Tested by

no test coverage detected