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 empty tensor deserialization #131

Merged

Conversation

enrico-stauss
Copy link
Contributor

What does this PR do?

When trying to deserialize tensors that were empty in the first place, the torch.frombuffer` method would fail due to an empty buffer. This PR fixes the issue by simply checking the buffer length and if the latter is 0, initializing a fresh tensor with no data but the correct shape and dtype.

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in GitHub issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

Copy link

codecov bot commented May 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@58b158a). Learn more about missing BASE report.

Additional details and impacted files
@@          Coverage Diff          @@
##             main   #131   +/-   ##
=====================================
  Coverage        ?    77%           
=====================================
  Files           ?     30           
  Lines           ?   3990           
  Branches        ?      0           
=====================================
  Hits            ?   3060           
  Misses          ?    930           
  Partials        ?      0           

Copy link
Collaborator

@tchaton tchaton left a comment

Choose a reason for hiding this comment

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

Looks great !

@tchaton tchaton merged commit d027730 into Lightning-AI:main May 19, 2024
27 of 28 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.

2 participants