Debug _merge_tokens shapes
This commit is contained in:
parent
ffb3c9e729
commit
b9dcdda116
1 changed files with 2 additions and 0 deletions
|
|
@ -676,6 +676,8 @@ class Qwen3VL32BVision(nn.Module):
|
|||
"""Flatten 2x2 spatial-merge blocks (the reference's pre-merge flatten)."""
|
||||
t, h, w = (int(v) for v in grid_thw.tolist()[0])
|
||||
merge = 2
|
||||
if x.ndim != 2 or x.shape[0] != t * h * w:
|
||||
print(f"[merge_tokens] x.shape={tuple(x.shape)}, grid={(t, h, w)}, expected N={t*h*w}")
|
||||
return x.view(t, h // merge, merge, w // merge, merge, -1).permute(0, 1, 3, 2, 4, 5).reshape(-1, -1)
|
||||
|
||||
def forward(self, flatten_patches: torch.Tensor, grid_thw: torch.Tensor) -> tuple[torch.Tensor, list[torch.Tensor]]:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue