Fix bc break of fp16 (#3822)
* fix bc break of mmdet.core.fp16, refactor import of wrap_fp16_model * changed warning method * added docstring for Depr_Fp16OptimizerHook * docformatter * fix docstring * changed names from depr to deprecatedpull/3833/head
parent
9c95543ea9
commit
bf01bdd5ae
7 changed files with 63 additions and 16 deletions
@ -1,6 +1,7 @@ |
|||||||
from .anchor import * # noqa: F401, F403 |
from .anchor import * # noqa: F401, F403 |
||||||
from .bbox import * # noqa: F401, F403 |
from .bbox import * # noqa: F401, F403 |
||||||
from .evaluation import * # noqa: F401, F403 |
from .evaluation import * # noqa: F401, F403 |
||||||
|
from .fp16 import * # noqa: F401, F403 |
||||||
from .mask import * # noqa: F401, F403 |
from .mask import * # noqa: F401, F403 |
||||||
from .post_processing import * # noqa: F401, F403 |
from .post_processing import * # noqa: F401, F403 |
||||||
from .utils import * # noqa: F401, F403 |
from .utils import * # noqa: F401, F403 |
||||||
|
@ -0,0 +1,8 @@ |
|||||||
|
from .deprecated_fp16_utils import \ |
||||||
|
DeprecatedFp16OptimizerHook as Fp16OptimizerHook |
||||||
|
from .deprecated_fp16_utils import deprecated_auto_fp16 as auto_fp16 |
||||||
|
from .deprecated_fp16_utils import deprecated_force_fp32 as force_fp32 |
||||||
|
from .deprecated_fp16_utils import \ |
||||||
|
deprecated_wrap_fp16_model as wrap_fp16_model |
||||||
|
|
||||||
|
__all__ = ['auto_fp16', 'force_fp32', 'Fp16OptimizerHook', 'wrap_fp16_model'] |
@ -0,0 +1,47 @@ |
|||||||
|
import warnings |
||||||
|
|
||||||
|
from mmcv.runner import (Fp16OptimizerHook, auto_fp16, force_fp32, |
||||||
|
wrap_fp16_model) |
||||||
|
|
||||||
|
|
||||||
|
class DeprecatedFp16OptimizerHook(Fp16OptimizerHook): |
||||||
|
"""A wrapper class for the FP16 optimizer hook. This class wraps |
||||||
|
:class:`Fp16OptimizerHook` in `mmcv.runner` and shows a warning that the |
||||||
|
:class:`Fp16OptimizerHook` from `mmdet.core` will be deprecated. |
||||||
|
|
||||||
|
Refer to :class:`Fp16OptimizerHook` in `mmcv.runner` for more details. |
||||||
|
|
||||||
|
Args: |
||||||
|
loss_scale (float): Scale factor multiplied with loss. |
||||||
|
""" |
||||||
|
|
||||||
|
def __init__(*args, **kwargs): |
||||||
|
super().__init__(*args, **kwargs) |
||||||
|
warnings.warn( |
||||||
|
'Importing Fp16OptimizerHook from "mmdet.core" will be ' |
||||||
|
'deprecated in the future. Please import them from "mmcv.runner" ' |
||||||
|
'instead') |
||||||
|
|
||||||
|
|
||||||
|
def deprecated_auto_fp16(*args, **kwargs): |
||||||
|
warnings.warn( |
||||||
|
'Importing auto_fp16 from "mmdet.core" will be ' |
||||||
|
'deprecated in the future. Please import them from "mmcv.runner" ' |
||||||
|
'instead') |
||||||
|
return auto_fp16(*args, **kwargs) |
||||||
|
|
||||||
|
|
||||||
|
def deprecated_force_fp32(*args, **kwargs): |
||||||
|
warnings.warn( |
||||||
|
'Importing force_fp32 from "mmdet.core" will be ' |
||||||
|
'deprecated in the future. Please import them from "mmcv.runner" ' |
||||||
|
'instead') |
||||||
|
return force_fp32(*args, **kwargs) |
||||||
|
|
||||||
|
|
||||||
|
def deprecated_wrap_fp16_model(*args, **kwargs): |
||||||
|
warnings.warn( |
||||||
|
'Importing wrap_fp16_model from "mmdet.core" will be ' |
||||||
|
'deprecated in the future. Please import them from "mmcv.runner" ' |
||||||
|
'instead') |
||||||
|
wrap_fp16_model(*args, **kwargs) |
Loading…
Reference in new issue