Skip to content

Commit

Permalink
Fix Tensor + Embedding error in some cases when using SiglipVisionMod…
Browse files Browse the repository at this point in the history
…el (#33994)

Fix Tensor + Embedding error in some cases

Co-authored-by: kaitolucifer <[email protected]>
  • Loading branch information
2 people authored and ArthurZucker committed Oct 7, 2024
1 parent ae5f491 commit b1c237f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/transformers/models/siglip/modeling_siglip.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def interpolate_pos_encoding(self, embeddings: torch.Tensor, height: int, width:

# always interpolate when tracing to ensure the exported model works for dynamic input shapes
if not torch.jit.is_tracing() and num_patches == num_positions and height == width:
return self.position_embedding
return self.position_embedding(self.position_ids)

patch_pos_embed = self.position_embedding.weight.unsqueeze(0)

Expand Down

0 comments on commit b1c237f

Please sign in to comment.