Update gemma.py
This commit is contained in:
parent
045bce2fa5
commit
e56eb3f406
1 changed files with 2 additions and 2 deletions
|
|
@ -70,12 +70,12 @@ class FastGemmaRotaryEmbedding(torch.nn.Module):
|
|||
# x: [bs, num_attention_heads, seq_len, head_size]
|
||||
if self.inv_freq is None:
|
||||
self.inv_freq = 1.0 / (
|
||||
self.base ** (torch.arange(0, self.dim, 2, dtype=torch.int64, device=x.device).float() / self.dim)
|
||||
self.base ** (torch.arange(0, self.dim, 2, dtype=torch.int64, device="cpu").float() / self.dim)
|
||||
)
|
||||
|
||||
t = torch.arange(self.max_position_embeddings, device="cpu", dtype=torch.int64).float()
|
||||
freqs = torch.outer(t, self.inv_freq)
|
||||
emb = torch.cat((freqs, freqs), dim=-1)
|
||||
emb = torch.cat((freqs, freqs), dim=-1).to("cuda")
|
||||
|
||||
# inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1)
|
||||
# position_ids_expanded = position_ids[:, None, :].float()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue