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

Method assign

tensorflow/python/distribute/values.py:1212–1224  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

1210 return self.get().assign_add(*args, **kwargs)
1211
1212 def assign(self, *args, **kwargs):
1213 with _enter_or_assert_strategy(self._distribute_strategy):
1214 if distribution_strategy_context.in_cross_replica_context():
1215 # To preserve the sum across save and restore, we have to divide the
1216 # total across all devices when restoring a variable that was summed
1217 # when saving.
1218 tensor = args[0]
1219 if self._aggregation == vs.VariableAggregation.SUM:
1220 tensor *= 1. / len(self.devices)
1221 return control_flow_ops.group(tuple(
1222 _assign_on_device(v.device, v, tensor) for v in self._values))
1223 else:
1224 return self.get().assign(*args, **kwargs)
1225
1226 @property
1227 def aggregation(self):

Callers

nothing calls this directly

Calls 6

tupleFunction · 0.85
_assign_on_deviceFunction · 0.85
groupMethod · 0.45
assignMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected