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

Re-enable passing BytesIO as path in .to_onnx() #20172

Merged
merged 4 commits into from
Aug 7, 2024

Conversation

GdoongMathew
Copy link
Contributor

@GdoongMathew GdoongMathew commented Aug 6, 2024

What does this PR do?

Fixes #20171

In to_onnx, only convert file_path to string when its a Path instance, and keep io.BytesIO intact and pass it to torch.export.onnx.

Before submitting
  • Was this discussed/agreed via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

📚 Documentation preview 📚: https://pytorch-lightning--20172.org.readthedocs.build/en/20172/

@github-actions github-actions bot added the pl Generic label for PyTorch Lightning package label Aug 6, 2024
Copy link

codecov bot commented Aug 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81%. Comparing base (a3e60ad) to head (e858928).
Report is 30 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (a3e60ad) and HEAD (e858928). Click for more details.

HEAD has 84 uploads less than BASE
Flag BASE (a3e60ad) HEAD (e858928)
cpu 41 21
lightning 30 16
pytest 24 2
python3.9 12 6
python3.11 12 6
gpu 3 2
lightning_fabric 7 0
python3.10 11 6
python3.12 6 3
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #20172     +/-   ##
=========================================
- Coverage      88%      81%     -7%     
=========================================
  Files         267      264      -3     
  Lines       23076    23023     -53     
=========================================
- Hits        20280    18613   -1667     
- Misses       2796     4410   +1614     

Copy link
Contributor

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the PR! To complete it, we need to add a test. Could we extend the same test as in #19727 by passing in a bytes io? Let me know if you need help with that.

src/lightning/pytorch/core/module.py Outdated Show resolved Hide resolved
@awaelchli awaelchli added bug Something isn't working community This PR is from the community labels Aug 6, 2024
@Borda Borda changed the title fix: change path to str if file_path is Path instance. (fix #20171) fix: change path to str if file_path is Path instance Aug 7, 2024
@GdoongMathew
Copy link
Contributor Author

Hi @awaelchli
Test case was added in that testing function. Thanks.

@awaelchli awaelchli added this to the 2.4.x milestone Aug 7, 2024
Copy link
Contributor

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

That looks great, thanks for adding the test!

@awaelchli awaelchli changed the title fix: change path to str if file_path is Path instance Re-enable passing BytesIO as path in .to_onnx() Aug 7, 2024
@awaelchli awaelchli merged commit 828fd99 into Lightning-AI:master Aug 7, 2024
74 checks passed
@GdoongMathew GdoongMathew deleted the fix/to_onnx branch August 7, 2024 15:12
Borda pushed a commit that referenced this pull request Sep 26, 2024
lexierule pushed a commit that referenced this pull request Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community This PR is from the community pl Generic label for PyTorch Lightning package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent input io type between to_onnx and torch.onnx.export.
2 participants