facebookresearch/fairseq

Why inplace operation in `AdaptiveSoftmax`

Open

#760 geöffnet am 28. Mai 2019

Auf GitHub ansehen
 (6 Kommentare) (1 Reaktion) (1 zugewiesene Person)Python (6.224 Forks)batch import
enhancementhelp wantedstale

Repository-Metriken

Stars
 (29.107 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

I used log_output for training purpose, but pytorch complains about inplace operation on backward.

For lines 204 and 205: https://github.com/pytorch/fairseq/blob/e6422528dae0b899848469efe2dc404c1e639ce9/fairseq/modules/adaptive_softmax.py#L200-L208

  1. why doing a copy_ on tailout
  2. why inplace add_

I changed to

tail_output = ...
... = self.lsm(tail_out) + tail_priors[idxs, i, None]

And it works for training.

Contributor Guide