Skip to content
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

Fix deprecation warnings for int div #15180

Merged
merged 6 commits into from
Jan 18, 2022
Merged

Fix deprecation warnings for int div #15180

merged 6 commits into from
Jan 18, 2022

Conversation

sgugger
Copy link
Collaborator

@sgugger sgugger commented Jan 17, 2022

Co-authored-by: mgoldey matthew.goldey@gmail.com

What does this PR do?

This PR fixes the int div warnings by using the new API in PyTorch for versions >= 1.8 all the while keeping backward compatibility with older versions.

Supersedes #14577

Co-authored-by: mgoldey <matthew.goldey@gmail.com>
Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -302,6 +302,8 @@ def __call__(self, features: List[Dict[str, Union[List[int], torch.Tensor]]]) ->
batch_size = batch["input_values"].shape[0]

mask_indices_seq_length = self.model._get_feat_extract_output_lengths(batch["input_values"].shape[-1])
# make sure masked sequence length is a Python scalar
mask_indices_seq_length = int(mask_indices_seq_length)
Copy link
Contributor

@patrickvonplaten patrickvonplaten Jan 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure that torch.tensor(...) is casted to Python scalar if necessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants