Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/models/llama/rope.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import math
from functools import partial
from typing import Optional, Tuple
from typing import Optional, Tuple, Union

import torch
from executorch.examples.models.llama.model_args import ModelArgs
Expand Down Expand Up @@ -47,9 +47,10 @@ def precompute_freqs_cis(
use_scaled: bool = False,
scale_factor: Optional[int] = None,
high_freq_factor: int = 4,
device: Union[str, torch.device] = "cpu",
):
freqs = 1.0 / (
theta ** (torch.arange(0, dim, 2, device="cpu")[: (dim // 2)].float() / dim)
theta ** (torch.arange(0, dim, 2, device=device)[: (dim // 2)].float() / dim)
)
t = torch.arange(end, device=freqs.device) # pyre-ignore
if use_scaled:
Expand Down
Loading