MCPcopy Create free account
hub / github.com/ADLab-AutoDrive/BEVFusion / PointFPModule

Class PointFPModule

mmdet3d/ops/pointnet_modules/point_fp_module.py:10–77  ·  view source on GitHub ↗

Point feature propagation module used in PointNets. Propagate the features from one set to another. Args: mlp_channels (list[int]): List of mlp channels. norm_cfg (dict): Type of normalization method. Default: dict(type='BN2d').

Source from the content-addressed store, hash-verified

8
9
10class PointFPModule(nn.Module):
11 """Point feature propagation module used in PointNets.
12
13 Propagate the features from one set to another.
14
15 Args:
16 mlp_channels (list[int]): List of mlp channels.
17 norm_cfg (dict): Type of normalization method.
18 Default: dict(type='BN2d').
19 """
20
21 def __init__(self,
22 mlp_channels: List[int],
23 norm_cfg: dict = dict(type='BN2d')):
24 super().__init__()
25 self.fp16_enabled = False
26 self.mlps = nn.Sequential()
27 for i in range(len(mlp_channels) - 1):
28 self.mlps.add_module(
29 f'layer{i}',
30 ConvModule(
31 mlp_channels[i],
32 mlp_channels[i + 1],
33 kernel_size=(1, 1),
34 stride=(1, 1),
35 conv_cfg=dict(type='Conv2d'),
36 norm_cfg=norm_cfg))
37
38 @force_fp32()
39 def forward(self, target: torch.Tensor, source: torch.Tensor,
40 target_feats: torch.Tensor,
41 source_feats: torch.Tensor) -> torch.Tensor:
42 """forward.
43
44 Args:
45 target (Tensor): (B, n, 3) tensor of the xyz positions of
46 the target features.
47 source (Tensor): (B, m, 3) tensor of the xyz positions of
48 the source features.
49 target_feats (Tensor): (B, C1, n) tensor of the features to be
50 propagated to.
51 source_feats (Tensor): (B, C2, m) tensor of features
52 to be propagated.
53
54 Return:
55 Tensor: (B, M, N) M = mlp[-1], tensor of the target features.
56 """
57 if source is not None:
58 dist, idx = three_nn(target, source)
59 dist_reciprocal = 1.0 / (dist + 1e-8)
60 norm = torch.sum(dist_reciprocal, dim=2, keepdim=True)
61 weight = dist_reciprocal / norm
62
63 interpolated_feats = three_interpolate(source_feats, idx, weight)
64 else:
65 interpolated_feats = source_feats.expand(*source_feats.size()[0:2],
66 target.size(1))
67

Callers 2

__init__Method · 0.90
test_pointnet_fp_moduleFunction · 0.90

Calls

no outgoing calls

Tested by 1

test_pointnet_fp_moduleFunction · 0.72