[Bugfix][MiniCPM-o] Fix cuda/cpu device mismatch in Resampler2_5 pos_embed (#43844)
Signed-off-by: Parth Ashwin Jain <parthash@amd.com> Co-authored-by: Parth Ashwin Jain <parthash@amd.com> Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Parth Ashwin Jain
Cyrus Leung
mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent
f843ac1a1c
commit
e6fc848d4f
@@ -217,7 +217,9 @@ class Resampler2_5(BaseResampler):
|
||||
for i in range(bs):
|
||||
tgt_h, tgt_w = tgt_sizes[i].tolist()
|
||||
pos_embed.append(
|
||||
self.pos_embed[:tgt_h, :tgt_w, :].reshape((tgt_h * tgt_w, -1)).to(dtype)
|
||||
self.pos_embed[:tgt_h, :tgt_w, :]
|
||||
.reshape((tgt_h * tgt_w, -1))
|
||||
.to(device=device, dtype=dtype)
|
||||
) # patches * D
|
||||
key_padding_mask[i, patch_len[i] :] = True
|
||||
pos_embed = torch.nn.utils.rnn.pad_sequence(
|
||||
|
||||
Reference in New Issue
Block a user