Speed-up NGP inference by 3x. (#211)

This commit is contained in:
Ruilong Li(李瑞龙) authored and GitHub committed 2022-07-27 10:19:19 -07:00
1 parent 934bd4bd72
commit 3e28a40c44
10 files changed
+243 -104

No files matched your search

+6 -3
View File
@@ -33,9 +33,9 @@ class VolumeRenderer(torch.autograd.Function):
@staticmethod
@custom_fwd(cast_inputs=torch.float32)
def forward(ctx, packed_info, starts, ends, sigmas, rgbs):
def forward(ctx, packed_info, starts, ends, sigmas, rgbs, opacities):
accumulated_weight, accumulated_depth, accumulated_color, mask = volumetric_rendering_forward(
packed_info, starts, ends, sigmas, rgbs
packed_info, starts, ends, sigmas, rgbs, opacities
)
# TODO(ruilongli): accelerate for torch.no_grad()?
ctx.save_for_backward(
@@ -47,6 +47,7 @@ class VolumeRenderer(torch.autograd.Function):
ends,
sigmas,
rgbs,
opacities,
)
return accumulated_weight, accumulated_depth, accumulated_color, mask
@@ -62,6 +63,7 @@ class VolumeRenderer(torch.autograd.Function):
ends,
sigmas,
rgbs,
opacities,
) = ctx.saved_tensors
grad_sigmas, grad_rgbs = volumetric_rendering_backward(
accumulated_weight,
@@ -75,9 +77,10 @@ class VolumeRenderer(torch.autograd.Function):
ends,
sigmas,
rgbs,
opacities,
)
# corresponds to the input argument list of forward()
return None, None, None, grad_sigmas, grad_rgbs
return None, None, None, grad_sigmas, grad_rgbs, None
def unpackbits(x: torch.Tensor) -> torch.Tensor: