input: xyz: (m, 3), new_xyz: (n, 3), feat: (m, c), offset: (b), new_offset: (b) output: (n, c)
(xyz, new_xyz, feat, offset, new_offset, k=3)
| 754 | |
| 755 | |
| 756 | def interpolation(xyz, new_xyz, feat, offset, new_offset, k=3): |
| 757 | """ |
| 758 | input: xyz: (m, 3), new_xyz: (n, 3), feat: (m, c), offset: (b), new_offset: (b) |
| 759 | output: (n, c) |
| 760 | """ |
| 761 | assert xyz.is_contiguous() and new_xyz.is_contiguous() and feat.is_contiguous() |
| 762 | idx, dist = knnquery(k, xyz, new_xyz, offset, new_offset) # (n, 3), (n, 3) |
| 763 | dist_recip = 1.0 / (dist + 1e-8) # (n, 3) |
| 764 | norm = torch.sum(dist_recip, dim=1, keepdim=True) |
| 765 | weight = dist_recip / norm # (n, 3) |
| 766 | |
| 767 | new_feat = torch.cuda.FloatTensor(new_xyz.shape[0], feat.shape[1]).zero_() |
| 768 | for i in range(k): |
| 769 | new_feat += feat[idx[:, i].long(), :] * weight[:, i].unsqueeze(-1) |
| 770 | return new_feat |
| 771 | |
| 772 | |
| 773 | def interpolation_v2(xyz, new_xyz, feat, offset, new_offset, k=3): |
nothing calls this directly
no outgoing calls
no test coverage detected