Commit 1f5b414f authored by Ning Dong's avatar Ning Dong Committed by Facebook Github Bot
Browse files

Support Latent Variable Model in base training (#879)

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

Pull Request resolved: https://github.com/pytorch/translate/pull/598

Details in https://fb.workplace.com/notes/ning-dong/closing-research-to-production-gap-a-story-of-latent-variable-model-migration/443418839813586/

Reviewed By: xianxl

Differential Revision: D15742439

fbshipit-source-id: 168c84bd30a5da3c2fb404fcca74266deef1f964
parent e46b924d
......@@ -36,7 +36,8 @@ class LearnedPositionalEmbedding(nn.Embedding):
if positions is None:
if incremental_state is not None:
# positions is the same for every token when decoding a single step
positions = input.data.new(1, 1).fill_(self.padding_idx + input.size(1))
# Without the int() cast, it doesn't work in some cases when exporting to ONNX
positions = input.data.new(1, 1).fill_(int(self.padding_idx + input.size(1)))
else:
positions = utils.make_positions(
input.data, self.padding_idx, onnx_trace=self.onnx_trace,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment