End of the .data removal in torch/optim (#34211)

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/34211

Test Plan: Imported from OSS

Differential Revision: D20248684

Pulled By: albanD

fbshipit-source-id: 2294bfa41b82ff47f000bc98860780f59d7d4421
This commit is contained in:
albanD
2020-03-09 06:37:44 -07:00
committed by Facebook Github Bot
parent 7e55494502
commit 6e2bb1c054
12 changed files with 55 additions and 41 deletions

View File

@ -101,7 +101,6 @@ class SparseAdam(Optimizer):
bias_correction2 = 1 - beta2 ** state['step']
step_size = group['lr'] * math.sqrt(bias_correction2) / bias_correction1
# Need to avoid version tracking for parameter.
p.data.add_(make_sparse(-step_size * numer.div_(denom)))
p.add_(make_sparse(-step_size * numer.div_(denom)))
return loss