-
Notifications
You must be signed in to change notification settings - Fork 228
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] Add DMCP and fix the deploy pipeline of NAS algorithms #406
Conversation
# To static ops for loaded pruned network. | ||
self._deploy() | ||
|
||
def _deploy(self): |
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.
_deploy
is not needed here.
ForwardResults = Union[LossResults, TensorResults, PredictResults] | ||
|
||
@MODELS.register_module() | ||
class DMCP(ItePruneAlgorithm): |
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.
inherit from ItePruneAlgorithm for ?
def __init__(self, | ||
channel_unit_cfg: Union[dict, Type[ChannelUnitType]] = dict( | ||
type='DMCPChannelUnit', units={}), | ||
parse_cfg=dict( |
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.
update parse_cfg to ChannelAnalyzer
, according to:
parse_cfg: Dict = dict( |
else: | ||
raise NotImplementedError | ||
|
||
def calc_current_flops(self, model): |
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.
move to Algorithm.
@@ -172,7 +171,8 @@ def params_units_convert(num_params, units='M', precision=3): | |||
>>> params_units_convert(3e-9) | |||
'3e-09' | |||
""" | |||
|
|||
if getattr(num_params, 'requires_grad', None): |
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.
If you want to get num_params without units, just pass the argument units
with the None
.
class DynamicSyncBatchNorm(nn.SyncBatchNorm, DynamicBatchNormMixin): | ||
"""DynamicOp for sync bn.""" | ||
@MODELS.register_module() | ||
class DMCPBatchNorm2d(DynamicBatchNorm2d): |
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.
fix dynamic_norm.py
|
||
self.modify_supernet_forward(arch_train) | ||
|
||
def _prune_by_arch(self, mode, group_id): |
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.
docstr
group_arch_param = self._build_arch_param(arch_message[1]) | ||
self.arch_params[str(group_id)] = group_arch_param | ||
|
||
for m in module[0].output_related: |
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.
modify name:m->unit
min_ratio: float = 0.5) -> None: | ||
super().__init__(num_channels, choice_mode, divisor, min_value, | ||
min_ratio) | ||
self._traceable_choice = tracable_choice() |
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.
traceable
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## dev-1.x #406 +/- ##
===========================================
+ Coverage 79.14% 79.49% +0.35%
===========================================
Files 276 279 +3
Lines 13597 14027 +430
Branches 2084 2155 +71
===========================================
+ Hits 10761 11151 +390
- Misses 2395 2416 +21
- Partials 441 460 +19
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
configs/nas/mmcls/onceforall/ofa_mobilenet_subnet_8xb256_in1k.py
Outdated
Show resolved
Hide resolved
@Lxtccc Congratulations on having your first PR merged in OpenMMLab! I am a technical operations staff member of OpenMMLab. My WeChat ID is van-sin ,please add me . I would like to invite you to join the OpenMMLab contributors WeChat group. |
Dear Lxtccc, |
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
Please describe the motivation of this PR and the goal you want to achieve through this PR.
Modification
Please briefly describe what modification is made in this PR.
BC-breaking (Optional)
Does the modification introduce changes that break the backward compatibility of the downstream repositories?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.
Use cases (Optional)
If this PR introduces a new feature, it is better to list some use cases here and update the documentation.
Checklist
Before PR:
After PR: