Skip to content

Commit

Permalink
Merge pull request #1820 from MlaikahImdad/fix-clip-half-error
Browse files Browse the repository at this point in the history
  • Loading branch information
mikel-brostrom authored Feb 15, 2025
2 parents 0404fa0 + 0e43fbd commit 6052830
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions boxmot/appearance/backbones/clip/clip/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,11 @@ class LayerNorm(nn.LayerNorm):

def forward(self, x: torch.Tensor):
orig_type = x.dtype
ret = super().forward(x.type(torch.float32))
return ret.type(orig_type)
for param in self.parameters():
if param.dtype == torch.float16:
param.data = param.data.to(torch.float32)
ret = super().forward(x.to(torch.float32))
return ret.to(orig_type)


class QuickGELU(nn.Module):
Expand Down

0 comments on commit 6052830

Please sign in to comment.