Commit 2de93532 authored by Sergey Edunov's avatar Sergey Edunov Committed by Myle Ott
Browse files

torch.arange default return type is changed in the latest pytorch version...

torch.arange default return type is changed in the latest pytorch version https://github.com/pytorch/pytorch/pull/7016
parent fc87eea2
Loading
Loading
Loading
Loading
+2 −2
Changes for fairseq/modules/sinusoidal_positional_embedding.py: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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