Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Pruning Bugfix: 1 out ch conv layer being treated as depthwise conv layer #5751

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all 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
8 changes: 6 additions & 2 deletions nni/compression/speedup/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,12 @@ def build_channel_dependency(graph_module: torch.fx.GraphModule,
if node.op == 'call_module':
submodule = graph_module.get_submodule(node.target)
# additional denpendency for (group number == output channel number) depth-wise conv:
if (isinstance(submodule, (torch.nn.Conv2d, torch.nn.ConvTranspose2d)) and submodule.groups == submodule.out_channels) \
or (isinstance(submodule, torch.nn.GroupNorm) and submodule.num_groups == submodule.num_channels):
if (
# check for conv layers with groups > 1, for depthwise convolutions
isinstance(submodule, (torch.nn.Conv2d, torch.nn.ConvTranspose2d))
and submodule.groups == submodule.out_channels
and submodule.out_channels != 1
) or (isinstance(submodule, torch.nn.GroupNorm) and submodule.num_groups == submodule.num_channels):
d_set = set([node] + find_adjacent_layers(node, graph_module, target_types, 'parent'))

elif node.op == 'call_function':
Expand Down
Loading