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

Static Analysis corrections on c++ model classes #2893

Merged
merged 4 commits into from
Oct 26, 2020

Conversation

datumbox
Copy link
Contributor

Minor refactoring based on static analysis and manual review of the code of models:

  • Eliminate unnecessary value parameter to constant reference to avoid unnecessary copies.
  • Eliminate unused include.

Post discussion with @fmassa, we might not want these changes to keep the C++ API easy to understand. Let me know if there is any thing we want to cherrypick from here else feel free to close the PR.

- Convert unnecessary value parameter to constant reference.
- Use move to avoid unnecessary copies.
- Eliminate unused include.
Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

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

Changes look good to me overall, but I have a question wrt explicit constructors.

Also, FYI I believe we have disabled C++ model tests in torchvision CI

vision/setup.py

Line 169 in d8ccbe7

compile_cpp_tests = os.getenv('WITH_CPP_MODELS_TEST', '0') == '1'
so this might not be tested on CI.

torchvision/csrc/models/densenet.h Outdated Show resolved Hide resolved
@datumbox
Copy link
Contributor Author

so this might not be tested on CI.

Thanks for letting me know. I re-enabled locally the C++ tests on test_cpp_models.py and they passed. The only ones failing on macOS are the MNASNet which I did not update in this PR. So we should be good.

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

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

Thanks!

@fmassa fmassa merged commit e987d1c into pytorch:master Oct 26, 2020
@datumbox datumbox deleted the refactor/models_staticanalysis branch October 26, 2020 14:58
bryant1410 pushed a commit to bryant1410/vision-1 that referenced this pull request Nov 22, 2020
* Minor refactoring based on static analysis on the code of models:
- Convert unnecessary value parameter to constant reference.
- Use move to avoid unnecessary copies.
- Eliminate unused include.

* Replace moves with const references.

* Fixing formatting.

* Remove explicit declaration on constructors.
vfdev-5 pushed a commit to Quansight/vision that referenced this pull request Dec 4, 2020
* Minor refactoring based on static analysis on the code of models:
- Convert unnecessary value parameter to constant reference.
- Use move to avoid unnecessary copies.
- Eliminate unused include.

* Replace moves with const references.

* Fixing formatting.

* Remove explicit declaration on constructors.
@datumbox datumbox mentioned this pull request Jan 5, 2021
13 tasks
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