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

Function _is_subscribed_identity

tensorflow/python/framework/subscribe.py:183–214  ·  view source on GitHub ↗

Checks if the given tensor is an identity op returned by `subscribe()`. Args: tensor: A `tf.Tensor` to check. Returns: True if the given tensor matches the criteria for subscription identies: its op type is `Identity`, its name matches the name of its input and conforms to the

(tensor)

Source from the content-addressed store, hash-verified

181
182
183def _is_subscribed_identity(tensor):
184 """Checks if the given tensor is an identity op returned by `subscribe()`.
185
186 Args:
187 tensor: A `tf.Tensor` to check.
188
189 Returns:
190 True if the given tensor matches the criteria for subscription identies:
191 its op type is `Identity`, its name matches the name of its input and
192 conforms to the convention for subscribed nodes.
193 False otherwise.
194 """
195 # Subscribed tensor are assumed to be identity ops.
196 if tensor.op.type != 'Identity':
197 return False
198
199 # Check that the tensor name matches the convention in place for identity ops
200 # created by subscribe().
201 match = re.match(r'(?P<prefix_name>^.*?)/subscription/Identity[^/]+',
202 tensor.name)
203 if match is None or len(match.groups()) != 1:
204 return False
205 prefix_name = match.group('prefix_name')
206
207 # Get a reference to the source tensor and check that it has a matching name.
208 assert len(tensor.op.inputs) == 1, 'Op {} must only have one input'.format(
209 tensor.op.name)
210 source_tensor = tensor.op.inputs[0]
211 if prefix_name != source_tensor.op.name:
212 return False
213
214 return True
215
216
217def _subscribe(tensor, side_effects, control_cache):

Callers 1

_subscribeFunction · 0.85

Calls 3

matchMethod · 0.45
groupMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected