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

Rename: ChannelGroup -> ChannelUnit #302

Merged
merged 13 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
data_preprocessor=data_preprocessor,
mutator=dict(
type='SlimmableChannelMutator',
channel_group_cfg=dict(
type='SlimmableChannelGroup',
groups='tests/data/MBV2_slimmable_config.json'),
channel_unit_cfg=dict(
type='SlimmableChannelUnit',
units='tests/data/MBV2_slimmable_config.json'),
parse_cfg=dict(
type='BackwardTracer',
loss_calculator=dict(type='ImageClassifierPseudoLoss'))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
preds_T=dict(recorder='fc', from_student=False)))),
mutator=dict(
type='OneShotChannelMutator',
channel_group_cfg=dict(
type='OneShotMutableChannelGroup',
channel_unit_cfg=dict(
type='OneShotMutableChannelUnit',
default_args=dict(
candidate_choices=list(i / 12 for i in range(2, 13)),
candidate_mode='ratio',
Expand Down
2 changes: 1 addition & 1 deletion configs/pruning/mmcls/l1-norm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

L1-norm pruning is a classical filter pruning algorithm. It prunes filers(channels) according to the l1-norm of the weight of a conv layer.

We use ItePruneAlgorithm and L1MutableChannelGroup to implement l1-norm pruning. Please refer to xxxx for more configuration detail.
We use ItePruneAlgorithm and L1MutableChannelUnit to implement l1-norm pruning. Please refer to xxxx for more configuration detail.
6 changes: 3 additions & 3 deletions configs/pruning/mmcls/l1-norm/l1-norm_resnet34_8xb32_in1k.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
stage_ratio_4 = 1.0

# the config template of target_pruning_ratio can be got by
# python ./tools/get_channel_groups.py {config_file} --choice
# python ./tools/get_channel_units.py {config_file} --choice
target_pruning_ratio = {
'backbone.layer1.2.conv2_(0, 64)_64': stage_ratio_1,
'backbone.layer1.0.conv1_(0, 64)_64': stage_ratio_1,
Expand Down Expand Up @@ -47,8 +47,8 @@
architecture=architecture,
mutator_cfg=dict(
type='ChannelMutator',
channel_group_cfg=dict(
type='L1MutableChannelGroup',
channel_unit_cfg=dict(
type='L1MutableChannelUnit',
default_args=dict(choice_mode='ratio'))),
target_pruning_ratio=target_pruning_ratio,
step_epoch=1,
Expand Down
6 changes: 3 additions & 3 deletions mmrazor/models/algorithms/pruning/ite_prune_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ItePruneAlgorithm(BaseAlgorithm):
architecture (Union[BaseModel, Dict]): The model to be pruned.
mutator_cfg (Union[Dict, ChannelMutator], optional): The config
of a mutator. Defaults to dict( type='ChannelMutator',
channel_group_cfg=dict( type='SequentialMutableChannelGroup')).
channel_unit_cfg=dict( type='SequentialMutableChannelUnit')).
data_preprocessor (Optional[Union[Dict, nn.Module]], optional):
Defaults to None.
target_pruning_ratio (dict, optional): The prune-target. The template
Expand All @@ -104,8 +104,8 @@ def __init__(self,
architecture: Union[BaseModel, Dict],
mutator_cfg: Union[Dict, ChannelMutator] = dict(
type='ChannelMutator',
channel_group_cfg=dict(
type='SequentialMutableChannelGroup')),
channel_unit_cfg=dict(
type='SequentialMutableChannelUnit')),
data_preprocessor: Optional[Union[Dict, nn.Module]] = None,
target_pruning_ratio={},
step_epoch=1,
Expand Down
18 changes: 9 additions & 9 deletions mmrazor/models/mutables/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
from .derived_mutable import DerivedMutable
from .mutable_channel import (BaseMutableChannel, MutableChannelContainer,
SimpleMutableChannel, SquentialMutableChannel)
from .mutable_channel.groups import (ChannelGroupType, L1MutableChannelGroup,
MutableChannelGroup,
OneShotMutableChannelGroup,
SequentialMutableChannelGroup,
SlimmableChannelGroup)
from .mutable_channel.units import (ChannelUnitType, L1MutableChannelUnit,
MutableChannelUnit,
OneShotMutableChannelUnit,
SequentialMutableChannelUnit,
SlimmableChannelUnit)
from .mutable_module import (DiffChoiceRoute, DiffMutableModule, DiffMutableOP,
OneShotMutableModule, OneShotMutableOP)
from .mutable_value import MutableValue, OneShotMutableValue

__all__ = [
'OneShotMutableOP', 'OneShotMutableModule', 'DiffMutableOP',
'DiffChoiceRoute', 'DiffMutableModule', 'DerivedMutable', 'MutableValue',
'OneShotMutableValue', 'SequentialMutableChannelGroup',
'L1MutableChannelGroup', 'OneShotMutableChannelGroup',
'SimpleMutableChannel', 'MutableChannelGroup', 'SlimmableChannelGroup',
'BaseMutableChannel', 'MutableChannelContainer', 'ChannelGroupType',
'OneShotMutableValue', 'SequentialMutableChannelUnit',
'L1MutableChannelUnit', 'OneShotMutableChannelUnit',
'SimpleMutableChannel', 'MutableChannelUnit', 'SlimmableChannelUnit',
'BaseMutableChannel', 'MutableChannelContainer', 'ChannelUnitType',
'SquentialMutableChannel', 'BaseMutable'
]
14 changes: 7 additions & 7 deletions mmrazor/models/mutables/mutable_channel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Copyright (c) OpenMMLab. All rights reserved.
from .base_mutable_channel import BaseMutableChannel
from .groups import (ChannelGroupType, L1MutableChannelGroup,
MutableChannelGroup, OneShotMutableChannelGroup,
SequentialMutableChannelGroup, SlimmableChannelGroup)
from .units import (ChannelUnitType, L1MutableChannelUnit,
MutableChannelUnit, OneShotMutableChannelUnit,
SequentialMutableChannelUnit, SlimmableChannelUnit)
from .mutable_channel_container import MutableChannelContainer
from .sequential_mutable_channel import SquentialMutableChannel
from .simple_mutable_channel import SimpleMutableChannel

__all__ = [
'SimpleMutableChannel', 'L1MutableChannelGroup',
'SequentialMutableChannelGroup', 'MutableChannelGroup',
'OneShotMutableChannelGroup', 'SlimmableChannelGroup',
'SimpleMutableChannel', 'L1MutableChannelUnit',
'SequentialMutableChannelUnit', 'MutableChannelUnit',
'OneShotMutableChannelUnit', 'SlimmableChannelUnit',
'BaseMutableChannel', 'MutableChannelContainer', 'SquentialMutableChannel',
'ChannelGroupType'
'ChannelUnitType'
]
13 changes: 0 additions & 13 deletions mmrazor/models/mutables/mutable_channel/groups/__init__.py

This file was deleted.

13 changes: 13 additions & 0 deletions mmrazor/models/mutables/mutable_channel/units/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) OpenMMLab. All rights reserved.

from .l1_mutable_channel_unit import L1MutableChannelUnit
from .mutable_channel_unit import ChannelUnitType, MutableChannelUnit
from .one_shot_mutable_channel_unit import OneShotMutableChannelUnit
from .sequential_mutable_channel_unit import SequentialMutableChannelUnit
from .slimmable_channel_unit import SlimmableChannelUnit

__all__ = [
'L1MutableChannelUnit', 'MutableChannelUnit',
'SequentialMutableChannelUnit', 'OneShotMutableChannelUnit',
'SlimmableChannelUnit', 'ChannelUnitType'
]
Loading