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

Method BuildCondBranch

tensorflow/python/ops/control_flow_ops.py:1058–1080  ·  view source on GitHub ↗

Add the subgraph defined by fn() to the graph.

(self, fn)

Source from the content-addressed store, hash-verified

1056 return self._ProcessOutputTensor(ops.convert_to_tensor(v))
1057
1058 def BuildCondBranch(self, fn):
1059 """Add the subgraph defined by fn() to the graph."""
1060 pre_summaries = ops.get_collection(ops.GraphKeys._SUMMARY_COLLECTION) # pylint: disable=protected-access
1061 original_result = fn()
1062 post_summaries = ops.get_collection(ops.GraphKeys._SUMMARY_COLLECTION) # pylint: disable=protected-access
1063 if len(post_summaries) > len(pre_summaries):
1064 new_summaries = post_summaries[len(pre_summaries):]
1065 summary_ref = ops.get_collection_ref(ops.GraphKeys._SUMMARY_COLLECTION) # pylint: disable=protected-access
1066 summary_ref[:] = pre_summaries
1067 with ops.control_dependencies(new_summaries):
1068 if original_result is None:
1069 return no_op(), None
1070 else:
1071 original_result = nest.map_structure(
1072 array_ops.identity, original_result, expand_composites=True)
1073 if original_result is None:
1074 return None, None
1075
1076 result = nest.map_structure(
1077 self._BuildCondTensor, original_result, expand_composites=True)
1078 if not isinstance(result, (list, _basetuple)):
1079 result = [result]
1080 return original_result, result
1081
1082 def IsCondContext(self):
1083 return True

Callers 1

condFunction · 0.95

Calls 4

get_collection_refMethod · 0.80
fnFunction · 0.70
get_collectionMethod · 0.45
control_dependenciesMethod · 0.45

Tested by

no test coverage detected