code clean up
Browse files
algorithms/dememwm/models/dit.py
CHANGED
|
@@ -158,23 +158,6 @@ class FrameMemoryReferenceAttention(nn.Module):
|
|
| 158 |
def _split_heads(self, x):
|
| 159 |
return rearrange(x, "b n (h d) -> b h n d", h=self.num_heads)
|
| 160 |
|
| 161 |
-
def _geometry_rays(
|
| 162 |
-
self,
|
| 163 |
-
geometry_cache,
|
| 164 |
-
B,
|
| 165 |
-
T_target,
|
| 166 |
-
T_memory,
|
| 167 |
-
H,
|
| 168 |
-
W,
|
| 169 |
-
device,
|
| 170 |
-
dtype,
|
| 171 |
-
):
|
| 172 |
-
if geometry_cache is None:
|
| 173 |
-
return None, None
|
| 174 |
-
return (
|
| 175 |
-
geometry_cache["query_rays"].to(device=device, dtype=dtype),
|
| 176 |
-
geometry_cache["relative_rays"].to(device=device, dtype=dtype),
|
| 177 |
-
)
|
| 178 |
|
| 179 |
def forward(self, target_hidden, memory_hidden, memory_mask=None, geometry_cache=None):
|
| 180 |
B, T_target, H, W, D = target_hidden.shape
|
|
@@ -183,16 +166,12 @@ class FrameMemoryReferenceAttention(nn.Module):
|
|
| 183 |
|
| 184 |
T_memory = memory_hidden.shape[1]
|
| 185 |
P = H * W
|
| 186 |
-
|
| 187 |
-
geometry_cache,
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
W,
|
| 193 |
-
target_hidden.device,
|
| 194 |
-
target_hidden.dtype,
|
| 195 |
-
)
|
| 196 |
q_input = target_hidden
|
| 197 |
if query_rays is not None:
|
| 198 |
# Values stay visual-only; Plucker features only steer Q/K matching.
|
|
|
|
| 158 |
def _split_heads(self, x):
|
| 159 |
return rearrange(x, "b n (h d) -> b h n d", h=self.num_heads)
|
| 160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
def forward(self, target_hidden, memory_hidden, memory_mask=None, geometry_cache=None):
|
| 163 |
B, T_target, H, W, D = target_hidden.shape
|
|
|
|
| 166 |
|
| 167 |
T_memory = memory_hidden.shape[1]
|
| 168 |
P = H * W
|
| 169 |
+
if geometry_cache is not None:
|
| 170 |
+
query_rays = geometry_cache["query_rays"].to(device=target_hidden.device, dtype=target_hidden.dtype)
|
| 171 |
+
relative_rays = geometry_cache["relative_rays"].to(device=target_hidden.device, dtype=target_hidden.dtype)
|
| 172 |
+
else:
|
| 173 |
+
query_rays = None
|
| 174 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
q_input = target_hidden
|
| 176 |
if query_rays is not None:
|
| 177 |
# Values stay visual-only; Plucker features only steer Q/K matching.
|