(
self,
in_channels,
out_channels,
kernel_size=2,
stride=None,
padding="corner",
dilation=1,
bias=False,
norm_cfg=dict(type="LN"),
init_cfg=None,
)
| 227 | """ |
| 228 | |
| 229 | def __init__( |
| 230 | self, |
| 231 | in_channels, |
| 232 | out_channels, |
| 233 | kernel_size=2, |
| 234 | stride=None, |
| 235 | padding="corner", |
| 236 | dilation=1, |
| 237 | bias=False, |
| 238 | norm_cfg=dict(type="LN"), |
| 239 | init_cfg=None, |
| 240 | ): |
| 241 | super().__init__(init_cfg=init_cfg) |
| 242 | self.in_channels = in_channels |
| 243 | self.out_channels = out_channels |
| 244 | if stride: |
| 245 | stride = stride |
| 246 | else: |
| 247 | stride = kernel_size |
| 248 | |
| 249 | kernel_size = to_2tuple(kernel_size) |
| 250 | stride = to_2tuple(stride) |
| 251 | dilation = to_2tuple(dilation) |
| 252 | |
| 253 | if isinstance(padding, str): |
| 254 | self.adap_padding = AdaptivePadding( |
| 255 | kernel_size=kernel_size, stride=stride, dilation=dilation, padding=padding |
| 256 | ) |
| 257 | # disable the padding of unfold |
| 258 | padding = 0 |
| 259 | else: |
| 260 | self.adap_padding = None |
| 261 | |
| 262 | padding = to_2tuple(padding) |
| 263 | self.sampler = nn.Unfold(kernel_size=kernel_size, dilation=dilation, padding=padding, stride=stride) |
| 264 | |
| 265 | sample_dim = kernel_size[0] * kernel_size[1] * in_channels |
| 266 | |
| 267 | if norm_cfg is not None: |
| 268 | self.norm = build_norm_layer(norm_cfg, sample_dim)[1] |
| 269 | else: |
| 270 | self.norm = None |
| 271 | |
| 272 | self.reduction = nn.Linear(sample_dim, out_channels, bias=bias) |
| 273 | |
| 274 | def forward(self, x, input_size): |
| 275 | """ |
nothing calls this directly
no test coverage detected