claverAI commited on
Commit
87b4538
·
verified ·
1 Parent(s): f6e9da6

proposed patch for the Tensor size mismatch error

Browse files

Patch proposed for this error type:
"RuntimeError: The expanded size of the tensor (750) must match the existing size (751) at non-singleton dimension 1. Target sizes: [1, 750]. Tensor sizes: [1, 751]"

Patch issued on GitHub: https://github.com/vikhyat/moondream/issues/50#issuecomment-1971789438, by https://github.com/JohnnyStreet

Files changed (1) hide show
  1. modeling_phi.py +1 -0
modeling_phi.py CHANGED
@@ -315,6 +315,7 @@ class CrossAttention(nn.Module):
315
  dtype=scores.dtype,
316
  device=scores.device,
317
  )
 
318
  padding_mask.masked_fill_(key_padding_mask, 0.0)
319
  scores = scores + rearrange(padding_mask, "b s -> b 1 1 s")
320
 
 
315
  dtype=scores.dtype,
316
  device=scores.device,
317
  )
318
+ key_padding_mask = key_padding_mask[:, :seqlen_k]
319
  padding_mask.masked_fill_(key_padding_mask, 0.0)
320
  scores = scores + rearrange(padding_mask, "b s -> b 1 1 s")
321