input: xyz: (m, 3), new_xyz: (n, 3), input: (m, c), offset: (b), new_offset: (b) output: (n, c)
(ctx, xyz, new_xyz, input, offset, new_offset, k=3)
| 181 | class Interpolation(Function): |
| 182 | @staticmethod |
| 183 | def forward(ctx, xyz, new_xyz, input, offset, new_offset, k=3): |
| 184 | """ |
| 185 | input: xyz: (m, 3), new_xyz: (n, 3), input: (m, c), offset: (b), new_offset: (b) |
| 186 | output: (n, c) |
| 187 | """ |
| 188 | assert xyz.is_contiguous() and new_xyz.is_contiguous() and input.is_contiguous() |
| 189 | idx, dist = knnquery(k, xyz, new_xyz, offset, new_offset) # (n, k), (n, k) |
| 190 | dist_recip = 1.0 / (dist + 1e-8) # (n, k) |
| 191 | norm = torch.sum(dist_recip, dim=1, keepdim=True) |
| 192 | weight = dist_recip / norm # (n, k) |
| 193 | |
| 194 | n, c, m = new_xyz.shape[0], input.shape[1], input.shape[0] |
| 195 | output = torch.cuda.FloatTensor(n, c).zero_() |
| 196 | pointops_cuda.interpolation_forward_cuda(n, c, k, input, idx, weight, output) |
| 197 | ctx.m, ctx.k = m, k |
| 198 | ctx.save_for_backward(idx, weight) |
| 199 | return output |
| 200 | |
| 201 | @staticmethod |
| 202 | def backward(ctx, grad_output): |
nothing calls this directly
no outgoing calls
no test coverage detected