r""" Parameters ---------- unknown : torch.Tensor (B, n, 3) tensor of the xyz positions of the unknown features known : torch.Tensor (B, m, 3) tensor of the xyz positions of the known features unknow_feats : torch.Tensor (B,
(self, unknown, known, unknow_feats, known_feats)
| 317 | self.mlp = pt_utils.SharedMLP(mlp, bn=bn) |
| 318 | |
| 319 | def forward(self, unknown, known, unknow_feats, known_feats): |
| 320 | # type: (PointnetFPModule, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor) -> torch.Tensor |
| 321 | r""" |
| 322 | Parameters |
| 323 | ---------- |
| 324 | unknown : torch.Tensor |
| 325 | (B, n, 3) tensor of the xyz positions of the unknown features |
| 326 | known : torch.Tensor |
| 327 | (B, m, 3) tensor of the xyz positions of the known features |
| 328 | unknow_feats : torch.Tensor |
| 329 | (B, C1, n) tensor of the features to be propigated to |
| 330 | known_feats : torch.Tensor |
| 331 | (B, C2, m) tensor of features to be propigated |
| 332 | |
| 333 | Returns |
| 334 | ------- |
| 335 | new_features : torch.Tensor |
| 336 | (B, mlp[-1], n) tensor of the features of the unknown features |
| 337 | """ |
| 338 | |
| 339 | if known is not None: |
| 340 | dist, idx = pointnet2_utils.three_nn(unknown, known) |
| 341 | dist_recip = 1.0 / (dist + 1e-8) |
| 342 | norm = torch.sum(dist_recip, dim=2, keepdim=True) |
| 343 | weight = dist_recip / norm |
| 344 | |
| 345 | interpolated_feats = pointnet2_utils.three_interpolate( |
| 346 | known_feats, idx, weight |
| 347 | ) |
| 348 | else: |
| 349 | interpolated_feats = known_feats.expand( |
| 350 | *(known_feats.size()[0:2] + [unknown.size(1)]) |
| 351 | ) |
| 352 | |
| 353 | if unknow_feats is not None: |
| 354 | new_features = torch.cat( |
| 355 | [interpolated_feats, unknow_feats], dim=1 |
| 356 | ) # (B, C2 + C1, n) |
| 357 | else: |
| 358 | new_features = interpolated_feats |
| 359 | |
| 360 | new_features = new_features.unsqueeze(-1) |
| 361 | new_features = self.mlp(new_features) |
| 362 | |
| 363 | return new_features.squeeze(-1) |
| 364 | |
| 365 | |
| 366 | if __name__ == "__main__": |
nothing calls this directly
no outgoing calls
no test coverage detected