r""" Parameters ---------- xyz : torch.Tensor (B, N, 3) tensor of the xyz coordinates of the features features : torch.Tensor (B, N, C) tensor of the descriptors of the the features Returns ------- new_xyz : torch.Tenso
(self, xyz, features, npoint, score)
| 240 | |
| 241 | |
| 242 | def forward(self, xyz, features, npoint, score): |
| 243 | # type: (_PointnetSAModuleBase, torch.Tensor, torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor] |
| 244 | r""" |
| 245 | Parameters |
| 246 | ---------- |
| 247 | xyz : torch.Tensor |
| 248 | (B, N, 3) tensor of the xyz coordinates of the features |
| 249 | features : torch.Tensor |
| 250 | (B, N, C) tensor of the descriptors of the the features |
| 251 | |
| 252 | Returns |
| 253 | ------- |
| 254 | new_xyz : torch.Tensor |
| 255 | (B, npoint, 3) tensor of the new features' xyz |
| 256 | new_features : torch.Tensor |
| 257 | (B, \sum_k(mlps[k][-1]), npoint) tensor of the new_features descriptors |
| 258 | """ |
| 259 | |
| 260 | self.npoint = npoint |
| 261 | new_features_list = [] |
| 262 | |
| 263 | xyz_flipped = xyz.transpose(1, 2).contiguous() |
| 264 | |
| 265 | if self.sample_method is None: |
| 266 | new_xyz = ( |
| 267 | pointnet2_utils.gather_operation( |
| 268 | xyz_flipped,torch.arange(self.npoint).repeat(xyz.size(0),1).int().cuda() |
| 269 | ) |
| 270 | .transpose(1, 2) |
| 271 | .contiguous()) |
| 272 | else: |
| 273 | new_xyz = ( |
| 274 | pointnet2_utils.gather_operation( |
| 275 | xyz_flipped, pointnet2_utils.furthest_point_sample(xyz, self.npoint) |
| 276 | ) |
| 277 | .transpose(1, 2) |
| 278 | .contiguous()) |
| 279 | |
| 280 | for i in range(len(self.groupers)): |
| 281 | new_features, score_id = self.groupers[i]( |
| 282 | xyz, new_xyz, score, features |
| 283 | ) # (B, C, npoint, nsample) |
| 284 | idx = torch.arange(new_features.size(0)) |
| 285 | new_features = new_features[idx,:,score_id,:] |
| 286 | #B*C*nsample |
| 287 | new_features = new_features.unsqueeze(2) |
| 288 | #B*C*1*nsample |
| 289 | new_xyz = new_xyz[idx,score_id,:] |
| 290 | #B*3 |
| 291 | |
| 292 | new_features = self.mlps[i](new_features) # (B, mlp[-1], npoint, nsample) |
| 293 | new_features = F.max_pool2d( |
| 294 | new_features, kernel_size=[1, new_features.size(3)] |
| 295 | ) # (B, mlp[-1], npoint, 1) |
| 296 | new_features = new_features.squeeze(-1).squeeze(-1) # (B, mlp[-1]) |
| 297 | |
| 298 | new_features_list.append(new_features) |
| 299 |
nothing calls this directly
no outgoing calls
no test coverage detected