(version: str, *, position: torch.Tensor)
| 7 | |
| 8 | |
| 9 | def encode_position(version: str, *, position: torch.Tensor): |
| 10 | if version == "v1": |
| 11 | freqs = get_scales(0, 10, position.dtype, position.device).view(1, -1) |
| 12 | freqs = position.reshape(-1, 1) * freqs |
| 13 | return torch.cat([freqs.cos(), freqs.sin()], dim=1).reshape(*position.shape[:-1], -1) |
| 14 | elif version == "nerf": |
| 15 | return posenc_nerf(position, min_deg=0, max_deg=15) |
| 16 | else: |
| 17 | raise ValueError(version) |
| 18 | |
| 19 | |
| 20 | def encode_channels(version: str, *, channels: torch.Tensor): |
no test coverage detected