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

Function _colocate_with_for_gradient

tensorflow/python/framework/ops.py:5271–5288  ·  view source on GitHub ↗
(op, gradient_uid, ignore_existing=False)

Source from the content-addressed store, hash-verified

5269
5270
5271def _colocate_with_for_gradient(op, gradient_uid, ignore_existing=False):
5272 if context.executing_eagerly():
5273 if op is not None:
5274 if not hasattr(op, "device"):
5275 op = internal_convert_to_tensor_or_indexed_slices(op)
5276 return device(op.device)
5277 else:
5278 return NullContextmanager()
5279 else:
5280 default_graph = get_default_graph()
5281 if isinstance(op, EagerTensor):
5282 if default_graph.building_function:
5283 return default_graph.device(op.device)
5284 else:
5285 raise ValueError("Encountered an Eager-defined Tensor during graph "
5286 "construction, but a function was not being built.")
5287 return default_graph._colocate_with_for_gradient(
5288 op, gradient_uid=gradient_uid, ignore_existing=ignore_existing)
5289
5290
5291# Internal interface to colocate_with. colocate_with has been deprecated from

Callers 1

colocate_withFunction · 0.85

Calls 7

NullContextmanagerClass · 0.85
get_default_graphFunction · 0.85
executing_eagerlyMethod · 0.80
deviceFunction · 0.70
deviceMethod · 0.45

Tested by

no test coverage detected