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

Function _subscribe_extend

tensorflow/python/framework/subscribe.py:155–180  ·  view source on GitHub ↗

Helper method to extend the list of side_effects for a subscribed tensor. Args: tensor: A `tf.Tensor` as returned by subscribe(). side_effects: List of side_effect functions, see subscribe for details. Returns: The given subscribed tensor (for API consistency).

(tensor, side_effects)

Source from the content-addressed store, hash-verified

153
154
155def _subscribe_extend(tensor, side_effects):
156 """Helper method to extend the list of side_effects for a subscribed tensor.
157
158 Args:
159 tensor: A `tf.Tensor` as returned by subscribe().
160 side_effects: List of side_effect functions, see subscribe for details.
161
162 Returns:
163 The given subscribed tensor (for API consistency).
164 """
165 assert len(tensor.op.inputs) == 1, 'Op {} must only have one input'.format(
166 tensor.op.name)
167 source_tensor = tensor.op.inputs[0]
168
169 # Build the side effect graphs and add their outputs to the list of control
170 # dependencies for the subscribed tensor.
171 outs = []
172 name_scope = source_tensor.op.name + '/subscription/'
173 with ops.name_scope(name_scope):
174 for s in side_effects:
175 outs += s(source_tensor)
176
177 out_ops = [out.op if isinstance(out, ops.Tensor) else out for out in outs]
178 tensor.op._add_control_inputs(out_ops) # pylint: disable=protected-access
179
180 return tensor
181
182
183def _is_subscribed_identity(tensor):

Callers 1

_subscribeFunction · 0.85

Calls 3

_add_control_inputsMethod · 0.80
formatMethod · 0.45
name_scopeMethod · 0.45

Tested by

no test coverage detected