Dimension-Decomposition based Context Modeling. Args: in_channels (int): Input channels of the block. out_channels (int): Output channels of the block. norm_cfg (:obj:`ConfigDict` or dict): Config dict for normalization layer. act_cfg (:obj:`ConfigDic
| 317 | |
| 318 | |
| 319 | class DDCMBlock(BaseModule): |
| 320 | """Dimension-Decomposition based Context Modeling. |
| 321 | |
| 322 | Args: |
| 323 | in_channels (int): Input channels of the block. |
| 324 | out_channels (int): Output channels of the block. |
| 325 | norm_cfg (:obj:`ConfigDict` or dict): Config dict for |
| 326 | normalization layer. |
| 327 | act_cfg (:obj:`ConfigDict` or dict): Config dict of activation layers. |
| 328 | Defaults to dict(type='Sigmoid'). |
| 329 | indice_key (str, optional): Name of indice tables. Defaults to None. |
| 330 | """ |
| 331 | |
| 332 | def __init__(self, |
| 333 | in_channels: int, |
| 334 | out_channels: int, |
| 335 | norm_cfg: ConfigType, |
| 336 | act_cfg: ConfigType = dict(type='Sigmoid'), |
| 337 | indice_key: Optional[str] = None): |
| 338 | super().__init__() |
| 339 | |
| 340 | self.conv1 = SubMConv3d( |
| 341 | in_channels, |
| 342 | out_channels, |
| 343 | kernel_size=(3, 1, 1), |
| 344 | padding=1, |
| 345 | bias=False, |
| 346 | indice_key=indice_key) |
| 347 | self.bn1 = build_norm_layer(norm_cfg, out_channels)[1] |
| 348 | self.act1 = build_activation_layer(act_cfg) |
| 349 | |
| 350 | self.conv2 = SubMConv3d( |
| 351 | in_channels, |
| 352 | out_channels, |
| 353 | kernel_size=(1, 3, 1), |
| 354 | padding=1, |
| 355 | bias=False, |
| 356 | indice_key=indice_key) |
| 357 | self.bn2 = build_norm_layer(norm_cfg, out_channels)[1] |
| 358 | self.act2 = build_activation_layer(act_cfg) |
| 359 | |
| 360 | self.conv3 = SubMConv3d( |
| 361 | in_channels, |
| 362 | out_channels, |
| 363 | kernel_size=(1, 1, 3), |
| 364 | padding=1, |
| 365 | bias=False, |
| 366 | indice_key=indice_key) |
| 367 | self.bn3 = build_norm_layer(norm_cfg, out_channels)[1] |
| 368 | self.act3 = build_activation_layer(act_cfg) |
| 369 | |
| 370 | def forward(self, x: SparseConvTensor) -> SparseConvTensor: |
| 371 | """Forward pass.""" |
| 372 | shortcut = self.conv1(x) |
| 373 | shortcut.features = self.bn1(shortcut.features) |
| 374 | shortcut.features = self.act1(shortcut.features) |
| 375 | |
| 376 | shortcut2 = self.conv2(x) |