(max_seq_len, dim, theta=10000)
| 222 | |
| 223 | @amp.autocast(enabled=False, device_type="cuda") |
| 224 | def rope_params(max_seq_len, dim, theta=10000): |
| 225 | assert dim % 2 == 0 |
| 226 | freqs = torch.outer( |
| 227 | torch.arange(max_seq_len), |
| 228 | 1.0 / torch.pow(theta, |
| 229 | torch.arange(0, dim, 2).to(torch.float64).div(dim))) |
| 230 | freqs = torch.polar(torch.ones_like(freqs), freqs) |
| 231 | return freqs |
| 232 | |
| 233 | |
| 234 | class WanRMSNorm(nn.Module): |