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

Function _enclosing_tpu_context

tensorflow/python/distribute/values.py:1091–1105  ·  view source on GitHub ↗

Returns the XLAControlFlowContext, which exists inside a tpu.rewrite().

()

Source from the content-addressed store, hash-verified

1089
1090
1091def _enclosing_tpu_context():
1092 """Returns the XLAControlFlowContext, which exists inside a tpu.rewrite()."""
1093 graph = ops.get_default_graph()
1094 while graph is not None:
1095 # pylint: disable=protected-access
1096 context_ = graph._get_control_flow_context()
1097 # pylint: enable=protected-access
1098 while context_ is not None:
1099 if isinstance(context_, control_flow_ops.XLAControlFlowContext):
1100 return context_
1101 context_ = context_.outer_context
1102 # This may be a FuncGraph due to defuns or v2 control flow. We need to
1103 # find the original graph with the XLAControlFlowContext.
1104 graph = getattr(graph, "outer_graph", None)
1105 return None
1106
1107
1108def is_distributed_variable(v):

Callers 11

__getattr__Method · 0.70
getMethod · 0.70
_get_closestMethod · 0.70
handleMethod · 0.70
read_valueMethod · 0.70
_as_graph_elementMethod · 0.70
_dense_var_to_tensorMethod · 0.70
_assign_funcMethod · 0.70
assign_subMethod · 0.70
assign_addMethod · 0.70
assignMethod · 0.70

Calls 1

Tested by

no test coverage detected