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)
| 288 | |
| 289 | |
| 290 | def _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 | |
| 312 | def subscribe(tensors, side_effects): |
no test coverage detected