mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-02 05:48:57 +08:00
Make DensityGrid plug-and-play for the base Graph and the base Sampler. (#205)
This commit is contained in:
1 parent
512842938a
commit
31c2c2608d
11 files changed
+327
-99
No files matched your search
@@ -25,6 +25,7 @@ morton3D_invert = _C.morton3D_invert
|
||||
raymarching = _C.raymarching
|
||||
volumetric_rendering_forward = _C.volumetric_rendering_forward
|
||||
volumetric_rendering_backward = _C.volumetric_rendering_backward
|
||||
occupancy_query = _C.occupancy_query
|
||||
|
||||
# pylint: disable=abstract-method,arguments-differ
|
||||
class VolumeRenderer(torch.autograd.Function):
|
||||
@@ -77,3 +78,18 @@ class VolumeRenderer(torch.autograd.Function):
|
||||
)
|
||||
# corresponds to the input argument list of forward()
|
||||
return None, None, None, grad_sigmas, grad_rgbs
|
||||
|
||||
|
||||
def unpackbits(x: torch.Tensor) -> torch.Tensor:
|
||||
"""Unpack uint8 bits back to a boolen mask.
|
||||
|
||||
Args:
|
||||
x: uint8 bit tensor with shape [N]
|
||||
|
||||
Returns:
|
||||
unpacked boolen tensor with shape [N * 8]
|
||||
"""
|
||||
assert x.dtype == torch.uint8 and x.dim() == 1
|
||||
bits = x.element_size() * 8
|
||||
mask = 2 ** torch.arange(bits - 1, -1, -1).to(x)
|
||||
return x.unsqueeze(-1).bitwise_and(mask).ne(0).flip(-1).bool().reshape(-1)
|
||||
Reference in new issue
Block a user