|
12 | 12 | from dataclasses import dataclass |
13 | 13 | from typing import TYPE_CHECKING |
14 | 14 |
|
15 | | -import torch |
16 | | - |
17 | 15 | if TYPE_CHECKING: |
18 | 16 | from collections.abc import Iterator |
19 | 17 |
|
@@ -85,39 +83,3 @@ def iter_packed_entries() -> Iterator[PackedWignerEntry]: |
85 | 83 | full_row=full_row, |
86 | 84 | full_col=block_start + local_col, |
87 | 85 | ) |
88 | | - |
89 | | - |
90 | | -def pack_dense_reference(d_full: torch.Tensor) -> torch.Tensor: |
91 | | - """Gather a dense block-diagonal matrix for CPU differential tests only.""" |
92 | | - entries = tuple(iter_packed_entries()) |
93 | | - rows = [entry.full_row for entry in entries] |
94 | | - cols = [entry.full_col for entry in entries] |
95 | | - return d_full[..., rows, cols] |
96 | | - |
97 | | - |
98 | | -def phase_a_reference(panel: torch.Tensor, x_wide: torch.Tensor) -> torch.Tensor: |
99 | | - """Reference ``D[coeff_index_m] @ x_wide`` without dense unpacking.""" |
100 | | - outputs = [] |
101 | | - for reduced, degree in enumerate(REDUCED_DEGREES): |
102 | | - block_start = FULL_BLOCK_OFFSETS[degree] |
103 | | - block_stop = FULL_BLOCK_OFFSETS[degree + 1] |
104 | | - row_start = REDUCED_PANEL_ROW_OFFSETS[reduced] |
105 | | - values = panel[..., row_start : row_start + block_stop - block_start] |
106 | | - x_block = x_wide[..., block_start:block_stop, :] |
107 | | - outputs.append((values.unsqueeze(-1) * x_block).sum(dim=-2)) |
108 | | - return torch.stack(outputs, dim=-2) |
109 | | - |
110 | | - |
111 | | -def phase_c_reference(panel: torch.Tensor, x_local: torch.Tensor) -> torch.Tensor: |
112 | | - """Reference ``Dt[:, :, coeff_index_m] @ x_local`` from the same panel.""" |
113 | | - outputs = [] |
114 | | - for full_row in range(FULL_BLOCK_OFFSETS[-1]): |
115 | | - value = torch.zeros_like(x_local[..., 0, :]) |
116 | | - for reduced in range(len(COEFF_INDEX_M)): |
117 | | - offset = dt_offset(full_row, reduced) |
118 | | - if offset is not None: |
119 | | - value = ( |
120 | | - value + panel[..., offset].unsqueeze(-1) * x_local[..., reduced, :] |
121 | | - ) |
122 | | - outputs.append(value) |
123 | | - return torch.stack(outputs, dim=-2) |
0 commit comments