-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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] Support amp (pytorch >= 1.6.0) on DCN and DCNv2/ Add unit tests on DCN/DCNv2 amp #1029
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1029 +/- ##
==========================================
- Coverage 65.35% 65.34% -0.01%
==========================================
Files 155 155
Lines 9927 9930 +3
Branches 1806 1806
==========================================
+ Hits 6488 6489 +1
- Misses 3105 3107 +2
Partials 334 334
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
mmcv/ops/deform_conv.py
Outdated
# The flag for whether to use fp16 (pytorch < 1.6.0) or | ||
# amp (pytorch >= 1.6.0) is the type of "offset", we | ||
# cast weight and input to temporarily support fp16 and | ||
# amp whatever the pytorch version is. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may state why we are doing this, e.g amp won't cast input for DCN correctly.
Motivation
mmcv 1.3.2 supports automatic mixed precision with pytorch >= 1.6.0 but the CUDA ops don't support it now, resulting in some runtime errors like #1004 and #1028.
#1014 fixes the bug in #1004. However, when the type of input data for DCN is float32, the bug still exists. The same bug also exits in DCNv2.
Here is I'd like to do:
Modification
The offset in deform_conv is computed by a Conv2d which supports amp, so the type of offset is the flag for whether we use fp16 or amp.
With amp (pytorch >= 1.6.0), the model type will not be set manually. The input type might be float32 and float16; the unit tests should include both cases.
BC-breaking (Optional)
No.