e383c0d1a76b9f5c62d477e97230401e6f5a152f,opennmt/optimizers/utils.py,GradientAccumulator,__call__,#GradientAccumulator#Any#,78

Before Change


      raise ValueError("Expected %s gradients, but got %d" % (
          len(self._gradients), len(gradients)))

    for accum_gradient, gradient in zip(self._get_replica_gradients(), gradients):
      accum_gradient.assign_add(gradient)

    self._accum_steps.assign_add(1)

After Change


    // In a replica context, we want to accumulate gradients on each replica
    // without synchronization, so we directly assign the value of the
    // current replica.
    for accum_gradient, gradient in zip(_get_replica_local_variables(self._gradients), gradients):
      accum_gradient.assign_add(gradient)
    _get_replica_local_variables(self._accum_steps).assign_add(1)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: OpenNMT/OpenNMT-tf
Commit Name: e383c0d1a76b9f5c62d477e97230401e6f5a152f
Time: 2020-01-14
Author: guillaumekln@users.noreply.github.com
File Name: opennmt/optimizers/utils.py
Class Name: GradientAccumulator
Method Name: __call__


Project Name: OpenNMT/OpenNMT-tf
Commit Name: e383c0d1a76b9f5c62d477e97230401e6f5a152f
Time: 2020-01-14
Author: guillaumekln@users.noreply.github.com
File Name: opennmt/optimizers/utils.py
Class Name: GradientAccumulator
Method Name: reset


Project Name: OpenNMT/OpenNMT-tf
Commit Name: e383c0d1a76b9f5c62d477e97230401e6f5a152f
Time: 2020-01-14
Author: guillaumekln@users.noreply.github.com
File Name: opennmt/optimizers/utils.py
Class Name: GradientAccumulator
Method Name: gradients