open-mmlab / mmcv

OpenMMLab Computer Vision Foundation
https://mmcv.readthedocs.io/en/latest/
Apache License 2.0
5.73k stars 1.61k forks source link

[Docs] mmcv 1.6.0 mmcv.cnn.bricks.conv_module.py class::ConvModule confusion in padding_mode #3078

Open ALLLLLecy opened 2 months ago

ALLLLLecy commented 2 months ago

šŸ“š The doc issue

First of all, if I now want to build a conv with padding mode, this file gives me two ways to build it, either by writing directly into conv_cfg of the configuration file that I want to configure the padding mode.

For example:

conv_cfg(dict("type":"Conv2d", padding_mode:"circle"))

self.shared_conv = ConvModule(
in_channels,
share_conv_channel,
kernel_size=3,
padding=1,
conv_cfg=conv_cfg,
norm_cfg=norm_cfg,
bias=bias)

The second way is to pass the padding_mode parameter directly on the call

For example:

conv_cfg(dict("type":"Conv2d")

self.shared_conv = ConvModule(
in_channels,
share_conv_channel,
kernel_size=3,
padding=1,
conv_cfg=conv_cfg,
norm_cfg=norm_cfg,
bias=bias,
padding_mode='zeros'
)

Both examples can build a conv layer, but obviously there are conflicts between the two examples, and there is no way to handle such conflicts in the ConvModule class for example:

conv_cfg(dict("type":"Conv2d", padding_mode:"circle"))

self.shared_conv = ConvModule(
in_channels,
share_conv_channel,
kernel_size=3,
padding=1,
conv_cfg=conv_cfg,
norm_cfg=norm_cfg,
bias=bias,
padding_mode='zeros'
)

Second, if we build the second way, and pytorch officially doesn't provide us with custom_padding, the ConvMoudule class internally calls build_padding_layer() to build a custom padding layer, which we can extend here. However, if you build in the first way, an error will be reported.