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

Function IsCondSwitch

tensorflow/python/ops/control_flow_util.py:112–130  ·  view source on GitHub ↗

Return true if `op` is the Switch for a conditional.

(op)

Source from the content-addressed store, hash-verified

110
111
112def IsCondSwitch(op):
113 """Return true if `op` is the Switch for a conditional."""
114 if not IsSwitch(op):
115 return False
116 if not op.outputs:
117 return False
118 # Switch nodes are not part of the cond control flow context that they
119 # represent, so consider the consumers of its outputs to determine if it is
120 # cond switch or not. A switch is a cond switch iff all its consumers are in
121 # cond contexts.
122 is_cond_switch = True
123 for o in op.outputs:
124 for c in o.consumers():
125 ctxt = c._get_control_flow_context() # pylint: disable=protected-access
126 if IsLoopEnter(c):
127 ctxt = ctxt.outer_context
128 is_cond_switch = is_cond_switch and (ctxt is not None and
129 ctxt.IsCondContext())
130 return is_cond_switch
131
132
133def IsCondMerge(op):

Callers 1

IsLoopSwitchFunction · 0.85

Calls 5

IsLoopEnterFunction · 0.85
IsSwitchFunction · 0.70
consumersMethod · 0.45
IsCondContextMethod · 0.45

Tested by

no test coverage detected