| 6 | |
| 7 | |
| 8 | class TrilinearDevoxelization(Function): |
| 9 | @staticmethod |
| 10 | def forward(ctx, features, coords, resolution, is_training=True): |
| 11 | """ |
| 12 | :param ctx: |
| 13 | :param coords: the coordinates of points, FloatTensor[B, 3, N] |
| 14 | :param features: FloatTensor[B, C, R, R, R] |
| 15 | :param resolution: int, the voxel resolution |
| 16 | :param is_training: bool, training mode |
| 17 | :return: |
| 18 | FloatTensor[B, C, N] |
| 19 | """ |
| 20 | B, C = features.shape[:2] |
| 21 | features = features.contiguous().view(B, C, -1) |
| 22 | coords = coords.contiguous() |
| 23 | outs, inds, wgts = _backend.trilinear_devoxelize_forward(resolution, is_training, coords, features) |
| 24 | if is_training: |
| 25 | ctx.save_for_backward(inds, wgts) |
| 26 | ctx.r = resolution |
| 27 | return outs |
| 28 | |
| 29 | @staticmethod |
| 30 | def backward(ctx, grad_output): |
| 31 | """ |
| 32 | :param ctx: |
| 33 | :param grad_output: gradient of outputs, FloatTensor[B, C, N] |
| 34 | :return: |
| 35 | gradient of inputs, FloatTensor[B, C, R, R, R] |
| 36 | """ |
| 37 | inds, wgts = ctx.saved_tensors |
| 38 | grad_inputs = _backend.trilinear_devoxelize_backward(grad_output.contiguous(), inds, wgts, ctx.r) |
| 39 | return grad_inputs.view(grad_output.size(0), grad_output.size(1), ctx.r, ctx.r, ctx.r), None, None, None |
| 40 | |
| 41 | |
| 42 | trilinear_devoxelize = TrilinearDevoxelization.apply |
nothing calls this directly
no outgoing calls
no test coverage detected