-
Notifications
You must be signed in to change notification settings - Fork 27.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed OwlViTModel inplace operations #24529
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for opening the PR to fix it.
LGTM, but ping a core maintainer @sgugger to have a look too.
@@ -1293,8 +1293,8 @@ def forward( | |||
return (pred_logits, image_class_embeds) | |||
|
|||
# Normalize image and text features | |||
image_class_embeds /= torch.linalg.norm(image_class_embeds, dim=-1, keepdim=True) + 1e-6 | |||
query_embeds /= torch.linalg.norm(query_embeds, dim=-1, keepdim=True) + 1e-6 | |||
image_class_embeds = image_class_embeds / torch.linalg.norm(image_class_embeds, dim=-1, keepdim=True) + 1e-6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait. I think we should do
(torch.linalg.norm(image_class_embeds, dim=-1, keepdim=True) + 1e-6) instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
image_class_embeds = image_class_embeds / torch.linalg.norm(image_class_embeds, dim=-1, keepdim=True) + 1e-6 | |
image_class_embeds = image_class_embeds / (torch.linalg.norm(image_class_embeds, dim=-1, keepdim=True) + 1e-6) |
@@ -1293,8 +1293,8 @@ def forward( | |||
return (pred_logits, image_class_embeds) | |||
|
|||
# Normalize image and text features | |||
image_class_embeds /= torch.linalg.norm(image_class_embeds, dim=-1, keepdim=True) + 1e-6 | |||
query_embeds /= torch.linalg.norm(query_embeds, dim=-1, keepdim=True) + 1e-6 | |||
image_class_embeds = image_class_embeds / torch.linalg.norm(image_class_embeds, dim=-1, keepdim=True) + 1e-6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
image_class_embeds = image_class_embeds / torch.linalg.norm(image_class_embeds, dim=-1, keepdim=True) + 1e-6 | |
image_class_embeds = image_class_embeds / (torch.linalg.norm(image_class_embeds, dim=-1, keepdim=True) + 1e-6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with @ydshieh suggestions, thanks!
The documentation is not available anymore as the PR was closed or merged. |
@pasqualedem Could you apply the commit suggestions, then we can merge 🙏 Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again!
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. |
What does this PR do?
This PR replaces the "/=" operator in OwlViTModel which causes an error in the backward pass with the non-inplace version.
Fixes #24525
#24525
Who can review?
@ydshieh