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

Method AddValue

tensorflow/python/ops/control_flow_ops.py:935–969  ·  view source on GitHub ↗

Add `val` to the current context and its outer context recursively.

(self, val)

Source from the content-addressed store, hash-verified

933 context_def.cond_ctxt.CopyFrom(self.to_proto(export_scope=export_scope))
934
935 def AddValue(self, val):
936 """Add `val` to the current context and its outer context recursively."""
937 if val.name in self._values:
938 # Use the real value if it comes from outer context. This is needed in
939 # particular for nested conds.
940 result = self._external_values.get(val.name)
941 result = val if result is None else result
942 else:
943 result = val
944 self._values.add(val.name)
945 if self._outer_context:
946 result = self._outer_context.AddValue(val)
947 self._values.add(result.name)
948 self._external_values[result.name] = result
949 with ops.control_dependencies(None):
950 result = _SwitchRefOrTensor(result, self._pred)[self._branch]
951 if self._outer_context:
952 self._outer_context.AddInnerOp(result.op)
953
954 result.op.graph.prevent_fetching(result.op)
955 # pylint: disable=protected-access
956 result.op._set_control_flow_context(self)
957 # pylint: enable=protected-access
958
959 # Mark Switch output as seen by this context and any outer contexts,
960 # just like what we do for normal op outputs in _AddOpInternal() below.
961 ctxt = self
962 while ctxt is not None:
963 # pylint: disable=protected-access
964 ctxt._values.add(result.name)
965 ctxt = ctxt._outer_context
966 # pylint: enable=protected-access
967
968 self._external_values[val.name] = result
969 return result
970
971 def AddOp(self, op):
972 self._AddOpInternal(op)

Callers 6

_AddOpInternalMethod · 0.95
AddForwardAccumulatorMethod · 0.45
GetRealValueMethod · 0.45
_ProcessOutputTensorMethod · 0.45
AddValueMethod · 0.45
_BuildLoopMethod · 0.45

Calls 7

_SwitchRefOrTensorFunction · 0.85
prevent_fetchingMethod · 0.80
getMethod · 0.45
addMethod · 0.45
control_dependenciesMethod · 0.45
AddInnerOpMethod · 0.45

Tested by

no test coverage detected