facebookresearch/fairseq

Why inplace operation in `AdaptiveSoftmax`

Open

#760 建立於 2019年5月28日

在 GitHub 查看
 (6 留言) (1 反應) (1 負責人)Python (6,224 fork)batch import
enhancementhelp wantedstale

倉庫指標

Star
 (29,107 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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.

貢獻者指南