Exemplo n.º 1
0
 def _experimental_distribute_values_from_function(self, value_fn):
   per_replica_values = []
   for replica_id in range(self._num_replicas_in_sync):
     per_replica_values.append(value_fn(
         distribute_lib.ValueContext(replica_id,
                                     self._num_replicas_in_sync)))
   return distribute_utils.regroup(per_replica_values, always_wrap=True)
Exemplo n.º 2
0
 def _experimental_distribute_values_from_function(self, value_fn):
     per_replica_values = []
     num_local_replicas = len(self.worker_devices)
     for local_replica_id in range(num_local_replicas):
         replica_id = (self._id_in_cluster * num_local_replicas +
                       local_replica_id)
         value_context = distribute_lib.ValueContext(
             replica_id, self._num_replicas_in_sync)
         per_replica_values.append(value_fn(value_context))
     return distribute_utils.regroup(per_replica_values, always_wrap=True)
Exemplo n.º 3
0
 def _experimental_distribute_values_from_function(self, value_fn):
     # TODO(b/137795644): This should return a PerReplica value but other
     # methods like run in OneDeviceStrategy need to be modified
     # to do the same.
     return value_fn(distribute_lib.ValueContext())