| 8 | |
| 9 | |
| 10 | class Gather(Function): |
| 11 | @staticmethod |
| 12 | def forward(ctx, features, indices): |
| 13 | """ |
| 14 | Gather |
| 15 | :param ctx: |
| 16 | :param features: features of points, FloatTensor[B, C, N] |
| 17 | :param indices: centers' indices in points, IntTensor[b, m] |
| 18 | :return: |
| 19 | centers_coords: coordinates of sampled centers, FloatTensor[B, C, M] |
| 20 | """ |
| 21 | features = features.contiguous() |
| 22 | indices = indices.int().contiguous() |
| 23 | ctx.save_for_backward(indices) |
| 24 | ctx.num_points = features.size(-1) |
| 25 | return _backend.gather_features_forward(features, indices) |
| 26 | |
| 27 | @staticmethod |
| 28 | def backward(ctx, grad_output): |
| 29 | indices, = ctx.saved_tensors |
| 30 | grad_features = _backend.gather_features_backward(grad_output.contiguous(), indices, ctx.num_points) |
| 31 | return grad_features, None |
| 32 | |
| 33 | |
| 34 | gather = Gather.apply |
nothing calls this directly
no outgoing calls
no test coverage detected