Skip to content

Commit 66050c2

Browse files
eellisonfacebook-github-bot
authored andcommitted
Moco Inplace Update Params (#1693)
Summary: The out of place .data manipulation is slower/more memory, and doesnt work with cudagraphs. Upstream pr link: facebookresearch/moco#141 Pull Request resolved: #1693 Reviewed By: xuzhao9 Differential Revision: D46453742 Pulled By: eellison fbshipit-source-id: 2072103ba9edd29444ff8cc16b6dc393c4f7a95d
1 parent db37ddd commit 66050c2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torchbenchmark/models/moco/moco/builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _momentum_update_key_encoder(self):
4747
Momentum update of the key encoder
4848
"""
4949
for param_q, param_k in zip(self.encoder_q.parameters(), self.encoder_k.parameters()):
50-
param_k.data = param_k.data * self.m + param_q.data * (1. - self.m)
50+
param_k.mul_(self.m).add_(param_q.mul(1. - self.m))
5151

5252
@torch.no_grad()
5353
def _dequeue_and_enqueue(self, keys):

0 commit comments

Comments
 (0)