torch.arange default return type is changed in the latest pytorch version
MODIFY
fairseq/modules/sinusoidal_positional_embedding.py
fairseq/modules/sinusoidal_positional_embedding.py
@@ -42,8 +42,8 @@ class SinusoidalPositionalEmbedding(nn.Module):
"""
half_dim = embedding_dim // 2
emb = math.log(10000) / (half_dim - 1)
- emb = torch.exp(torch.arange(half_dim) * -emb)
- emb = torch.arange(num_embeddings).unsqueeze(1) * emb.unsqueeze(0)
+ emb = torch.exp(torch.arange(half_dim, dtype=torch.float) * -emb)
+ emb = torch.arange(num_embeddings, dtype=torch.float).unsqueeze(1) * emb.unsqueeze(0)
emb = torch.cat([torch.sin(emb), torch.cos(emb)], dim=1).view(num_embeddings, -1)
if embedding_dim % 2 == 1:
# zero pad

torch.arange default return type is changed in the latest pytorch version https://github.com/pytorch/pytorch/pull/7016