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)
| 162 | |
| 163 | |
| 164 | def interpolation(xyz, new_xyz, feat, offset, new_offset, k=3): |
| 165 | """ |
| 166 | input: xyz: (m, 3), new_xyz: (n, 3), feat: (m, c), offset: (b), new_offset: (b) |
| 167 | output: (n, c) |
| 168 | """ |
| 169 | assert xyz.is_contiguous() and new_xyz.is_contiguous() and feat.is_contiguous() |
| 170 | idx, dist = knnquery(k, xyz, new_xyz, offset, new_offset) # (n, 3), (n, 3) |
| 171 | dist_recip = 1.0 / (dist + 1e-8) # (n, 3) |
| 172 | norm = torch.sum(dist_recip, dim=1, keepdim=True) |
| 173 | weight = dist_recip / norm # (n, 3) |
| 174 | |
| 175 | new_feat = torch.cuda.FloatTensor(new_xyz.shape[0], feat.shape[1]).zero_() |
| 176 | for i in range(k): |
| 177 | new_feat += feat[idx[:, i].long(), :] * weight[:, i].unsqueeze(-1) |
| 178 | return new_feat |
| 179 | |
| 180 | |
| 181 | class Interpolation(Function): |
nothing calls this directly
no outgoing calls
no test coverage detected