-
Notifications
You must be signed in to change notification settings - Fork 29
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
Sentence Transformers T5 GPU issue #50
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.
Looks good to me. We should add CI/CD smoke tests with GPU for this model
if self.cuda: | ||
labels = torch.tensor(labels).to(self.cuda_core) | ||
else: | ||
labels = torch.tensor(labels) |
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.
I'm thinking of refactoring this code into this, would this still work?
labels = torch.tensor(labels)
if self.cuda:
labels = labels.to(self.cuda_core)
if self.cuda: | ||
sum_embeddings = torch.sum(embeddings * input_mask_expanded, 1).to(self.cuda_core) | ||
sum_mask = torch.clamp(input_mask_expanded.sum(1), min=1e-9).to(self.cuda_core) | ||
return sum_embeddings, sum_mask | ||
else: | ||
sum_embeddings = torch.sum(embeddings * input_mask_expanded, 1) | ||
sum_mask = torch.clamp(input_mask_expanded.sum(1), min=1e-9) | ||
return sum_embeddings, sum_mask |
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.
and this portion of code I'm thinking of refactoring to:
sum_embeddings = torch.sum(embeddings * input_mask_expanded, 1)
if self.cuda:
sum_embeddings = sum_embeddings.to(self.cuda_core)
sum_mask = torch.clamp(input_mask_expanded.sum(1), min=1e-9)
if self.cuda:
sum_mask = sum_mask.to(self.cuda_core)
return sum_embeddings, sum_mask
9a88c38
to
d502a54
Compare
No description provided.