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 optional chaining for batch size calculation in PreTrainedModel #1063

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

emojiiii
Copy link
Contributor

@emojiiii emojiiii commented Dec 2, 2024

image

@emojiiii
Copy link
Contributor Author

emojiiii commented Dec 2, 2024

This pull request includes a minor change to the PreTrainedModel class in the src/models.js file. The change improves the robustness of the code by using optional chaining to handle undefined values more gracefully.

  • src/models.js: Modified the batch_size calculation to use optional chaining for accessing dims property, ensuring the code handles cases where dims might be undefined.

@xenova
Copy link
Collaborator

xenova commented Dec 2, 2024

Thanks for the PR! Can you provide the sample code which produces the error?

@emojiiii
Copy link
Contributor Author

emojiiii commented Dec 2, 2024

Thanks for the PR! Can you provide the sample code which produces the error?

I found this when running the example code

Copy link
Collaborator

@xenova xenova left a comment

Choose a reason for hiding this comment

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

Thanks! I can confirm this fixes the issue.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@xenova xenova merged commit aead8a9 into huggingface:main Dec 2, 2024
4 checks passed
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