MCPcopy
hub / github.com/microsoft/Cream / sync

Method sync

TinyViT/my_meter.py:58–74  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

56 return self._avg
57
58 def sync(self):
59 buf = torch.tensor([self._sum, self._count],
60 dtype=torch.float32)
61 if self._use_gpu:
62 buf = buf.cuda()
63 dist.all_reduce(buf, op=dist.ReduceOp.SUM)
64 _sum, _count = buf.tolist()
65 _avg = _sum / max(1, _count)
66 r = self._history_count / max(1, self._history_count + _count)
67
68 self._history_avg = r * self._history_avg + (1.0 - r) * _avg
69 self._history_count += _count
70
71 self._sum = 0
72 self._count = 0
73
74 self._avg = None

Callers 3

validateFunction · 0.95
validateFunction · 0.95

Calls 1

tolistMethod · 0.80

Tested by

no test coverage detected