Skip to content

Commit

Permalink
fixing arange not knowing half on cpu
Browse files Browse the repository at this point in the history
  • Loading branch information
blefaudeux committed Jun 4, 2022
1 parent 0ef428a commit 50f6da4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion xformers/components/positional_embedding/rotary.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def _update_cos_sin_tables(self, x, seq_dimension=1):
or self._cos_cached.dtype != x.dtype
):
self._seq_len_cached = seq_len
t = torch.arange(x.shape[seq_dimension], device=x.device, dtype=x.dtype)
t = torch.arange(
x.shape[seq_dimension], device=x.device, dtype=torch.float32
).to(x.dtype)
freqs = torch.einsum("i,j->ij", t, self.inv_freq.to(x.dtype))
emb = torch.cat((freqs, freqs), dim=-1).to(x.device)

Expand Down

0 comments on commit 50f6da4

Please sign in to comment.