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

Function _scoped_subscribe

tensorflow/python/framework/subscribe.py:290–309  ·  view source on GitHub ↗

Helper method that subscribes a single tensor to a list of side_effects. This is a thin wrapper around `_subscribe` and ensures that the side effect ops are added within the same device and control flow context of the subscribed tensor. Args: tensor: The `tf.Tensor` to be subscribed.

(tensor, side_effects, control_cache)

Source from the content-addressed store, hash-verified

288
289
290def _scoped_subscribe(tensor, side_effects, control_cache):
291 """Helper method that subscribes a single tensor to a list of side_effects.
292
293 This is a thin wrapper around `_subscribe` and ensures that the side effect
294 ops are added within the same device and control flow context of the
295 subscribed tensor.
296
297 Args:
298 tensor: The `tf.Tensor` to be subscribed.
299 side_effects: List of side_effect functions, see subscribe for details.
300 control_cache: `_ControlOutputCache` helper to get control_outputs faster.
301
302 Returns:
303 The modified replacement to the passed in tensor which triggers the side
304 effects or the given tensor, if it was already been subscribed.
305 """
306
307 with ops.device(tensor.device):
308 with _preserve_control_flow_context(tensor):
309 return _subscribe(tensor, side_effects, control_cache)
310
311
312def subscribe(tensors, side_effects):

Callers 1

subscribeFunction · 0.85

Calls 3

_subscribeFunction · 0.85
deviceMethod · 0.45

Tested by

no test coverage detected