MCPcopy Create free account
hub / github.com/QWTforGithub/T2LDM / forward

Method forward

pointops/functions/pointops.py:548–585  ·  view source on GitHub ↗

input: xyz: (b, n, 3) coordinates of the features new_xyz: (b, m, 3) centriods features: (b, c, n) idx: idx of neighbors # idxs: (b, n) output: new_features: (b, c+3, m, nsample) # grouped_idxs: (b, m, nsampl

(self, xyz: torch.Tensor, new_xyz: torch.Tensor = None, features: torch.Tensor = None, idx: torch.Tensor = None)

Source from the content-addressed store, hash-verified

546 self.return_idx = return_idx
547
548 def forward(self, xyz: torch.Tensor, new_xyz: torch.Tensor = None, features: torch.Tensor = None, idx: torch.Tensor = None) -> torch.Tensor:
549 """
550 input: xyz: (b, n, 3) coordinates of the features
551 new_xyz: (b, m, 3) centriods
552 features: (b, c, n)
553 idx: idx of neighbors
554 # idxs: (b, n)
555 output: new_features: (b, c+3, m, nsample)
556 # grouped_idxs: (b, m, nsample)
557 """
558 if new_xyz is None:
559 new_xyz = xyz
560 if idx is None:
561 if self.radius is not None:
562 idx = ballquery(self.radius, self.nsample, xyz, new_xyz)
563 else:
564 # idx = knnquery_naive(self.nsample, xyz, new_xyz) # (b, m, nsample)
565 # idx = knnquery(self.nsample, xyz, new_xyz) # (b, m, nsample)
566 idx = knnquery_heap(self.nsample, xyz, new_xyz) # (b, m, nsample)
567 xyz_trans = xyz.transpose(1, 2).contiguous()
568 grouped_xyz = grouping(xyz_trans, idx) # (b, 3, m, nsample)
569 # grouped_idxs = grouping(idxs.unsqueeze(1).float(), idx).squeeze(1).int() # (b, m, nsample)
570 grouped_xyz_diff = grouped_xyz - new_xyz.transpose(1, 2).unsqueeze(-1)
571 if features is not None:
572 grouped_features = grouping(features, idx)
573 if self.use_xyz:
574 new_features = torch.cat([grouped_xyz_diff, grouped_features], dim=1) # (b, 3+c, m, nsample)
575 else:
576 new_features = grouped_features
577 else:
578 assert self.use_xyz, "Cannot have not features and not use xyz as a feature!"
579 new_features = grouped_xyz_diff
580
581 if self.return_idx:
582 return new_features, grouped_xyz, idx.long()
583 # (b,c,m,k), (b,3,m,k), (b,m,k)
584 else:
585 return new_features, grouped_xyz
586
587
588class QueryAndGroupForKPConv(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected