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

[Feature] Support using checkpoint in Swin Transformer to save memory. #557

Merged
merged 2 commits into from
Dec 1, 2021
Merged

[Feature] Support using checkpoint in Swin Transformer to save memory. #557

merged 2 commits into from
Dec 1, 2021

Conversation

okotaku
Copy link
Collaborator

@okotaku okotaku commented Nov 26, 2021

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

For larger batch size training in swin transformer.

Modification

Added checkpointing in swin transformer.

Checklist

Before PR:

  • Pre-commit or other linting tools are used to fix the potential lint issues.
  • Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests.
  • The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  • The documentation has been modified accordingly, like docstring or example tutorials.

After PR:

  • If the modification has potential influence on downstream or other related projects, this PR should be tested with those projects, like MMDet or MMSeg.
  • CLA has been signed and all committers have signed the CLA in this PR.

@codecov
Copy link

codecov bot commented Nov 26, 2021

Codecov Report

Merging #557 (a0fad05) into master (715a80b) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #557      +/-   ##
==========================================
+ Coverage   79.92%   79.94%   +0.02%     
==========================================
  Files         107      107              
  Lines        6102     6109       +7     
  Branches      989     1041      +52     
==========================================
+ Hits         4877     4884       +7     
  Misses       1093     1093              
  Partials      132      132              
Flag Coverage Δ
unittests 79.94% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmcls/models/backbones/swin_transformer.py 90.54% <100.00%> (+0.46%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 715a80b...a0fad05. Read the comment docs.

@@ -36,6 +37,9 @@ class SwinBlock(BaseModule):
Defaults to empty dict.
norm_cfg (dict, optional): The config of norm layers.
Defaults to dict(type='LN').
with_cp (bool, optional): Use checkpoint or not. Using checkpoint
will save some memory while slowing down the training speed.
Default: False.
Copy link
Member

Choose a reason for hiding this comment

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

Please use Defaults to False to keep the same with other docstrings.

@okotaku okotaku requested a review from mzr1996 November 28, 2021 02:45
Copy link
Member

@mzr1996 mzr1996 left a comment

Choose a reason for hiding this comment

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

LGTM
We will merge it after the release of this month.

@mzr1996 mzr1996 changed the title add checkpoint in swin backbone [Feature] Support using checkpoint in Swin Transformer to save memory. Dec 1, 2021
@mzr1996 mzr1996 merged commit 9d9dce6 into open-mmlab:master Dec 1, 2021
mzr1996 pushed a commit to mzr1996/mmpretrain that referenced this pull request Nov 24, 2022
open-mmlab#557)

* add checkpoint in swin backbone

* add checkpoint in swin backbone
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.

None yet

2 participants