Functional API

The fvdb.functional module provides a pure-function alternative to the equivalent methods on Grid and GridBatch. Every operation is available as a standalone function that takes the grid as its first argument, mirroring the design of torch.nn.functional.

Each grid operation has two variants:

The Gaussian splatting kernels at the end of this page are the exception: each is a single flat wrapper over a CUDA kernel.

Tip

Most users should prefer the methods on Grid and GridBatch directly. The functional API is useful when building custom operations or when you need explicit control over the single-grid vs. batched code path.

Coordinate Transforms

fvdb.functional.voxel_to_world_batch(grid: GridBatch, ijk: JaggedTensor) → JaggedTensor[source]

Transform voxel-space coordinates to world-space positions for a grid batch.

Supports backpropagation.

Parameters:
  • grid (GridBatch) – The grid batch supplying the voxel-to-world transforms.

  • ijk (JaggedTensor) – Voxel-space coordinates, shape (B, -1, 3).

Returns:

result (JaggedTensor) – World-space coordinates, shape (B, -1, 3).

fvdb.functional.voxel_to_world_single(grid: Grid, ijk: torch.Tensor) → torch.Tensor[source]

Transform voxel-space coordinates to world-space positions for a single grid.

Supports backpropagation.

Parameters:
  • grid (Grid) – The grid supplying the voxel-to-world transform.

  • ijk (torch.Tensor) – Voxel-space coordinates, shape (N, 3).

Returns:

result (torch.Tensor) – World-space coordinates, shape (N, 3).

fvdb.functional.world_to_voxel_batch(grid: GridBatch, points: JaggedTensor) → JaggedTensor[source]

Transform world-space coordinates to voxel-space positions for a grid batch.

Supports backpropagation.

Parameters:
  • grid (GridBatch) – The grid batch supplying the world-to-voxel transforms.

  • points (JaggedTensor) – World-space positions, shape (B, -1, 3).

Returns:

result (JaggedTensor) – Voxel-space coordinates, shape (B, -1, 3).

fvdb.functional.world_to_voxel_single(grid: Grid, points: torch.Tensor) → torch.Tensor[source]

Transform world-space coordinates to voxel-space positions for a single grid.

Supports backpropagation.

Parameters:
  • grid (Grid) – The grid supplying the world-to-voxel transform.

  • points (torch.Tensor) – World-space positions, shape (N, 3).

Returns:

result (torch.Tensor) – Voxel-space coordinates, shape (N, 3).

Interpolation and Splatting

fvdb.functional.sample_nearest_batch(grid: GridBatch, points: JaggedTensor, voxel_data: JaggedTensor) → JaggedTensor[source]

Sample voxel data at world-space points using nearest-neighbor lookup for a grid batch.

For each query point the 8 nearest voxel centers are checked and the value of the closest active one is returned. When two or more active corners are equidistant, the corner encountered first in the stencil’s zig-zag traversal order wins (the same ordering used by sample_trilinear). Points where none of the 8 surrounding voxel centers are active return zero.

Supports backpropagation w.r.t. voxel_data.

Parameters:
  • grid (GridBatch) – The grid batch defining the sparse topology.

  • points (JaggedTensor) – World-space query points, shape (B, -1, 3).

  • voxel_data (JaggedTensor) – Per-voxel feature data.

Returns:

result (JaggedTensor) – Sampled values at each query point.

fvdb.functional.sample_nearest_single(grid: Grid, points: torch.Tensor, voxel_data: torch.Tensor) → torch.Tensor[source]

Sample voxel data at world-space points using nearest-neighbor lookup for a single grid.

For each query point the 8 nearest voxel centers are checked and the value of the closest active one is returned. When two or more active corners are equidistant, the corner encountered first in the stencil’s zig-zag traversal order wins (the same ordering used by sample_trilinear). Points where none of the 8 surrounding voxel centers are active return zero.

Supports backpropagation w.r.t. voxel_data.

Parameters:
  • grid (Grid) – The single grid defining the sparse topology.

  • points (torch.Tensor) – World-space query points, shape (N, 3).

  • voxel_data (torch.Tensor) – Per-voxel feature data.

Returns:

result (torch.Tensor) – Sampled values at each query point.

fvdb.functional.sample_trilinear_batch(grid: GridBatch, points: JaggedTensor, voxel_data: JaggedTensor) → JaggedTensor[source]

Sample voxel data at world-space points using trilinear interpolation for a grid batch.

Supports backpropagation.

Parameters:
  • grid (GridBatch) – The grid batch defining the sparse topology.

  • points (JaggedTensor) – World-space query points, shape (B, -1, 3).

  • voxel_data (JaggedTensor) – Per-voxel feature data.

Returns:

result (JaggedTensor) – Interpolated values at each query point.

fvdb.functional.sample_trilinear_single(grid: Grid, points: torch.Tensor, voxel_data: torch.Tensor) → torch.Tensor[source]

Sample voxel data at world-space points using trilinear interpolation for a single grid.

Supports backpropagation.

Parameters:
  • grid (Grid) – The single grid defining the sparse topology.

  • points (torch.Tensor) – World-space query points, shape (N, 3).

  • voxel_data (torch.Tensor) – Per-voxel feature data.

Returns:

result (torch.Tensor) – Interpolated values at each query point.

fvdb.functional.sample_trilinear_with_grad_batch(grid: GridBatch, points: JaggedTensor, voxel_data: JaggedTensor) → tuple[JaggedTensor, JaggedTensor][source]

Sample with trilinear interpolation and return spatial gradients for a grid batch.

Supports backpropagation.

Parameters:
  • grid (GridBatch) – The grid batch defining the sparse topology.

  • points (JaggedTensor) – World-space query points, shape (B, -1, 3).

  • voxel_data (JaggedTensor) – Per-voxel feature data.

Returns:
  • values (JaggedTensor) – Interpolated values at each query point.

  • gradients (JaggedTensor) – Spatial gradients at each query point.

fvdb.functional.sample_trilinear_with_grad_single(grid: Grid, points: torch.Tensor, voxel_data: torch.Tensor) → tuple[torch.Tensor, torch.Tensor][source]

Sample with trilinear interpolation and return spatial gradients for a single grid.

Supports backpropagation.

Parameters:
  • grid (Grid) – The single grid defining the sparse topology.

  • points (torch.Tensor) – World-space query points, shape (N, 3).

  • voxel_data (torch.Tensor) – Per-voxel feature data.

Returns:
  • values (torch.Tensor) – Interpolated values at each query point.

  • gradients (torch.Tensor) – Spatial gradients at each query point.

fvdb.functional.sample_bezier_batch(grid: GridBatch, points: JaggedTensor, voxel_data: JaggedTensor) → JaggedTensor[source]

Sample voxel data at world-space points using Bezier interpolation for a grid batch.

Supports backpropagation.

Parameters:
  • grid (GridBatch) – The grid batch defining the sparse topology.

  • points (JaggedTensor) – World-space query points, shape (B, -1, 3).

  • voxel_data (JaggedTensor) – Per-voxel feature data.

Returns:

result (JaggedTensor) – Interpolated values at each query point.

fvdb.functional.sample_bezier_single(grid: Grid, points: torch.Tensor, voxel_data: torch.Tensor) → torch.Tensor[source]

Sample voxel data at world-space points using Bezier interpolation for a single grid.

Supports backpropagation.

Parameters:
  • grid (Grid) – The single grid defining the sparse topology.

  • points (torch.Tensor) – World-space query points, shape (N, 3).

  • voxel_data (torch.Tensor) – Per-voxel feature data.

Returns:

result (torch.Tensor) – Interpolated values at each query point.

fvdb.functional.sample_bezier_with_grad_batch(grid: GridBatch, points: JaggedTensor, voxel_data: JaggedTensor) → tuple[JaggedTensor, JaggedTensor][source]

Sample with Bezier interpolation and return spatial gradients for a grid batch.

Supports backpropagation.

Parameters:
  • grid (GridBatch) – The grid batch defining the sparse topology.

  • points (JaggedTensor) – World-space query points, shape (B, -1, 3).

  • voxel_data (JaggedTensor) – Per-voxel feature data.

Returns:
  • values (JaggedTensor) – Interpolated values at each query point.

  • gradients (JaggedTensor) – Spatial gradients at each query point.

fvdb.functional.sample_bezier_with_grad_single(grid: Grid, points: torch.Tensor, voxel_data: torch.Tensor) → tuple[torch.Tensor, torch.Tensor][source]

Sample with Bezier interpolation and return spatial gradients for a single grid.

Supports backpropagation.

Parameters:
  • grid (Grid) – The single grid defining the sparse topology.

  • points (torch.Tensor) – World-space query points, shape (N, 3).

  • voxel_data (torch.Tensor) – Per-voxel feature data.

Returns:
  • values (torch.Tensor) – Interpolated values at each query point.

  • gradients (torch.Tensor) – Spatial gradients at each query point.

fvdb.functional.splat_trilinear_batch(grid: GridBatch, points: JaggedTensor, points_data: JaggedTensor) → JaggedTensor[source]

Splat point data into voxels using trilinear weights for a grid batch.

Supports backpropagation.

Parameters:
  • grid (GridBatch) – The grid batch defining the sparse topology.

  • points (JaggedTensor) – World-space point positions, shape (B, -1, 3).

  • points_data (JaggedTensor) – Per-point feature data to splat.

Returns:

result (JaggedTensor) – Accumulated voxel data.

fvdb.functional.splat_trilinear_single(grid: Grid, points: torch.Tensor, points_data: torch.Tensor) → torch.Tensor[source]

Splat point data into voxels using trilinear weights for a single grid.

Supports backpropagation.

Parameters:
  • grid (Grid) – The single grid defining the sparse topology.

  • points (torch.Tensor) – World-space point positions, shape (N, 3).

  • points_data (torch.Tensor) – Per-point feature data to splat.

Returns:

result (torch.Tensor) – Accumulated voxel data.

fvdb.functional.splat_bezier_batch(grid: GridBatch, points: JaggedTensor, points_data: JaggedTensor) → JaggedTensor[source]

Splat point data into voxels using Bezier weights for a grid batch.

Supports backpropagation.

Parameters:
  • grid (GridBatch) – The grid batch defining the sparse topology.

  • points (JaggedTensor) – World-space point positions, shape (B, -1, 3).

  • points_data (JaggedTensor) – Per-point feature data to splat.

Returns:

result (JaggedTensor) – Accumulated voxel data.

fvdb.functional.splat_bezier_single(grid: Grid, points: torch.Tensor, points_data: torch.Tensor) → torch.Tensor[source]

Splat point data into voxels using Bezier weights for a single grid.

Supports backpropagation.

Parameters:
  • grid (Grid) – The single grid defining the sparse topology.

  • points (torch.Tensor) – World-space point positions, shape (N, 3).

  • points_data (torch.Tensor) – Per-point feature data to splat.

Returns:

result (torch.Tensor) – Accumulated voxel data.

Pooling and Refinement

fvdb.functional.max_pool_batch(grid: GridBatch, pool_factor: NumericMaxRank1, data: JaggedTensor, stride: NumericMaxRank1 = 0, coarse_grid: GridBatch | None = None) → tuple[JaggedTensor, GridBatch][source]

Max-pool voxel data on a grid batch, reducing resolution by pool_factor.

Supports backpropagation.

Parameters:
  • grid (GridBatch) – The fine grid batch.

  • pool_factor (NumericMaxRank1) – Pooling factor per axis, broadcastable to (3,).

  • data (JaggedTensor) – Per-voxel feature data on the fine grid.

  • stride (NumericMaxRank1) – Pooling stride per axis. Default 0 uses pool_factor.

  • coarse_grid (GridBatch | None) – Optional pre-computed coarse grid batch.

Returns:
  • pooled_data (JaggedTensor) – Pooled feature data on the coarse grid.

  • coarse_grid (GridBatch) – The coarse grid batch.

fvdb.functional.max_pool_single(grid: Grid, pool_factor: NumericMaxRank1, data: torch.Tensor, stride: NumericMaxRank1 = 0, coarse_grid: Grid | None = None) → tuple[torch.Tensor, Grid][source]

Max-pool voxel data on a single grid, reducing resolution by pool_factor.

Supports backpropagation.

Parameters:
  • grid (Grid) – The fine single grid.

  • pool_factor (NumericMaxRank1) – Pooling factor per axis, broadcastable to (3,).

  • data (torch.Tensor) – Per-voxel feature data on the fine grid.

  • stride (NumericMaxRank1) – Pooling stride per axis. Default 0 uses pool_factor.

  • coarse_grid (Grid | None) – Optional pre-computed coarse grid.

Returns:
  • pooled_data (torch.Tensor) – Pooled feature data on the coarse grid.

  • coarse_grid (Grid) – The coarse grid.

See also

max_pool_batch()

fvdb.functional.avg_pool_batch(grid: GridBatch, pool_factor: NumericMaxRank1, data: JaggedTensor, stride: NumericMaxRank1 = 0, coarse_grid: GridBatch | None = None) → tuple[JaggedTensor, GridBatch][source]

Average-pool voxel data on a grid batch, reducing resolution by pool_factor.

Supports backpropagation.

Parameters:
  • grid (GridBatch) – The fine grid batch.

  • pool_factor (NumericMaxRank1) – Pooling factor per axis, broadcastable to (3,).

  • data (JaggedTensor) – Per-voxel feature data on the fine grid.

  • stride (NumericMaxRank1) – Pooling stride per axis. Default 0 uses pool_factor.

  • coarse_grid (GridBatch | None) – Optional pre-computed coarse grid batch.

Returns:
  • pooled_data (JaggedTensor) – Pooled feature data on the coarse grid.

  • coarse_grid (GridBatch) – The coarse grid batch.

fvdb.functional.avg_pool_single(grid: Grid, pool_factor: NumericMaxRank1, data: torch.Tensor, stride: NumericMaxRank1 = 0, coarse_grid: Grid | None = None) → tuple[torch.Tensor, Grid][source]

Average-pool voxel data on a single grid, reducing resolution by pool_factor.

Supports backpropagation.

Parameters:
  • grid (Grid) – The fine single grid.

  • pool_factor (NumericMaxRank1) – Pooling factor per axis, broadcastable to (3,).

  • data (torch.Tensor) – Per-voxel feature data on the fine grid.

  • stride (NumericMaxRank1) – Pooling stride per axis. Default 0 uses pool_factor.

  • coarse_grid (Grid | None) – Optional pre-computed coarse grid.

Returns:
  • pooled_data (torch.Tensor) – Pooled feature data on the coarse grid.

  • coarse_grid (Grid) – The coarse grid.

See also

avg_pool_batch()

fvdb.functional.refine_batch(grid: GridBatch, subdiv_factor: NumericMaxRank1, data: JaggedTensor, mask: JaggedTensor | None = None, refined: GridBatch | None = None) → tuple[JaggedTensor, GridBatch][source]

Refine (upsample) voxel data by subdividing each voxel on a grid batch.

Supports backpropagation.

Parameters:
  • grid (GridBatch) – The coarse grid batch.

  • subdiv_factor (NumericMaxRank1) – Subdivision factor per axis, broadcastable to (3,).

  • data (JaggedTensor) – Per-voxel feature data on the coarse grid.

  • mask (JaggedTensor | None) – Optional boolean mask selecting voxels to refine.

  • refined (GridBatch | None) – Optional pre-computed fine grid batch.

Returns:
  • refined_data (JaggedTensor) – Refined feature data on the fine grid.

  • fine_grid (GridBatch) – The fine grid batch.

See also

refine_single()

fvdb.functional.refine_single(grid: Grid, subdiv_factor: NumericMaxRank1, data: torch.Tensor, mask: torch.Tensor | None = None, refined: Grid | None = None) → tuple[torch.Tensor, Grid][source]

Refine (upsample) voxel data by subdividing each voxel on a single grid.

Supports backpropagation.

Parameters:
  • grid (Grid) – The coarse single grid.

  • subdiv_factor (NumericMaxRank1) – Subdivision factor per axis, broadcastable to (3,).

  • data (torch.Tensor) – Per-voxel feature data on the coarse grid.

  • mask (torch.Tensor | None) – Optional boolean mask selecting voxels to refine.

  • refined (Grid | None) – Optional pre-computed fine grid.

Returns:
  • refined_data (torch.Tensor) – Refined feature data on the fine grid.

  • fine_grid (Grid) – The fine grid.

See also

refine_batch()

Spatial Queries

fvdb.functional.points_in_grid_batch(grid: GridBatch, points: JaggedTensor) → JaggedTensor[source]

Check if world-space points are located within active voxels of a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch to test against.

  • points (JaggedTensor) – World-space points, shape (B, -1, 3).

Returns:

mask (JaggedTensor) – Boolean mask indicating which points are in active voxels.

fvdb.functional.points_in_grid_single(grid: Grid, points: torch.Tensor) → torch.Tensor[source]

Check if world-space points are located within active voxels of a single grid.

Parameters:
  • grid (Grid) – The single grid to test against.

  • points (torch.Tensor) – World-space points, shape (N, 3).

Returns:

mask (torch.Tensor) – Boolean mask indicating which points are in active voxels.

fvdb.functional.coords_in_grid_batch(grid: GridBatch, ijk: JaggedTensor) → JaggedTensor[source]

Check which voxel-space coordinates lie on active voxels of a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch to test against.

  • ijk (JaggedTensor) – Voxel coordinates with integer dtype.

Returns:

mask (JaggedTensor) – Boolean mask indicating which coordinates correspond to active voxels.

fvdb.functional.coords_in_grid_single(grid: Grid, ijk: torch.Tensor) → torch.Tensor[source]

Check which voxel-space coordinates lie on active voxels of a single grid.

Parameters:
  • grid (Grid) – The single grid to test against.

  • ijk (torch.Tensor) – Voxel coordinates with integer dtype.

Returns:

mask (torch.Tensor) – Boolean mask indicating which coordinates correspond to active voxels.

fvdb.functional.cubes_in_grid_batch(grid: GridBatch, cube_centers: JaggedTensor, cube_min: NumericMaxRank1 = 0.0, cube_max: NumericMaxRank1 = 0.0) → JaggedTensor[source]

Check if axis-aligned cubes are fully contained within active voxels of a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch to test against.

  • cube_centers (JaggedTensor) – World-space cube centers, shape (B, -1, 3).

  • cube_min (NumericMaxRank1) – Minimum offsets from center, broadcastable to (3,).

  • cube_max (NumericMaxRank1) – Maximum offsets from center, broadcastable to (3,).

Returns:

mask (JaggedTensor) – Boolean mask indicating which cubes are fully contained.

fvdb.functional.cubes_in_grid_single(grid: Grid, cube_centers: torch.Tensor, cube_min: NumericMaxRank1 = 0.0, cube_max: NumericMaxRank1 = 0.0) → torch.Tensor[source]

Check if axis-aligned cubes are fully contained within active voxels of a single grid.

Parameters:
  • grid (Grid) – The single grid to test against.

  • cube_centers (torch.Tensor) – World-space cube centers, shape (N, 3).

  • cube_min (NumericMaxRank1) – Minimum offsets from center, broadcastable to (3,).

  • cube_max (NumericMaxRank1) – Maximum offsets from center, broadcastable to (3,).

Returns:

mask (torch.Tensor) – Boolean mask indicating which cubes are fully contained.

fvdb.functional.cubes_intersect_grid_batch(grid: GridBatch, cube_centers: JaggedTensor, cube_min: NumericMaxRank1 = 0.0, cube_max: NumericMaxRank1 = 0.0) → JaggedTensor[source]

Check if axis-aligned cubes intersect any active voxels of a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch to test against.

  • cube_centers (JaggedTensor) – World-space cube centers, shape (B, -1, 3).

  • cube_min (NumericMaxRank1) – Minimum offsets from center, broadcastable to (3,).

  • cube_max (NumericMaxRank1) – Maximum offsets from center, broadcastable to (3,).

Returns:

mask (JaggedTensor) – Boolean mask indicating which cubes intersect the grid.

fvdb.functional.cubes_intersect_grid_single(grid: Grid, cube_centers: torch.Tensor, cube_min: NumericMaxRank1 = 0.0, cube_max: NumericMaxRank1 = 0.0) → torch.Tensor[source]

Check if axis-aligned cubes intersect any active voxels of a single grid.

Parameters:
  • grid (Grid) – The single grid to test against.

  • cube_centers (torch.Tensor) – World-space cube centers, shape (N, 3).

  • cube_min (NumericMaxRank1) – Minimum offsets from center, broadcastable to (3,).

  • cube_max (NumericMaxRank1) – Maximum offsets from center, broadcastable to (3,).

Returns:

mask (torch.Tensor) – Boolean mask indicating which cubes intersect the grid.

fvdb.functional.ijk_to_index_batch(grid: GridBatch, ijk: JaggedTensor, cumulative: bool = False) → JaggedTensor[source]

Convert voxel-space coordinates to linear indices in a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch to index into.

  • ijk (JaggedTensor) – Voxel coordinates with integer dtype.

  • cumulative (bool) – If True, return indices cumulative across the batch.

Returns:

indices (JaggedTensor) – Linear indices (-1 for inactive coordinates).

fvdb.functional.ijk_to_index_single(grid: Grid, ijk: torch.Tensor, cumulative: bool = False) → torch.Tensor[source]

Convert voxel-space coordinates to linear indices in a single grid.

Parameters:
  • grid (Grid) – The single grid to index into.

  • ijk (torch.Tensor) – Voxel coordinates with integer dtype.

  • cumulative (bool) – If True, return indices cumulative across the batch.

Returns:

indices (torch.Tensor) – Linear indices (-1 for inactive coordinates).

fvdb.functional.ijk_to_inv_index_batch(grid: GridBatch, ijk: JaggedTensor, cumulative: bool = False) → JaggedTensor[source]

Get the inverse permutation of ijk_to_index_batch() for a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch to index into.

  • ijk (JaggedTensor) – Voxel coordinates with integer dtype.

  • cumulative (bool) – If True, return indices cumulative across the batch.

Returns:

indices (JaggedTensor) – Inverse permutation indices.

fvdb.functional.ijk_to_inv_index_single(grid: Grid, ijk: torch.Tensor, cumulative: bool = False) → torch.Tensor[source]

Get the inverse permutation of ijk_to_index_single() for a single grid.

Parameters:
  • grid (Grid) – The single grid to index into.

  • ijk (torch.Tensor) – Voxel coordinates with integer dtype.

  • cumulative (bool) – If True, return indices cumulative across the batch.

Returns:

indices (torch.Tensor) – Inverse permutation indices.

fvdb.functional.neighbor_indexes_batch(grid: GridBatch, ijk: JaggedTensor, extent: int, bitshift: int = 0) → JaggedTensor[source]

Get linear indices of neighboring voxels in an N-ring neighborhood for a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch to query.

  • ijk (JaggedTensor) – Voxel coordinates with integer dtype.

  • extent (int) – Neighborhood ring size.

  • bitshift (int) – Optional bit shift applied to input coordinates. Default 0.

Returns:

indices (JaggedTensor) – Neighbor indices; -1 for inactive neighbors.

fvdb.functional.neighbor_indexes_single(grid: Grid, ijk: torch.Tensor, extent: int, bitshift: int = 0) → torch.Tensor[source]

Get linear indices of neighboring voxels in an N-ring neighborhood for a single grid.

Parameters:
  • grid (Grid) – The single grid to query.

  • ijk (torch.Tensor) – Voxel coordinates with integer dtype.

  • extent (int) – Neighborhood ring size.

  • bitshift (int) – Optional bit shift applied to input coordinates. Default 0.

Returns:

indices (torch.Tensor) – Neighbor indices; -1 for inactive neighbors.

fvdb.functional.active_grid_coords_batch(grid: GridBatch) → JaggedTensor[source]

Return the voxel coordinates of every active voxel in a grid batch, in index order.

Parameters:

grid (GridBatch) – The grid batch to query.

Returns:

ijk (JaggedTensor) – Voxel coordinates, shape (B, -1, 3).

fvdb.functional.active_grid_coords_single(grid: Grid) → torch.Tensor[source]

Return the voxel coordinates of every active voxel in a single grid, in index order.

Parameters:

grid (Grid) – The single grid to query.

Returns:

ijk (torch.Tensor) – Voxel coordinates, shape (N, 3).

Dense–Sparse Conversion

fvdb.functional.inject_from_dense_cminor_batch(grid: GridBatch, dense_data: torch.Tensor, dense_origin: NumericMaxRank1 = 0) → JaggedTensor[source]

Inject values from a dense tensor (XYZC order) into sparse voxel data for a grid batch.

Supports backpropagation.

Parameters:
  • grid (GridBatch) – The grid batch defining the sparse topology.

  • dense_data (torch.Tensor) – Dense input tensor, shape (B, X, Y, Z, C*).

  • dense_origin (NumericMaxRank1) – Voxel-space origin of the dense tensor.

Returns:

result (JaggedTensor) – Sparse voxel data extracted from the dense tensor.

fvdb.functional.inject_from_dense_cminor_single(grid: Grid, dense_data: torch.Tensor, dense_origin: NumericMaxRank1 = 0) → torch.Tensor[source]

Inject values from a dense tensor (XYZC order) into sparse voxel data for a single grid.

Supports backpropagation.

Parameters:
  • grid (Grid) – The single grid defining the sparse topology.

  • dense_data (torch.Tensor) – Dense input tensor, shape (1, X, Y, Z, C*).

  • dense_origin (NumericMaxRank1) – Voxel-space origin of the dense tensor.

Returns:

result (torch.Tensor) – Sparse voxel data extracted from the dense tensor.

fvdb.functional.inject_from_dense_cmajor_batch(grid: GridBatch, dense_data: torch.Tensor, dense_origin: NumericMaxRank1 = 0) → JaggedTensor[source]

Inject values from a dense tensor (CXYZ order) into sparse voxel data for a grid batch.

Supports backpropagation.

Parameters:
  • grid (GridBatch) – The grid batch defining the sparse topology.

  • dense_data (torch.Tensor) – Dense input tensor, shape (B, C*, X, Y, Z).

  • dense_origin (NumericMaxRank1) – Voxel-space origin of the dense tensor.

Returns:

result (JaggedTensor) – Sparse voxel data extracted from the dense tensor.

fvdb.functional.inject_from_dense_cmajor_single(grid: Grid, dense_data: torch.Tensor, dense_origin: NumericMaxRank1 = 0) → torch.Tensor[source]

Inject values from a dense tensor (CXYZ order) into sparse voxel data for a single grid.

Supports backpropagation.

Parameters:
  • grid (Grid) – The single grid defining the sparse topology.

  • dense_data (torch.Tensor) – Dense input tensor, shape (1, C*, X, Y, Z).

  • dense_origin (NumericMaxRank1) – Voxel-space origin of the dense tensor.

Returns:

result (torch.Tensor) – Sparse voxel data extracted from the dense tensor.

fvdb.functional.inject_to_dense_cminor_batch(grid: GridBatch, sparse_data: JaggedTensor, min_coord: NumericMaxRank1 | NumericMaxRank2 | None = None, grid_size: NumericMaxRank1 | None = None) → torch.Tensor[source]

Write sparse voxel data into a dense tensor (XYZC order) for a grid batch.

Supports backpropagation.

Parameters:
  • grid (GridBatch) – The grid batch defining the sparse topology.

  • sparse_data (JaggedTensor) – Per-voxel feature data.

  • min_coord (NumericMaxRank1 | NumericMaxRank2 | None) – Minimum voxel coordinate for the dense grid.

  • grid_size (NumericMaxRank1 | None) – Size of the dense grid, broadcastable to (3,).

Returns:

result (torch.Tensor) – Dense tensor, shape (B, X, Y, Z, C*).

fvdb.functional.inject_to_dense_cminor_single(grid: Grid, sparse_data: torch.Tensor, min_coord: NumericMaxRank1 | None = None, grid_size: NumericMaxRank1 | None = None) → torch.Tensor[source]

Write sparse voxel data into a dense tensor (XYZC order) for a single grid.

Supports backpropagation.

Parameters:
  • grid (Grid) – The single grid defining the sparse topology.

  • sparse_data (torch.Tensor) – Per-voxel feature data.

  • min_coord (NumericMaxRank1 | None) – Minimum voxel coordinate for the dense grid.

  • grid_size (NumericMaxRank1 | None) – Size of the dense grid, broadcastable to (3,).

Returns:

result (torch.Tensor) – Dense tensor, shape (1, X, Y, Z, C*).

fvdb.functional.inject_to_dense_cmajor_batch(grid: GridBatch, sparse_data: JaggedTensor, min_coord: NumericMaxRank1 | NumericMaxRank2 | None = None, grid_size: NumericMaxRank1 | None = None) → torch.Tensor[source]

Write sparse voxel data into a dense tensor (CXYZ order) for a grid batch.

Supports backpropagation.

Parameters:
  • grid (GridBatch) – The grid batch defining the sparse topology.

  • sparse_data (JaggedTensor) – Per-voxel feature data.

  • min_coord (NumericMaxRank1 | NumericMaxRank2 | None) – Minimum voxel coordinate for the dense grid.

  • grid_size (NumericMaxRank1 | None) – Size of the dense grid, broadcastable to (3,).

Returns:

result (torch.Tensor) – Dense tensor, shape (B, C*, X, Y, Z).

fvdb.functional.inject_to_dense_cmajor_single(grid: Grid, sparse_data: torch.Tensor, min_coord: NumericMaxRank1 | None = None, grid_size: NumericMaxRank1 | None = None) → torch.Tensor[source]

Write sparse voxel data into a dense tensor (CXYZ order) for a single grid.

Supports backpropagation.

Parameters:
  • grid (Grid) – The single grid defining the sparse topology.

  • sparse_data (torch.Tensor) – Per-voxel feature data.

  • min_coord (NumericMaxRank1 | None) – Minimum voxel coordinate for the dense grid.

  • grid_size (NumericMaxRank1 | None) – Size of the dense grid, broadcastable to (3,).

Returns:

result (torch.Tensor) – Dense tensor, shape (1, C*, X, Y, Z).

Grid-to-Grid Injection

fvdb.functional.inject_batch(dst_grid: GridBatch, src_grid: GridBatch, src: JaggedTensor, dst: JaggedTensor | None = None, default_value: float | int | bool = 0) → JaggedTensor[source]

Inject data from src_grid into dst_grid in voxel space for grid batches.

Supports backpropagation.

Parameters:
  • dst_grid (GridBatch) – The destination grid batch.

  • src_grid (GridBatch) – The source grid batch.

  • src (JaggedTensor) – Source per-voxel data.

  • dst (JaggedTensor | None) – Optional destination buffer; created with default_value if None.

  • default_value (float | int | bool) – Fill value for unmatched voxels. Default 0.

Returns:

result (JaggedTensor) – Destination data with injected values.

See also

inject_single()

fvdb.functional.inject_single(dst_grid: Grid, src_grid: Grid, src: torch.Tensor, dst: torch.Tensor | None = None, default_value: float | int | bool = 0) → torch.Tensor[source]

Inject data from src_grid into dst_grid in voxel space for single grids.

Supports backpropagation.

Parameters:
  • dst_grid (Grid) – The destination single grid.

  • src_grid (Grid) – The source single grid.

  • src (torch.Tensor) – Source per-voxel data.

  • dst (torch.Tensor | None) – Optional destination buffer; created with default_value if None.

  • default_value (float | int | bool) – Fill value for unmatched voxels. Default 0.

Returns:

result (torch.Tensor) – Destination data with injected values.

See also

inject_batch()

fvdb.functional.inject_from_ijk_batch(grid: GridBatch, src_ijk: JaggedTensor, src: JaggedTensor, dst: JaggedTensor | None = None, default_value: float | int | bool = 0) → JaggedTensor[source]

Inject data from source voxel coordinates into a grid batch’s voxel data.

Supports backpropagation.

Parameters:
  • grid (GridBatch) – The grid batch to inject into.

  • src_ijk (JaggedTensor) – Source voxel coordinates, shape (B, -1, 3).

  • src (JaggedTensor) – Source per-voxel data.

  • dst (JaggedTensor | None) – Optional destination buffer; created with default_value if None.

  • default_value (float | int | bool) – Fill value for unmatched voxels. Default 0.

Returns:

result (JaggedTensor) – Destination data with injected values.

fvdb.functional.inject_from_ijk_single(grid: Grid, src_ijk: torch.Tensor, src: torch.Tensor, dst: torch.Tensor | None = None, default_value: float | int | bool = 0) → torch.Tensor[source]

Inject data from source voxel coordinates into a single grid’s voxel data.

Supports backpropagation.

Parameters:
  • grid (Grid) – The single grid to inject into.

  • src_ijk (torch.Tensor) – Source voxel coordinates, shape (N, 3).

  • src (torch.Tensor) – Source per-voxel data.

  • dst (torch.Tensor | None) – Optional destination buffer; created with default_value if None.

  • default_value (float | int | bool) – Fill value for unmatched voxels. Default 0.

Returns:

result (torch.Tensor) – Destination data with injected values.

Ray Operations

fvdb.functional.voxels_along_rays_batch(grid: GridBatch, ray_origins: JaggedTensor, ray_directions: JaggedTensor, max_voxels: int, eps: float = 0.0, return_ijk: bool = False, cumulative: bool = False) → tuple[JaggedTensor, JaggedTensor][source]

Enumerate voxels intersected by rays using a DDA traversal on a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch to trace through.

  • ray_origins (JaggedTensor) – Ray origin positions, shape (B, -1, 3).

  • ray_directions (JaggedTensor) – Ray direction vectors, shape (B, -1, 3).

  • max_voxels (int) – Maximum number of voxels to return per ray.

  • eps (float) – Small offset to avoid self-intersection. Default 0.0.

  • return_ijk (bool) – If True, return voxel coordinates instead of linear indices.

  • cumulative (bool) – If True, return cumulative indices across the batch.

Returns:
  • voxels (JaggedTensor) – Voxel coordinates or linear indices per ray hit.

  • distances (JaggedTensor) – (t_entry, t_exit) pairs per ray hit.

fvdb.functional.voxels_along_rays_single(grid: Grid, ray_origins: torch.Tensor, ray_directions: torch.Tensor, max_voxels: int, eps: float = 0.0, return_ijk: bool = False) → tuple[JaggedTensor, JaggedTensor][source]

Enumerate voxels intersected by rays using a DDA traversal on a single grid.

Parameters:
  • grid (Grid) – The single grid to trace through.

  • ray_origins (torch.Tensor) – Ray origin positions, shape (N, 3).

  • ray_directions (torch.Tensor) – Ray direction vectors, shape (N, 3).

  • max_voxels (int) – Maximum number of voxels to return per ray.

  • eps (float) – Small offset to avoid self-intersection. Default 0.0.

  • return_ijk (bool) – If True, return voxel coordinates instead of linear indices.

Returns:
  • voxels (JaggedTensor) – Voxel coordinates or linear indices per ray hit.

  • distances (JaggedTensor) – (t_entry, t_exit) pairs per ray hit.

fvdb.functional.segments_along_rays_batch(grid: GridBatch, ray_origins: JaggedTensor, ray_directions: JaggedTensor, max_segments: int, eps: float = 0.0) → JaggedTensor[source]

Return continuous segments of ray traversal through a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch to trace through.

  • ray_origins (JaggedTensor) – Ray origin positions, shape (B, -1, 3).

  • ray_directions (JaggedTensor) – Ray direction vectors, shape (B, -1, 3).

  • max_segments (int) – Maximum number of segments to return per ray.

  • eps (float) – Small offset to avoid self-intersection. Default 0.0.

Returns:

segments (JaggedTensor) – (t_start, t_end) pairs per ray segment.

fvdb.functional.segments_along_rays_single(grid: Grid, ray_origins: torch.Tensor, ray_directions: torch.Tensor, max_segments: int, eps: float = 0.0) → JaggedTensor[source]

Return continuous segments of ray traversal through a single grid.

Parameters:
  • grid (Grid) – The single grid to trace through.

  • ray_origins (torch.Tensor) – Ray origin positions, shape (N, 3).

  • ray_directions (torch.Tensor) – Ray direction vectors, shape (N, 3).

  • max_segments (int) – Maximum number of segments to return per ray.

  • eps (float) – Small offset to avoid self-intersection. Default 0.0.

Returns:

segments (JaggedTensor) – (t_start, t_end) pairs per ray segment.

fvdb.functional.uniform_ray_samples_batch(grid: GridBatch, ray_origins: JaggedTensor, ray_directions: JaggedTensor, t_min: JaggedTensor, t_max: JaggedTensor, step_size: float, cone_angle: float = 0.0, include_end_segments: bool = True, return_midpoints: bool = False, eps: float = 0.0) → JaggedTensor[source]

Generate uniformly spaced samples along rays that intersect active voxels of a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch to sample through.

  • ray_origins (JaggedTensor) – Ray origin positions, shape (B, -1, 3).

  • ray_directions (JaggedTensor) – Ray direction vectors, shape (B, -1, 3).

  • t_min (JaggedTensor) – Minimum ray distances per ray.

  • t_max (JaggedTensor) – Maximum ray distances per ray.

  • step_size (float) – Distance between consecutive samples.

  • cone_angle (float) – Cone angle for mip-mapping. Default 0.0.

  • include_end_segments (bool) – Include segment endpoints. Default True.

  • return_midpoints (bool) – Return midpoints instead of boundaries. Default False.

  • eps (float) – Small offset to avoid self-intersection. Default 0.0.

Returns:

samples (JaggedTensor) – Sample distances along each ray.

fvdb.functional.uniform_ray_samples_single(grid: Grid, ray_origins: torch.Tensor, ray_directions: torch.Tensor, t_min: torch.Tensor, t_max: torch.Tensor, step_size: float, cone_angle: float = 0.0, include_end_segments: bool = True, return_midpoints: bool = False, eps: float = 0.0) → JaggedTensor[source]

Generate uniformly spaced samples along rays that intersect active voxels of a single grid.

Parameters:
  • grid (Grid) – The single grid to sample through.

  • ray_origins (torch.Tensor) – Ray origin positions, shape (N, 3).

  • ray_directions (torch.Tensor) – Ray direction vectors, shape (N, 3).

  • t_min (torch.Tensor) – Minimum ray distances per ray.

  • t_max (torch.Tensor) – Maximum ray distances per ray.

  • step_size (float) – Distance between consecutive samples.

  • cone_angle (float) – Cone angle for mip-mapping. Default 0.0.

  • include_end_segments (bool) – Include segment endpoints. Default True.

  • return_midpoints (bool) – Return midpoints instead of boundaries. Default False.

  • eps (float) – Small offset to avoid self-intersection. Default 0.0.

Returns:

samples (JaggedTensor) – Sample distances along each ray.

fvdb.functional.ray_implicit_intersection_batch(grid: GridBatch, ray_origins: JaggedTensor, ray_directions: JaggedTensor, grid_scalars: JaggedTensor, eps: float = 0.0) → JaggedTensor[source]

Find ray intersections with an implicit surface defined by grid scalars on a grid batch.

The first valid (non-NaN) voxel sampled along each ray seeds the sign reference, and the first subsequent voxel with the opposite sign is reported as the intersection. Both “positive outside” and “negative outside” SDF conventions are therefore handled identically, and a ray that enters the bbox already inside the surface is reported at the exit of the surface along the ray.

Parameters:
  • grid (GridBatch) – The grid batch defining the implicit surface topology.

  • ray_origins (JaggedTensor) – Ray origin positions, shape (B, -1, 3).

  • ray_directions (JaggedTensor) – Ray direction vectors, shape (B, -1, 3).

  • grid_scalars (JaggedTensor) – Per-voxel scalar values defining the implicit surface.

  • eps (float) – Small offset to avoid self-intersection. Default 0.0.

Returns:

distances (JaggedTensor) – Intersection distance per ray, or -1 if no intersection.

fvdb.functional.ray_implicit_intersection_single(grid: Grid, ray_origins: torch.Tensor, ray_directions: torch.Tensor, grid_scalars: torch.Tensor, eps: float = 0.0) → torch.Tensor[source]

Find ray intersections with an implicit surface defined by grid scalars on a single grid.

The first valid (non-NaN) voxel sampled along each ray seeds the sign reference, and the first subsequent voxel with the opposite sign is reported as the intersection. Both “positive outside” and “negative outside” SDF conventions are therefore handled identically, and a ray that enters the bbox already inside the surface is reported at the exit of the surface along the ray.

Parameters:
  • grid (Grid) – The single grid defining the implicit surface topology.

  • ray_origins (torch.Tensor) – Ray origin positions, shape (N, 3).

  • ray_directions (torch.Tensor) – Ray direction vectors, shape (N, 3).

  • grid_scalars (torch.Tensor) – Per-voxel scalar values defining the implicit surface.

  • eps (float) – Small offset to avoid self-intersection. Default 0.0.

Returns:

distances (torch.Tensor) – Intersection distance per ray, or -1 if no intersection.

fvdb.functional.rays_intersect_voxels_batch(grid: GridBatch, ray_origins: JaggedTensor, ray_directions: JaggedTensor, eps: float = 0.0) → JaggedTensor[source]

Check whether rays hit any voxels in a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch to test against.

  • ray_origins (JaggedTensor) – Ray origin positions, shape (B, -1, 3).

  • ray_directions (JaggedTensor) – Ray direction vectors, shape (B, -1, 3).

  • eps (float) – Small offset to avoid self-intersection. Default 0.0.

Returns:

hit (JaggedTensor) – Boolean mask indicating whether each ray hit a voxel.

fvdb.functional.rays_intersect_voxels_single(grid: Grid, ray_origins: torch.Tensor, ray_directions: torch.Tensor, eps: float = 0.0) → torch.Tensor[source]

Check whether rays hit any voxels in a single grid.

Parameters:
  • grid (Grid) – The single grid to test against.

  • ray_origins (torch.Tensor) – Ray origin positions, shape (N, 3).

  • ray_directions (torch.Tensor) – Ray direction vectors, shape (N, 3).

  • eps (float) – Small offset to avoid self-intersection. Default 0.0.

Returns:

hit (torch.Tensor) – Boolean mask indicating whether each ray hit a voxel.

Meshing and TSDF Integration

fvdb.functional.marching_cubes_batch(grid: GridBatch, field: JaggedTensor, level: float = 0.0) → tuple[JaggedTensor, JaggedTensor, JaggedTensor][source]

Extract isosurface meshes using marching cubes on a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch defining the sparse topology.

  • field (JaggedTensor) – Per-voxel scalar field values.

  • level (float) – Isovalue at which to extract the surface. Default 0.0.

Returns:
  • vertices (JaggedTensor) – Mesh vertex positions, shape (B, -1, 3).

  • faces (JaggedTensor) – Triangle face indices.

  • vertex_edge_keys (JaggedTensor) – Edge keys used to deduplicate mesh vertices, dtype torch.int64, shape (B, -1, 3). Each row [batch_idx, voxel_a, voxel_b] identifies the grid edge on which the vertex was interpolated, where voxel_a and voxel_b are flat voxel indices of the two endpoint voxels (voxel_a >= voxel_b). This can be used to map mesh vertices back to the grid edges and voxels they originated from.

fvdb.functional.marching_cubes_single(grid: Grid, field: torch.Tensor, level: float = 0.0) → tuple[torch.Tensor, torch.Tensor, torch.Tensor][source]

Extract isosurface mesh using marching cubes on a single grid.

Parameters:
  • grid (Grid) – The single grid defining the sparse topology.

  • field (torch.Tensor) – Per-voxel scalar field values.

  • level (float) – Isovalue at which to extract the surface. Default 0.0.

Returns:
  • vertices (torch.Tensor) – Mesh vertex positions, shape (N, 3).

  • faces (torch.Tensor) – Triangle face indices.

  • vertex_edge_keys (torch.Tensor) – Edge keys used to deduplicate mesh vertices, dtype torch.int64, shape (N, 3). Each row [batch_idx, voxel_a, voxel_b] identifies the grid edge on which the vertex was interpolated, where voxel_a and voxel_b are flat voxel indices of the two endpoint voxels (voxel_a >= voxel_b). This can be used to map mesh vertices back to the grid edges and voxels they originated from. batch_idx is always 0 for a single grid.

fvdb.functional.integrate_tsdf_batch(grid: GridBatch, truncation_distance: float, projection_matrices: torch.Tensor, cam_to_world_matrices: torch.Tensor, tsdf: JaggedTensor, weights: JaggedTensor, depth_images: torch.Tensor, weight_images: torch.Tensor | None = None) → tuple[GridBatch, JaggedTensor, JaggedTensor][source]

Integrate depth images into a TSDF volume for a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch defining the TSDF topology.

  • truncation_distance (float) – TSDF truncation distance.

  • projection_matrices (torch.Tensor) – Camera projection matrices.

  • cam_to_world_matrices (torch.Tensor) – Camera-to-world transform matrices.

  • tsdf (JaggedTensor) – Current TSDF values.

  • weights (JaggedTensor) – Current integration weights.

  • depth_images (torch.Tensor) – Depth images to integrate.

  • weight_images (torch.Tensor | None) – Optional per-pixel weight images.

Returns:
  • updated_grid (GridBatch) – The updated grid batch.

  • updated_tsdf (JaggedTensor) – Updated TSDF values.

  • updated_weights (JaggedTensor) – Updated integration weights.

fvdb.functional.integrate_tsdf_single(grid: Grid, truncation_distance: float, projection_matrices: torch.Tensor, cam_to_world_matrices: torch.Tensor, tsdf: torch.Tensor, weights: torch.Tensor, depth_images: torch.Tensor, weight_images: torch.Tensor | None = None) → tuple[Grid, torch.Tensor, torch.Tensor][source]

Integrate depth images into a TSDF volume for a single grid.

Parameters:
  • grid (Grid) – The single grid defining the TSDF topology.

  • truncation_distance (float) – TSDF truncation distance.

  • projection_matrices (torch.Tensor) – Camera projection matrices.

  • cam_to_world_matrices (torch.Tensor) – Camera-to-world transform matrices.

  • tsdf (torch.Tensor) – Current TSDF values.

  • weights (torch.Tensor) – Current integration weights.

  • depth_images (torch.Tensor) – Depth images to integrate.

  • weight_images (torch.Tensor | None) – Optional per-pixel weight images.

Returns:
  • updated_grid (Grid) – The updated grid.

  • updated_tsdf (torch.Tensor) – Updated TSDF values.

  • updated_weights (torch.Tensor) – Updated integration weights.

fvdb.functional.integrate_tsdf_with_features_batch(grid: GridBatch, truncation_distance: float, projection_matrices: torch.Tensor, cam_to_world_matrices: torch.Tensor, tsdf: JaggedTensor, features: JaggedTensor, weights: JaggedTensor, depth_images: torch.Tensor, feature_images: torch.Tensor, weight_images: torch.Tensor | None = None) → tuple[GridBatch, JaggedTensor, JaggedTensor, JaggedTensor][source]

Integrate depth and feature images into a TSDF volume with features for a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch defining the TSDF topology.

  • truncation_distance (float) – TSDF truncation distance.

  • projection_matrices (torch.Tensor) – Camera projection matrices.

  • cam_to_world_matrices (torch.Tensor) – Camera-to-world transform matrices.

  • tsdf (JaggedTensor) – Current TSDF values.

  • features (JaggedTensor) – Current per-voxel features.

  • weights (JaggedTensor) – Current integration weights.

  • depth_images (torch.Tensor) – Depth images to integrate.

  • feature_images (torch.Tensor) – Feature images to integrate.

  • weight_images (torch.Tensor | None) – Optional per-pixel weight images.

Returns:
  • updated_grid (GridBatch) – The updated grid batch.

  • updated_tsdf (JaggedTensor) – Updated TSDF values.

  • updated_weights (JaggedTensor) – Updated integration weights.

  • updated_features (JaggedTensor) – Updated per-voxel features.

fvdb.functional.integrate_tsdf_with_features_single(grid: Grid, truncation_distance: float, projection_matrices: torch.Tensor, cam_to_world_matrices: torch.Tensor, tsdf: torch.Tensor, features: torch.Tensor, weights: torch.Tensor, depth_images: torch.Tensor, feature_images: torch.Tensor, weight_images: torch.Tensor | None = None) → tuple[Grid, torch.Tensor, torch.Tensor, torch.Tensor][source]

Integrate depth and feature images into a TSDF volume with features for a single grid.

Parameters:
  • grid (Grid) – The single grid defining the TSDF topology.

  • truncation_distance (float) – TSDF truncation distance.

  • projection_matrices (torch.Tensor) – Camera projection matrices.

  • cam_to_world_matrices (torch.Tensor) – Camera-to-world transform matrices.

  • tsdf (torch.Tensor) – Current TSDF values.

  • features (torch.Tensor) – Current per-voxel features.

  • weights (torch.Tensor) – Current integration weights.

  • depth_images (torch.Tensor) – Depth images to integrate.

  • feature_images (torch.Tensor) – Feature images to integrate.

  • weight_images (torch.Tensor | None) – Optional per-pixel weight images.

Returns:
  • updated_grid (Grid) – The updated grid.

  • updated_tsdf (torch.Tensor) – Updated TSDF values.

  • updated_weights (torch.Tensor) – Updated integration weights.

  • updated_features (torch.Tensor) – Updated per-voxel features.

Signed Distance Fields

fvdb.functional.reinitialize_sdf_batch(grid: GridBatch, field: JaggedTensor, band: int = 3, smooth: int = 0, order: int = 3, smoothing: SmoothingMode = SmoothingMode.MEAN_CURVATURE, redistance_iters: int = -1) → JaggedTensor[source]

Re-initialize a signed per-voxel field into an SDF on the same grid batch.

Redistances field to satisfy |grad phi| = 1 (TVD-RK Godunov upwind eikonal solve with a frozen Peng sign), then optionally de-staircases it with curvature-based smoothing. The grid topology is unchanged: the returned field has the same per-voxel ordering as field.

Parameters:
  • grid (GridBatch) – The grid batch defining the sparse topology.

  • field (JaggedTensor) – Per-voxel signed field values.

  • band (int) – Narrow-band half-width in voxels. The field is clamped to [-band*vx, band*vx].

  • smooth (int) – Number of smoothing passes (0 disables smoothing).

  • order (int) – TVD-RK order, one of 1 (Euler), 2 (Heun), or 3 (Shu-Osher).

  • smoothing (SmoothingMode) – Which Laplacian flow each smoothing pass applies – MEAN_CURVATURE (default) or TAUBIN (volume-preserving). Only used when smooth > 0.

  • redistance_iters (int) – Number of redistancing sweeps. <= 0 uses the default max(6, round(2.5*band) + 2).

Returns:

sdf (JaggedTensor) – The re-initialized SDF, same per-voxel ordering as field.

Note

  • field must represent the intended inside/outside regions and zero crossings. Its magnitudes need not be accurate distances, but affect convergence, accuracy, and sub-voxel surface location. With smooth=0 redistancing aims to preserve the input surface, subject to discretization error; smoothing moves the surface and then re-redistances.

  • Values must be finite, with shape (N,) or (N, 1) (for a batch, the shape of field.jdata). Invalid shapes and NaN/Inf values raise ValueError.

  • The surface is where the field changes sign between active voxels; one active voxel of each sign across the crossing is sufficient (two or more per side gives the best sub-voxel accuracy). A grid whose active values are all one sign has no surface: the result is the constant -/+band*vx and rebuild_narrow_band_batch() returns an empty band, which is correct for e.g. a tile that lies entirely inside an object.

  • Inactive neighbours read as +/-band*vx using the adjacent voxel’s frozen sign during redistancing and its current sign during smoothing. Both filled solids (interior active) and narrow bands whose interior is inactive are valid inputs. Leave no-data voxels inactive rather than assigning them NaN/Inf values.

  • Voxels whose value is exactly 0 have a zero frozen sign and are left at 0 by the redistance (a no-data pass-through relied on by the ray-implicit-intersection op, which treats exact 0 as a gap). Their signed neighbours, however, see them as an interface and are redistanced toward them, and smoothing blends them – prune such voxels first when you can.

  • Each grid must have isotropic voxels (ValueError otherwise); grids in the batch may differ from one another. CUDA only; float32 or float64.

fvdb.functional.reinitialize_sdf_single(grid: Grid, field: torch.Tensor, band: int = 3, smooth: int = 0, order: int = 3, smoothing: SmoothingMode = SmoothingMode.MEAN_CURVATURE, redistance_iters: int = -1) → torch.Tensor[source]

Re-initialize a signed per-voxel field into an SDF on a single grid.

Parameters:
  • grid (Grid) – The single grid defining the sparse topology.

  • field (torch.Tensor) – Per-voxel signed field values, shape (num_voxels,) or (num_voxels, 1).

  • band (int) – Narrow-band half-width in voxels.

  • smooth (int) – Number of smoothing passes (0 disables smoothing).

  • order (int) – TVD-RK order, one of 1, 2, or 3.

  • smoothing (SmoothingMode) – Which Laplacian flow each smoothing pass applies – MEAN_CURVATURE (default) or TAUBIN (volume-preserving). Only used when smooth > 0.

  • redistance_iters (int) – Number of redistancing sweeps. <= 0 uses the default.

Returns:

sdf (torch.Tensor) – The re-initialized SDF, shape (num_voxels,).

Note

See reinitialize_sdf_batch() for the input contract.

fvdb.functional.rebuild_narrow_band_batch(grid: GridBatch, field: JaggedTensor, band: int = 3, smooth: int = 0, order: int = 3, smoothing: SmoothingMode = SmoothingMode.MEAN_CURVATURE, redistance_iters: int = -1, pad: bool = True, prune: bool = True) → tuple[GridBatch, JaggedTensor][source]

Rebuild a signed field into a clean narrow-band SDF on a (possibly pruned) grid batch.

If pad is True the grid is first dilated by band voxels (so the eikonal solve has room to propagate a full-width band), then reinitialize_sdf_batch() is run, and finally, if prune is True, the grid is pruned to the voxels strictly inside the band (|phi| < band*vx*0.999). The prune reuses GridBatch.pruned_grid(); the resulting field is selected in the grid’s canonical voxel order so it stays aligned with the pruned grid.

Parameters:
  • grid (GridBatch) – The grid batch defining the sparse topology.

  • field (JaggedTensor) – Per-voxel signed field values.

  • band (int) – Narrow-band half-width in voxels.

  • smooth (int) – Number of smoothing passes (0 disables smoothing).

  • order (int) – TVD-RK order, one of 1, 2, or 3.

  • smoothing (SmoothingMode) – Which Laplacian flow each smoothing pass applies – MEAN_CURVATURE (default) or TAUBIN (volume-preserving). Only used when smooth > 0.

  • redistance_iters (int) – Number of redistancing sweeps. <= 0 uses the default.

  • pad (bool) – If True (default) dilate the grid by band voxels before redistancing so the output narrow band is a full band voxels wide even if the input grid had a thinner active region. The dilation grows one layer at a time and seeds each new voxel with +/-band*vx according to the sign of its existing neighbours, so padding continues a narrow band both outward (exterior) and inward (interior) and works for filled solids as well as narrow bands whose interior is inactive.

  • prune (bool) – If True prune to the narrow band; if False return the (possibly padded) grid and the re-initialized field unchanged.

Returns:
  • out_grid (GridBatch) – The pruned (or, with prune=False, the padded/original) grid batch.

  • sdf (JaggedTensor) – The narrow-band SDF, aligned with out_grid.

Note

Applying this to its own output reproduces it (up to a voxel layer at the band edge). See reinitialize_sdf_batch() for the input contract.

fvdb.functional.rebuild_narrow_band_single(grid: Grid, field: torch.Tensor, band: int = 3, smooth: int = 0, order: int = 3, smoothing: SmoothingMode = SmoothingMode.MEAN_CURVATURE, redistance_iters: int = -1, pad: bool = True, prune: bool = True) → tuple[Grid, torch.Tensor][source]

Rebuild a signed field into a clean narrow-band SDF on a (possibly pruned) single grid.

If pad is True the grid is first dilated by band voxels (so the eikonal solve has room to propagate a full-width band), then reinitialize_sdf_single() is run, and finally, if prune is True, the grid is pruned to the voxels strictly inside the band (|phi| < band*vx*0.999).

Parameters:
  • grid (Grid) – The single grid defining the sparse topology.

  • field (torch.Tensor) – Per-voxel signed field values, shape (num_voxels,) or (num_voxels, 1).

  • band (int) – Narrow-band half-width in voxels.

  • smooth (int) – Number of smoothing passes (0 disables smoothing).

  • order (int) – TVD-RK order, one of 1, 2, or 3.

  • smoothing (SmoothingMode) – Which Laplacian flow each smoothing pass applies – MEAN_CURVATURE (default) or TAUBIN (volume-preserving). Only used when smooth > 0.

  • redistance_iters (int) – Number of redistancing sweeps. <= 0 uses the default.

  • pad (bool) – If True (default) dilate the grid by band voxels before redistancing so the output narrow band is a full band voxels wide even if the input grid had a thinner active region. The dilation grows one layer at a time and seeds each new voxel with +/-band*vx according to the sign of its existing neighbours, so padding continues a narrow band both outward (exterior) and inward (interior) and works for filled solids as well as narrow bands whose interior is inactive.

  • prune (bool) – If True prune to the narrow band; if False return the (possibly padded) grid and the re-initialized field unchanged.

Returns:
  • out_grid (Grid) – The pruned (or, with prune=False, the padded/original) grid.

  • sdf (torch.Tensor) – The narrow-band SDF, aligned with out_grid.

Note

Applying this to its own output reproduces it (up to a voxel layer at the band edge). See reinitialize_sdf_batch() for the input contract.

Grid Topology

fvdb.functional.coarsened_grid_batch(grid: GridBatch, coarsening_factor: NumericMaxRank1) → GridBatch[source]

Return a coarsened version of a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch to coarsen.

  • coarsening_factor (NumericMaxRank1) – Factor per axis, broadcastable to (3,).

Returns:

result (GridBatch) – The coarsened grid batch.

fvdb.functional.coarsened_grid_single(grid: Grid, coarsening_factor: NumericMaxRank1) → Grid[source]

Return a coarsened version of a single grid.

Parameters:
  • grid (Grid) – The single grid to coarsen.

  • coarsening_factor (NumericMaxRank1) – Factor per axis, broadcastable to (3,).

Returns:

result (Grid) – The coarsened grid.

fvdb.functional.refined_grid_batch(grid: GridBatch, subdiv_factor: NumericMaxRank1, mask: JaggedTensor | None = None) → GridBatch[source]

Return a refined (subdivided) version of a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch to refine.

  • subdiv_factor (NumericMaxRank1) – Subdivision factor per axis, broadcastable to (3,).

  • mask (JaggedTensor | None) – Optional boolean mask selecting voxels to refine.

Returns:

result (GridBatch) – The refined grid batch.

fvdb.functional.refined_grid_single(grid: Grid, subdiv_factor: NumericMaxRank1, mask: torch.Tensor | None = None) → Grid[source]

Return a refined (subdivided) version of a single grid.

Parameters:
  • grid (Grid) – The single grid to refine.

  • subdiv_factor (NumericMaxRank1) – Subdivision factor per axis, broadcastable to (3,).

  • mask (torch.Tensor | None) – Optional boolean mask selecting voxels to refine.

Returns:

result (Grid) – The refined grid.

fvdb.functional.dual_grid_batch(grid: GridBatch, exclude_border: bool = False) → GridBatch[source]

Return the dual grid of a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch.

  • exclude_border (bool) – If True, exclude border voxels from the dual.

Returns:

result (GridBatch) – The dual grid batch.

fvdb.functional.dual_grid_single(grid: Grid, exclude_border: bool = False) → Grid[source]

Return the dual grid of a single grid.

Parameters:
  • grid (Grid) – The single grid.

  • exclude_border (bool) – If True, exclude border voxels from the dual.

Returns:

result (Grid) – The dual grid.

fvdb.functional.dilated_grid_batch(grid: GridBatch, dilation: int) → GridBatch[source]

Return a dilated version of a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch to dilate.

  • dilation (int) – Number of voxels to dilate by.

Returns:

result (GridBatch) – The dilated grid batch.

fvdb.functional.dilated_grid_single(grid: Grid, dilation: int) → Grid[source]

Return a dilated version of a single grid.

Parameters:
  • grid (Grid) – The single grid to dilate.

  • dilation (int) – Number of voxels to dilate by.

Returns:

result (Grid) – The dilated grid.

fvdb.functional.merged_grid_batch(grid: GridBatch, other: GridBatch) → GridBatch[source]

Return the union of two grid batches.

Parameters:
Returns:

result (GridBatch) – Grid batch containing the union of active voxels.

fvdb.functional.merged_grid_single(grid: Grid, other: Grid) → Grid[source]

Return the union of two single grids.

Parameters:
  • grid (Grid) – The first single grid.

  • other (Grid) – The second single grid.

Returns:

result (Grid) – Grid containing the union of active voxels.

fvdb.functional.pruned_grid_batch(grid: GridBatch, mask: JaggedTensor) → GridBatch[source]

Return a grid batch containing only voxels where mask is True.

Parameters:
  • grid (GridBatch) – The grid batch to prune.

  • mask (JaggedTensor) – Boolean mask selecting voxels to keep.

Returns:

result (GridBatch) – The pruned grid batch.

fvdb.functional.pruned_grid_single(grid: Grid, mask: torch.Tensor) → Grid[source]

Return a single grid containing only voxels where mask is True.

Parameters:
  • grid (Grid) – The single grid to prune.

  • mask (torch.Tensor) – Boolean mask selecting voxels to keep.

Returns:

result (Grid) – The pruned grid.

fvdb.functional.clipped_grid_batch(grid: GridBatch, ijk_min: NumericMaxRank2, ijk_max: NumericMaxRank2) → GridBatch[source]

Return a grid batch clipped to the voxel-space range [ijk_min, ijk_max].

Parameters:
  • grid (GridBatch) – The grid batch to clip.

  • ijk_min (NumericMaxRank2) – Minimum voxel coordinate bound.

  • ijk_max (NumericMaxRank2) – Maximum voxel coordinate bound.

Returns:

result (GridBatch) – The clipped grid batch.

fvdb.functional.clipped_grid_single(grid: Grid, ijk_min: NumericMaxRank1, ijk_max: NumericMaxRank1) → Grid[source]

Return a single grid clipped to the voxel-space range [ijk_min, ijk_max].

Parameters:
  • grid (Grid) – The single grid to clip.

  • ijk_min (NumericMaxRank1) – Minimum voxel coordinate bound.

  • ijk_max (NumericMaxRank1) – Maximum voxel coordinate bound.

Returns:

result (Grid) – The clipped grid.

fvdb.functional.clip_batch(grid: GridBatch, features: JaggedTensor, ijk_min: NumericMaxRank2, ijk_max: NumericMaxRank2) → tuple[JaggedTensor, GridBatch][source]

Clip a grid batch and its features to the voxel-space range [ijk_min, ijk_max].

Supports backpropagation on features.

Parameters:
  • grid (GridBatch) – The grid batch to clip.

  • features (JaggedTensor) – Per-voxel feature data.

  • ijk_min (NumericMaxRank2) – Minimum voxel coordinate bound.

  • ijk_max (NumericMaxRank2) – Maximum voxel coordinate bound.

Returns:
  • clipped_features (JaggedTensor) – Features for the clipped voxels.

  • clipped_grid (GridBatch) – The clipped grid batch.

See also

clip_single()

fvdb.functional.clip_single(grid: Grid, features: torch.Tensor, ijk_min: NumericMaxRank1, ijk_max: NumericMaxRank1) → tuple[torch.Tensor, Grid][source]

Clip a single grid and its features to the voxel-space range [ijk_min, ijk_max].

Supports backpropagation on features.

Parameters:
  • grid (Grid) – The single grid to clip.

  • features (torch.Tensor) – Per-voxel feature data.

  • ijk_min (NumericMaxRank1) – Minimum voxel coordinate bound.

  • ijk_max (NumericMaxRank1) – Maximum voxel coordinate bound.

Returns:
  • clipped_features (torch.Tensor) – Features for the clipped voxels.

  • clipped_grid (Grid) – The clipped grid.

See also

clip_batch()

fvdb.functional.contiguous_batch(grid: GridBatch) → GridBatch[source]

Return a contiguous copy of a grid batch.

Parameters:

grid (GridBatch) – The grid batch.

Returns:

result (GridBatch) – A contiguous copy of the grid batch.

fvdb.functional.contiguous_single(grid: Grid) → Grid[source]

Return a contiguous copy of a single grid.

Parameters:

grid (Grid) – The single grid.

Returns:

result (Grid) – A contiguous copy of the grid.

fvdb.functional.clone_grid_batch(grid: GridBatch, device: torch.device) → GridBatch[source]

Clone a grid batch to the specified device.

Parameters:
  • grid (GridBatch) – The grid batch to clone.

  • device (torch.device) – Target device.

Returns:

result (GridBatch) – A clone of the grid batch on the target device.

fvdb.functional.clone_grid_single(grid: Grid, device: torch.device) → Grid[source]

Clone a single grid to the specified device.

Parameters:
  • grid (Grid) – The single grid to clone.

  • device (torch.device) – Target device.

Returns:

result (Grid) – A clone of the grid on the target device.

fvdb.functional.conv_grid_batch(grid: GridBatch, kernel_size: NumericMaxRank1, stride: NumericMaxRank1 = 1) → GridBatch[source]

Return the complete structural-support grid for a convolution on a grid batch.

It uses the canonical componentwise Torch phase fine_ijk = stride * coarse_ijk + tap_ijk - padding_before, where fine_ijk and coarse_ijk are integer coordinates on the fine and strided lattices, padding_before = floor((kernel_size - 1) / 2), and the zero-based kernel tap satisfies 0 <= tap_ijk[axis] < kernel_size[axis]. The result is a convolution lattice (voxel size scaled by stride, canonical origin), not a block-coarsened grid. K=S=1 returns grid itself.

Parameters:
  • grid (GridBatch) – The input grid batch.

  • kernel_size (NumericMaxRank1) – Convolution kernel size, broadcastable to (3,).

  • stride (NumericMaxRank1) – Convolution stride, broadcastable to (3,).

Returns:

result (GridBatch) – The output grid batch for the convolution.

fvdb.functional.conv_grid_single(grid: Grid, kernel_size: NumericMaxRank1, stride: NumericMaxRank1 = 1) → Grid[source]

Return the complete structural-support grid for a convolution on a single grid.

This is the canonical convolution lattice, not a cell-coarsening operation. K=S=1 returns grid itself.

Parameters:
  • grid (Grid) – The input single grid.

  • kernel_size (NumericMaxRank1) – Convolution kernel size, broadcastable to (3,).

  • stride (NumericMaxRank1) – Convolution stride, broadcastable to (3,).

Returns:

result (Grid) – The output grid for the convolution.

fvdb.functional.conv_transpose_grid_batch(grid: GridBatch, kernel_size: NumericMaxRank1, stride: NumericMaxRank1 = 1) → GridBatch[source]

Return the complete structural-support grid for a transposed convolution on a grid batch.

Each active input coordinate spreads through all canonical Torch-phase taps. This generated support is not a value inverse of a forward convolution. K=S=1 returns grid itself.

Parameters:
  • grid (GridBatch) – The input grid batch.

  • kernel_size (NumericMaxRank1) – Kernel size, broadcastable to (3,).

  • stride (NumericMaxRank1) – Stride, broadcastable to (3,).

Returns:

result (GridBatch) – The output grid batch for the transposed convolution.

fvdb.functional.conv_transpose_grid_single(grid: Grid, kernel_size: NumericMaxRank1, stride: NumericMaxRank1 = 1) → Grid[source]

Return the complete structural-support grid for a transposed convolution on a single grid.

Each active input coordinate spreads through all canonical Torch-phase taps; this does not imply value inversion. K=S=1 returns grid itself.

Parameters:
  • grid (Grid) – The input single grid.

  • kernel_size (NumericMaxRank1) – Kernel size, broadcastable to (3,).

  • stride (NumericMaxRank1) – Stride, broadcastable to (3,).

Returns:

result (Grid) – The output grid for the transposed convolution.

Space-Filling Curves

fvdb.functional.morton_batch(grid: GridBatch, offset: torch.Tensor | NumericMaxRank1 | None = None) → JaggedTensor[source]

Return Morton (Z-order) codes for active voxels in a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch.

  • offset (torch.Tensor | NumericMaxRank1 | None) – Coordinate offset before encoding.

Returns:

codes (JaggedTensor) – Morton codes per active voxel.

See also

morton_single()

fvdb.functional.morton_single(grid: Grid, offset: torch.Tensor | NumericMaxRank1 | None = None) → torch.Tensor[source]

Return Morton (Z-order) codes for active voxels in a single grid.

Parameters:
  • grid (Grid) – The single grid.

  • offset (torch.Tensor | NumericMaxRank1 | None) – Coordinate offset before encoding.

Returns:

codes (torch.Tensor) – Morton codes per active voxel.

See also

morton_batch()

fvdb.functional.morton_zyx_batch(grid: GridBatch, offset: torch.Tensor | NumericMaxRank1 | None = None) → JaggedTensor[source]

Return transposed Morton codes (zyx interleaving) for a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch.

  • offset (torch.Tensor | NumericMaxRank1 | None) – Coordinate offset before encoding.

Returns:

codes (JaggedTensor) – Transposed Morton codes per active voxel.

fvdb.functional.morton_zyx_single(grid: Grid, offset: torch.Tensor | NumericMaxRank1 | None = None) → torch.Tensor[source]

Return transposed Morton codes (zyx interleaving) for a single grid.

Parameters:
  • grid (Grid) – The single grid.

  • offset (torch.Tensor | NumericMaxRank1 | None) – Coordinate offset before encoding.

Returns:

codes (torch.Tensor) – Transposed Morton codes per active voxel.

fvdb.functional.hilbert_batch(grid: GridBatch, offset: torch.Tensor | NumericMaxRank1 | None = None) → JaggedTensor[source]

Return Hilbert curve codes for active voxels in a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch.

  • offset (torch.Tensor | NumericMaxRank1 | None) – Coordinate offset before encoding.

Returns:

codes (JaggedTensor) – Hilbert codes per active voxel.

See also

hilbert_single()

fvdb.functional.hilbert_single(grid: Grid, offset: torch.Tensor | NumericMaxRank1 | None = None) → torch.Tensor[source]

Return Hilbert curve codes for active voxels in a single grid.

Parameters:
  • grid (Grid) – The single grid.

  • offset (torch.Tensor | NumericMaxRank1 | None) – Coordinate offset before encoding.

Returns:

codes (torch.Tensor) – Hilbert codes per active voxel.

See also

hilbert_batch()

fvdb.functional.hilbert_zyx_batch(grid: GridBatch, offset: torch.Tensor | NumericMaxRank1 | None = None) → JaggedTensor[source]

Return transposed Hilbert codes (zyx ordering) for a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch.

  • offset (torch.Tensor | NumericMaxRank1 | None) – Coordinate offset before encoding.

Returns:

codes (JaggedTensor) – Transposed Hilbert codes per active voxel.

fvdb.functional.hilbert_zyx_single(grid: Grid, offset: torch.Tensor | NumericMaxRank1 | None = None) → torch.Tensor[source]

Return transposed Hilbert codes (zyx ordering) for a single grid.

Parameters:
  • grid (Grid) – The single grid.

  • offset (torch.Tensor | NumericMaxRank1 | None) – Coordinate offset before encoding.

Returns:

codes (torch.Tensor) – Transposed Hilbert codes per active voxel.

Edge Network

fvdb.functional.edge_network_batch(grid: GridBatch, return_voxel_coordinates: bool = False) → tuple[JaggedTensor, JaggedTensor][source]

Return the edge network of a grid batch.

Parameters:
  • grid (GridBatch) – The grid batch.

  • return_voxel_coordinates (bool) – If True, return voxel coordinates instead of indices.

Returns:
  • sources (JaggedTensor) – Source node indices or coordinates for each edge.

  • targets (JaggedTensor) – Target node indices or coordinates for each edge.

fvdb.functional.edge_network_single(grid: Grid, return_voxel_coordinates: bool = False) → tuple[torch.Tensor, torch.Tensor][source]

Return the edge network of a single grid.

Parameters:
  • grid (Grid) – The single grid.

  • return_voxel_coordinates (bool) – If True, return voxel coordinates instead of indices.

Returns:
  • sources (torch.Tensor) – Source node indices or coordinates for each edge.

  • targets (torch.Tensor) – Target node indices or coordinates for each edge.

Grid Indexing

fvdb.functional.index_grid_batch(grid: GridBatch, index: int) → GridBatch[source]
fvdb.functional.index_grid_batch(grid: GridBatch, index: slice) → GridBatch
fvdb.functional.index_grid_batch(grid: GridBatch, index: list[bool]) → GridBatch
fvdb.functional.index_grid_batch(grid: GridBatch, index: list[int]) → GridBatch
fvdb.functional.index_grid_batch(grid: GridBatch, index: Tensor) → GridBatch

Select a subset of grids from a batch using indexing.

Supports integer indexing, slicing, list indexing, and boolean/integer tensor indexing.

Parameters:
  • grid – The grid batch to index into.

  • index – Index to select grids. Can be: - int: Select a single grid. - slice: Select a range of grids. - list[int] or list[bool]: Select specific grids. - torch.Tensor: Boolean or integer tensor for advanced indexing.

Returns:

A new :class:`~fvdb.GridBatch` containing the selected grids.

Grid Constructors (Batch)

fvdb.functional.gridbatch_from_dense(num_grids: int, dense_dims: NumericMaxRank1, ijk_min: NumericMaxRank1 = 0, voxel_sizes: NumericMaxRank2 = 1, origins: NumericMaxRank2 = 0, mask: torch.Tensor | None = None, device: DeviceIdentifier | None = None) → GridBatch[source]

Create a grid batch of dense grids.

Parameters:
  • num_grids (int) – Number of grids to create.

  • dense_dims (NumericMaxRank1) – Dimensions of the dense grid, broadcastable to (3,).

  • ijk_min (NumericMaxRank1) – Minimum voxel index, broadcastable to (3,).

  • voxel_sizes (NumericMaxRank2) – Voxel size per grid, broadcastable to (num_grids, 3).

  • origins (NumericMaxRank2) – Origin per grid, broadcastable to (num_grids, 3).

  • mask (torch.Tensor | None) – Optional boolean mask (W, H, D) selecting active voxels.

  • device (DeviceIdentifier | None) – Device to create on. Defaults to mask’s device or "cpu".

Returns:

result (GridBatch) – A new grid batch.

fvdb.functional.gridbatch_from_dense_axis_aligned_bounds(num_grids: int, dense_dims: NumericMaxRank1, bounds_min: NumericMaxRank1 = 0, bounds_max: NumericMaxRank1 = 1, voxel_center: bool = False, device: DeviceIdentifier = 'cpu') → GridBatch[source]

Create a grid batch of dense grids defined by axis-aligned world-space bounds.

Parameters:
  • num_grids (int) – Number of grids to create.

  • dense_dims (NumericMaxRank1) – Dimensions of the dense grids, broadcastable to (3,).

  • bounds_min (NumericMaxRank1) – Minimum world-space coordinate, broadcastable to (3,).

  • bounds_max (NumericMaxRank1) – Maximum world-space coordinate, broadcastable to (3,).

  • voxel_center (bool) – Whether bounds correspond to voxel centers (True) or edges (False).

  • device (DeviceIdentifier) – Device to create on. Defaults to "cpu".

Returns:

result (GridBatch) – A new grid batch.

fvdb.functional.gridbatch_from_ijk(ijk: JaggedTensor, voxel_sizes: NumericMaxRank2 = 1, origins: NumericMaxRank2 = 0) → GridBatch[source]

Create a grid batch from voxel-space coordinates.

Parameters:
  • ijk (JaggedTensor) – Per-grid voxel coordinates, shape (B, -1, 3) with integer dtype.

  • voxel_sizes (NumericMaxRank2) – Voxel size per grid, broadcastable to (B, 3).

  • origins (NumericMaxRank2) – Origin per grid, broadcastable to (B, 3).

Returns:

result (GridBatch) – A new grid batch.

See also

grid_from_ijk()

fvdb.functional.gridbatch_from_mesh(mesh_vertices: JaggedTensor, mesh_faces: JaggedTensor, voxel_sizes: NumericMaxRank2 = 1, origins: NumericMaxRank2 = 0) → GridBatch[source]

Create a grid batch by voxelizing triangle mesh surfaces.

Parameters:
  • mesh_vertices (JaggedTensor) – Per-grid vertex positions, shape (B, -1, 3).

  • mesh_faces (JaggedTensor) – Per-grid face indices, shape (B, -1, 3).

  • voxel_sizes (NumericMaxRank2) – Voxel size per grid, broadcastable to (B, 3).

  • origins (NumericMaxRank2) – Origin per grid, broadcastable to (B, 3).

Returns:

result (GridBatch) – A new grid batch.

See also

grid_from_mesh()

fvdb.functional.gridbatch_from_nearest_voxels_to_points(points: JaggedTensor, voxel_sizes: NumericMaxRank2 = 1, origins: NumericMaxRank2 = 0) → GridBatch[source]

Create a grid batch by adding the eight nearest voxels to every input point.

Parameters:
  • points (JaggedTensor) – Per-grid point positions, shape (B, -1, 3).

  • voxel_sizes (NumericMaxRank2) – Voxel size per grid, broadcastable to (B, 3).

  • origins (NumericMaxRank2) – Origin per grid, broadcastable to (B, 3).

Returns:

result (GridBatch) – A new grid batch.

fvdb.functional.gridbatch_from_points(points: JaggedTensor, voxel_sizes: NumericMaxRank2 = 1, origins: NumericMaxRank2 = 0) → GridBatch[source]

Create a grid batch from point clouds.

Parameters:
  • points (JaggedTensor) – Per-grid point positions, shape (B, -1, 3).

  • voxel_sizes (NumericMaxRank2) – Voxel size per grid, broadcastable to (B, 3).

  • origins (NumericMaxRank2) – Origin per grid, broadcastable to (B, 3).

Returns:

result (GridBatch) – A new grid batch.

fvdb.functional.gridbatch_from_zero_grids(device: DeviceIdentifier = 'cpu') → GridBatch[source]

Create a grid batch with zero grids.

Parameters:

device (DeviceIdentifier) – Device to create on. Defaults to "cpu".

Returns:

result (GridBatch) – An empty grid batch with grid_count == 0.

fvdb.functional.gridbatch_from_zero_voxels(device: DeviceIdentifier = 'cpu', voxel_sizes: NumericMaxRank2 = 1, origins: NumericMaxRank2 = 0) → GridBatch[source]

Create a grid batch with one or more zero-voxel grids.

Parameters:
  • device (DeviceIdentifier) – Device to create on. Defaults to "cpu".

  • voxel_sizes (NumericMaxRank2) – Voxel size per grid, broadcastable to (num_grids, 3).

  • origins (NumericMaxRank2) – Origin per grid, broadcastable to (num_grids, 3).

Returns:

result (GridBatch) – A new grid batch with zero-voxel grids.

fvdb.functional.concatenate_grids(grids: Sequence[GridBatch | Grid]) → GridBatch[source]

Concatenate a sequence of grids or grid batches into one.

Parameters:

grids (Sequence[GridBatch | Grid]) – Grids or grid batches to concatenate.

Returns:

result (GridBatch) – A new grid batch containing all grids.

Grid Constructors (Single)

fvdb.functional.grid_from_dense(dense_dims: NumericMaxRank1, ijk_min: NumericMaxRank1 = 0, voxel_size: NumericMaxRank1 = 1, origin: NumericMaxRank1 = 0, mask: torch.Tensor | None = None, device: DeviceIdentifier | None = None) → Grid[source]

Create a single dense grid.

Parameters:
  • dense_dims (NumericMaxRank1) – Dimensions of the dense grid, broadcastable to (3,).

  • ijk_min (NumericMaxRank1) – Minimum voxel index, broadcastable to (3,).

  • voxel_size (NumericMaxRank1) – Voxel size, broadcastable to (3,).

  • origin (NumericMaxRank1) – Origin, broadcastable to (3,).

  • mask (torch.Tensor | None) – Optional boolean mask (W, H, D) selecting active voxels.

  • device (DeviceIdentifier | None) – Device to create on. Defaults to mask’s device or "cpu".

Returns:

result (Grid) – A new single grid.

fvdb.functional.grid_from_dense_axis_aligned_bounds(dense_dims: NumericMaxRank1, bounds_min: NumericMaxRank1 = 0, bounds_max: NumericMaxRank1 = 1, voxel_center: bool = False, device: DeviceIdentifier = 'cpu') → Grid[source]

Create a single dense grid defined by axis-aligned world-space bounds.

Parameters:
  • dense_dims (NumericMaxRank1) – Dimensions of the dense grid, broadcastable to (3,).

  • bounds_min (NumericMaxRank1) – Minimum world-space coordinate, broadcastable to (3,).

  • bounds_max (NumericMaxRank1) – Maximum world-space coordinate, broadcastable to (3,).

  • voxel_center (bool) – Whether bounds correspond to voxel centers (True) or edges (False).

  • device (DeviceIdentifier) – Device to create on. Defaults to "cpu".

Returns:

result (Grid) – A new single grid.

fvdb.functional.grid_from_ijk(ijk: torch.Tensor, voxel_size: NumericMaxRank1 = 1, origin: NumericMaxRank1 = 0) → Grid[source]

Create a single grid from voxel-space coordinates.

Parameters:
  • ijk (torch.Tensor) – Voxel coordinates, shape (N, 3) with integer dtype.

  • voxel_size (NumericMaxRank1) – Voxel size, broadcastable to (3,).

  • origin (NumericMaxRank1) – Origin, broadcastable to (3,).

Returns:

result (Grid) – A new single grid.

fvdb.functional.grid_from_mesh(mesh_vertices: torch.Tensor, mesh_faces: torch.Tensor, voxel_size: NumericMaxRank1 = 1, origin: NumericMaxRank1 = 0) → Grid[source]

Create a single grid by voxelizing a triangle mesh surface.

Parameters:
  • mesh_vertices (torch.Tensor) – Vertex positions, shape (N, 3).

  • mesh_faces (torch.Tensor) – Face indices, shape (F, 3).

  • voxel_size (NumericMaxRank1) – Voxel size, broadcastable to (3,).

  • origin (NumericMaxRank1) – Origin, broadcastable to (3,).

Returns:

result (Grid) – A new single grid.

fvdb.functional.grid_from_nearest_voxels_to_points(points: torch.Tensor, voxel_size: NumericMaxRank1 = 1, origin: NumericMaxRank1 = 0) → Grid[source]

Create a single grid by adding the eight nearest voxels to every input point.

Parameters:
  • points (torch.Tensor) – Point positions, shape (N, 3).

  • voxel_size (NumericMaxRank1) – Voxel size, broadcastable to (3,).

  • origin (NumericMaxRank1) – Origin, broadcastable to (3,).

Returns:

result (Grid) – A new single grid.

fvdb.functional.grid_from_points(points: torch.Tensor, voxel_size: NumericMaxRank1 = 1, origin: NumericMaxRank1 = 0) → Grid[source]

Create a single grid from a point cloud.

Parameters:
  • points (torch.Tensor) – Point positions, shape (N, 3).

  • voxel_size (NumericMaxRank1) – Voxel size, broadcastable to (3,).

  • origin (NumericMaxRank1) – Origin, broadcastable to (3,).

Returns:

result (Grid) – A new single grid.

fvdb.functional.grid_from_zero_voxels(device: DeviceIdentifier = 'cpu', voxel_size: NumericMaxRank1 = 1, origin: NumericMaxRank1 = 0) → Grid[source]

Create a single grid with zero voxels.

Parameters:
  • device (DeviceIdentifier) – Device to create on. Defaults to "cpu".

  • voxel_size (NumericMaxRank1) – Voxel size, broadcastable to (3,).

  • origin (NumericMaxRank1) – Origin, broadcastable to (3,).

Returns:

result (Grid) – A new single grid with zero voxels.

I/O

fvdb.functional.load_nanovdb(path: str, *, device: str | device = 'cpu', verbose: bool = False) → tuple[GridBatch, JaggedTensor, list[str]][source]
fvdb.functional.load_nanovdb(path: str, *, indices: list[int], device: str | device = 'cpu', verbose: bool = False) → tuple[GridBatch, JaggedTensor, list[str]]
fvdb.functional.load_nanovdb(path: str, *, index: int, device: str | device = 'cpu', verbose: bool = False) → tuple[GridBatch, JaggedTensor, list[str]]
fvdb.functional.load_nanovdb(path: str, *, names: list[str], device: str | device = 'cpu', verbose: bool = False) → tuple[GridBatch, JaggedTensor, list[str]]
fvdb.functional.load_nanovdb(path: str, *, name: str, device: str | device = 'cpu', verbose: bool = False) → tuple[GridBatch, JaggedTensor, list[str]]

Load a grid batch from a .nvdb file.

Parameters:
  • path (str) – Path to the .nvdb file.

  • indices (list[int] | None) – Optional list of grid indices to load.

  • index (int | None) – Optional single grid index to load.

  • names (list[str] | None) – Optional list of grid names to load.

  • name (str | None) – Optional single grid name to load.

  • device (DeviceIdentifier) – Device to load onto. Defaults to "cpu".

  • verbose (bool) – Print information about loaded grids.

Returns:
  • grid_batch (GridBatch) – The loaded grid batch.

  • data (JaggedTensor) – Per-voxel data.

  • names (list[str]) – Grid names.

fvdb.functional.load_nanovdb_single(path: str, *, index: int = 0, name: str | None = None, device: DeviceIdentifier = 'cpu', verbose: bool = False) → tuple[Grid, torch.Tensor, str][source]

Load a single grid from a .nvdb file.

Parameters:
  • path (str) – Path to the .nvdb file.

  • index (int) – Grid index to load. Default 0.

  • name (str | None) – Optional grid name to load (overrides index).

  • device (DeviceIdentifier) – Device to load onto. Defaults to "cpu".

  • verbose (bool) – Print information about loaded grids.

Returns:
  • grid (Grid) – The loaded single grid.

  • data (torch.Tensor) – Per-voxel data.

  • name (str) – Grid name.

See also

load_nanovdb()

fvdb.functional.save_nanovdb(grid: GridBatch, path: str, data: JaggedTensor | None = None, names: list[str] | str | None = None, name: str | None = None, compressed: bool = False, verbose: bool = False) → None[source]

Save a grid batch and optional voxel data to a .nvdb file.

Parameters:
  • grid (GridBatch) – The grid batch to save.

  • path (str) – File path (should have .nvdb extension).

  • data (JaggedTensor | None) – Optional voxel data to save with the grids.

  • names (list[str] | str | None) – Names for each grid, or a single name for all.

  • name (str | None) – Single name for all grids (takes precedence over names).

  • compressed (bool) – Use Blosc compression. Default False.

  • verbose (bool) – Print information about saved grids. Default False.

fvdb.functional.save_nanovdb_single(grid: Grid, path: str, data: torch.Tensor | None = None, name: str | None = None, compressed: bool = False, verbose: bool = False) → None[source]

Save a single grid and optional voxel data to a .nvdb file.

Parameters:
  • grid (Grid) – The single grid to save.

  • path (str) – File path (should have .nvdb extension).

  • data (torch.Tensor | None) – Optional voxel data as a plain tensor.

  • name (str | None) – Optional name for the grid.

  • compressed (bool) – Use Blosc compression. Default False.

  • verbose (bool) – Print information about saved grids. Default False.

See also

save_nanovdb()

fvdb.functional.read_nanovdb_metadata(path: str) → list[NanoVDBGridMetadata][source]

Read per-grid metadata from a .nvdb file without loading voxel data.

This is a lightweight way to enumerate which grids are in a file (their names, value types, voxel counts, etc.) before deciding which ones to load. It only reads file headers, so it is much cheaper than load_nanovdb() and works on files containing a mix of grid value types (e.g. a float density grid alongside a Vec3f velocity grid) where the full batch load is not representable as a single JaggedTensor.

Parameters:

path (str) – Path to the .nvdb file.

Returns:
  • list[NanoVDBGridMetadata] – One entry per grid, in file order. Each entry exposes

  • ``name``, ``type`` (e.g. "float", "Vec3f", "OnIndex")

  • (e.g. ``”SDF”``, ``”FOG”``, ``”TENSOR”``, ``”?”``), ``voxel_count``, ``voxel_size``,

  • ``index_bbox_min`` and ``index_bbox_max``.

Example

>>> for m in read_nanovdb_metadata("explosion.nvdb"):
...     print(m.name, m.type, m.voxel_count)
fvdb.functional.grid_names_in_nanovdb(path: str) → list[str][source]

Return the list of grid names stored in a .nvdb file, in file order.

This is a convenience wrapper around read_nanovdb_metadata() that returns just the names.

Parameters:

path (str) – Path to the .nvdb file.

Returns:
  • list[str] – Grid names in the order they appear in the file. Names are not guaranteed to be

  • unique; NanoVDB allows duplicate grid names.

Gaussian Splatting

Flat wrappers over the Gaussian splatting CUDA kernels, one function per kernel entry point. These functions do not build an autograd graph. Forward and backward kernels are exposed separately so that a downstream package can attach its own torch.autograd.Function classes and compose the stages into a differentiable pipeline.

Conventions: C is the number of cameras, N the number of Gaussians and D the feature channel count. Pixel coordinates have their origin at the top-left corner of the image. Sparse variants take pixels_to_render as a JaggedTensor with one [P_c, 2] list of integer (row, col) coordinates per camera. Camera enums are CameraModel and RollingShutterType.

Projection

fvdb.functional.project_gaussians_analytic_fwd(means: Tensor, quats: Tensor, log_scales: Tensor, world_to_cam_matrices: Tensor, projection_matrices: Tensor, image_width: int, image_height: int, eps2d: float, near: float, far: float, min_radius_2d: float, calc_compensations: bool, ortho: bool) → tuple[Tensor, Tensor, Tensor, Tensor, Tensor | None][source]

Project 3D Gaussians to 2D screen space with the analytic (EWA) projection.

Discarded Gaussians (clipped by the near/far planes or smaller than min_radius_2d) have both radii set to zero; their other outputs are left uninitialized.

Parameters:
  • means (torch.Tensor) – Gaussian centers in world space, shape [N, 3].

  • quats (torch.Tensor) – Gaussian rotations as quaternions, shape [N, 4].

  • log_scales (torch.Tensor) – Natural-log scale factors per axis, shape [N, 3].

  • world_to_cam_matrices (torch.Tensor) – World-to-camera transforms, shape [C, 4, 4].

  • projection_matrices (torch.Tensor) – Camera intrinsics, shape [C, 3, 3].

  • image_width (int) – Image width in pixels.

  • image_height (int) – Image height in pixels.

  • eps2d (float) – Blur added to the 2D covariance for numerical stability.

  • near (float) – Near clipping plane distance.

  • far (float) – Far clipping plane distance.

  • min_radius_2d (float) – Gaussians whose projected radius is at most this value are discarded.

  • calc_compensations (bool) – Whether to compute the anti-aliasing compensation factors.

  • ortho (bool) – Use an orthographic projection instead of perspective.

Returns:
  • radii (torch.Tensor) – Per-axis projected radii, shape [C, N, 2], int32.

  • means2d (torch.Tensor) – Projected 2D centers, shape [C, N, 2].

  • depths (torch.Tensor) – View-space depths, shape [C, N].

  • conics (torch.Tensor) – Inverse 2D covariances as (a, b, c), shape [C, N, 3].

  • compensations (torch.Tensor | None) – Compensation factors, shape [C, N], or None when calc_compensations is False.

fvdb.functional.project_gaussians_analytic_bwd(means: Tensor, quats: Tensor, log_scales: Tensor, world_to_cam_matrices: Tensor, projection_matrices: Tensor, compensations: Tensor | None, image_width: int, image_height: int, eps2d: float, radii: Tensor, conics: Tensor, d_loss_d_means2d: Tensor, d_loss_d_depths: Tensor | None, d_loss_d_conics: Tensor, d_loss_d_compensations: Tensor | None, world_to_cam_matrices_requires_grad: bool, ortho: bool, out_normalized_d_loss_d_means2d_norm_accum: Tensor | None = None, out_normalized_max_radii_accum: Tensor | None = None, out_gradient_step_counts: Tensor | None = None) → tuple[Tensor, Tensor | None, Tensor, Tensor, Tensor | None][source]

Backward pass of project_gaussians_analytic_fwd().

The optional out_* accumulators gather per-Gaussian statistics for densification strategies (split, clone, prune). The kernel updates them in place only when both out_normalized_d_loss_d_means2d_norm_accum and out_gradient_step_counts are given; out_normalized_max_radii_accum is updated only alongside those two.

Parameters:
  • means (torch.Tensor) – Gaussian centers, shape [N, 3].

  • quats (torch.Tensor) – Gaussian quaternions, shape [N, 4].

  • log_scales (torch.Tensor) – Natural-log scale factors, shape [N, 3].

  • world_to_cam_matrices (torch.Tensor) – World-to-camera transforms, shape [C, 4, 4].

  • projection_matrices (torch.Tensor) – Camera intrinsics, shape [C, 3, 3].

  • compensations (torch.Tensor | None) – Forward compensation factors, shape [C, N], or None.

  • image_width (int) – Image width in pixels.

  • image_height (int) – Image height in pixels.

  • eps2d (float) – Blur used in the forward pass.

  • radii (torch.Tensor) – Forward radii, shape [C, N, 2].

  • conics (torch.Tensor) – Forward conics, shape [C, N, 3].

  • d_loss_d_means2d (torch.Tensor) – Loss gradient w.r.t. means2d, shape [C, N, 2].

  • d_loss_d_depths (torch.Tensor | None) – Loss gradient w.r.t. depths, shape [C, N]. None contributes zero without allocating or reading a depth-gradient tensor.

  • d_loss_d_conics (torch.Tensor) – Loss gradient w.r.t. conics, shape [C, N, 3].

  • d_loss_d_compensations (torch.Tensor | None) – Loss gradient w.r.t. compensations, shape [C, N], or None.

  • world_to_cam_matrices_requires_grad (bool) – Whether to compute the camera-matrix gradient.

  • ortho (bool) – Whether the forward pass used an orthographic projection.

  • out_normalized_d_loss_d_means2d_norm_accum (torch.Tensor | None) – Optional [N] float accumulator of image-normalized 2D mean gradient norms.

  • out_normalized_max_radii_accum (torch.Tensor | None) – Optional [N] int32 accumulator of the maximum projected radius in pixels.

  • out_gradient_step_counts (torch.Tensor | None) – Optional [N] int32 accumulator of gradient step counts.

Returns:
  • d_loss_d_means (torch.Tensor) – Gradient w.r.t. means, shape [N, 3].

  • d_loss_d_covars (torch.Tensor | None) – Gradient w.r.t. precomputed 3D covariances. None when the covariance is derived from quats and log_scales, which is always the case through this binding.

  • d_loss_d_quats (torch.Tensor) – Gradient w.r.t. quats, shape [N, 4].

  • d_loss_d_log_scales (torch.Tensor) – Gradient w.r.t. log_scales, shape [N, 3].

  • d_loss_d_world_to_cam_matrices (torch.Tensor | None) – Gradient w.r.t. world_to_cam_matrices, shape [C, 4, 4], or None when not requested.

fvdb.functional.project_gaussians_analytic_jagged_fwd(g_sizes: Tensor, means: Tensor, quats: Tensor, scales: Tensor, c_sizes: Tensor, world_to_cam_matrices: Tensor, projection_matrices: Tensor, image_width: int, image_height: int, eps2d: float, near: float, far: float, min_radius_2d: float, ortho: bool) → tuple[Tensor, Tensor, Tensor, Tensor, Tensor | None][source]

Analytic projection for a batch of scenes with varying Gaussian and camera counts.

Scene b owns g_sizes[b] consecutive Gaussians and c_sizes[b] consecutive cameras. Every Gaussian is projected into every camera of its own scene, producing M packed projections in total. Unlike project_gaussians_analytic_fwd(), scales are linear.

Parameters:
  • g_sizes (torch.Tensor) – Gaussians per scene, shape [B].

  • means (torch.Tensor) – Gaussian centers for all scenes, shape [N, 3].

  • quats (torch.Tensor) – Gaussian quaternions, shape [N, 4].

  • scales (torch.Tensor) – Linear scale factors per axis, shape [N, 3].

  • c_sizes (torch.Tensor) – Cameras per scene, shape [B].

  • world_to_cam_matrices (torch.Tensor) – World-to-camera transforms for all scenes, shape [C, 4, 4].

  • projection_matrices (torch.Tensor) – Camera intrinsics for all scenes, shape [C, 3, 3].

  • image_width (int) – Image width in pixels.

  • image_height (int) – Image height in pixels.

  • eps2d (float) – Blur added to the 2D covariance for numerical stability.

  • near (float) – Near clipping plane distance.

  • far (float) – Far clipping plane distance.

  • min_radius_2d (float) – Gaussians whose projected radius is at most this value are discarded.

  • ortho (bool) – Use an orthographic projection instead of perspective.

Returns:
  • radii (torch.Tensor) – Per-axis projected radii, shape [M, 2], int32.

  • means2d (torch.Tensor) – Projected 2D centers, shape [M, 2].

  • depths (torch.Tensor) – View-space depths, shape [M].

  • conics (torch.Tensor) – Inverse 2D covariances as (a, b, c), shape [M, 3].

  • compensations (torch.Tensor | None) – Compensation factors, shape [M], or None.

fvdb.functional.project_gaussians_analytic_jagged_bwd(g_sizes: Tensor, means: Tensor, quats: Tensor, scales: Tensor, c_sizes: Tensor, world_to_cam_matrices: Tensor, projection_matrices: Tensor, image_width: int, image_height: int, eps2d: float, radii: Tensor, conics: Tensor, d_loss_d_means2d: Tensor, d_loss_d_depths: Tensor | None, d_loss_d_conics: Tensor, world_to_cam_matrices_requires_grad: bool, ortho: bool) → tuple[Tensor, Tensor | None, Tensor, Tensor, Tensor | None][source]

Backward pass of project_gaussians_analytic_jagged_fwd().

Parameters:
  • g_sizes (torch.Tensor) – Gaussians per scene, shape [B].

  • means (torch.Tensor) – Gaussian centers, shape [N, 3].

  • quats (torch.Tensor) – Gaussian quaternions, shape [N, 4].

  • scales (torch.Tensor) – Linear scale factors, shape [N, 3].

  • c_sizes (torch.Tensor) – Cameras per scene, shape [B].

  • world_to_cam_matrices (torch.Tensor) – World-to-camera transforms, shape [C, 4, 4].

  • projection_matrices (torch.Tensor) – Camera intrinsics, shape [C, 3, 3].

  • image_width (int) – Image width in pixels.

  • image_height (int) – Image height in pixels.

  • eps2d (float) – Blur used in the forward pass.

  • radii (torch.Tensor) – Forward radii, shape [M, 2].

  • conics (torch.Tensor) – Forward conics, shape [M, 3].

  • d_loss_d_means2d (torch.Tensor) – Loss gradient w.r.t. means2d, shape [M, 2].

  • d_loss_d_depths (torch.Tensor | None) – Loss gradient w.r.t. depths, shape [M]. None contributes zero without allocating or reading a depth-gradient tensor.

  • d_loss_d_conics (torch.Tensor) – Loss gradient w.r.t. conics, shape [M, 3].

  • world_to_cam_matrices_requires_grad (bool) – Whether to compute the camera-matrix gradient.

  • ortho (bool) – Whether the forward pass used an orthographic projection.

Returns:
  • d_loss_d_means (torch.Tensor) – Gradient w.r.t. means, shape [N, 3].

  • d_loss_d_covars (torch.Tensor | None) – Gradient w.r.t. precomputed 3D covariances, None through this binding.

  • d_loss_d_quats (torch.Tensor) – Gradient w.r.t. quats, shape [N, 4].

  • d_loss_d_scales (torch.Tensor) – Gradient w.r.t. scales, shape [N, 3].

  • d_loss_d_world_to_cam_matrices (torch.Tensor | None) – Gradient w.r.t. world_to_cam_matrices, shape [C, 4, 4], or None when not requested.

fvdb.functional.project_gaussians_ut_fwd(means: Tensor, quats: Tensor, log_scales: Tensor, world_to_cam_matrices_start: Tensor, world_to_cam_matrices_end: Tensor, projection_matrices: Tensor, distortion_coeffs: Tensor, camera_model: CameraModel | int, image_width: int, image_height: int, eps2d: float, near: float, far: float, min_radius_2d: float, calc_compensations: bool, rolling_shutter_type: RollingShutterType | int = RollingShutterType.NONE, ut_alpha: float = 0.1, ut_beta: float = 2.0, ut_kappa: float = 0.0, ut_in_image_margin: float = 0.1, ut_require_all_sigma_points_in_image: bool = True) → tuple[Tensor, Tensor, Tensor, Tensor, Tensor | None][source]

Project 3D Gaussians to 2D screen space with the unscented transform (UT).

Each Gaussian is represented by seven sigma points that are pushed through the full camera model, including OpenCV distortion and rolling shutter, and the 2D mean and covariance are rebuilt from the projected points. There is no separate backward kernel; use rasterize_world_space_gaussians_bwd() to differentiate through this path.

Parameters:
  • means (torch.Tensor) – Gaussian centers in world space, shape [N, 3].

  • quats (torch.Tensor) – Gaussian quaternions, shape [N, 4].

  • log_scales (torch.Tensor) – Natural-log scale factors, shape [N, 3].

  • world_to_cam_matrices_start (torch.Tensor) – World-to-camera transforms at the start of the exposure, shape [C, 4, 4].

  • world_to_cam_matrices_end (torch.Tensor) – World-to-camera transforms at the end of the exposure, shape [C, 4, 4]. Equal to the start matrices without rolling shutter.

  • projection_matrices (torch.Tensor) – Camera intrinsics, shape [C, 3, 3].

  • distortion_coeffs (torch.Tensor) – Packed OpenCV distortion coefficients, shape [C, 12], or an empty [C, 0] tensor for PINHOLE and ORTHOGRAPHIC.

  • camera_model (CameraModel | int) – Camera model used for projection.

  • image_width (int) – Image width in pixels.

  • image_height (int) – Image height in pixels.

  • eps2d (float) – Blur added to the 2D covariance for numerical stability.

  • near (float) – Near clipping plane distance.

  • far (float) – Far clipping plane distance.

  • min_radius_2d (float) – Gaussians whose projected radius is at most this value are discarded.

  • calc_compensations (bool) – Whether to compute the anti-aliasing compensation factors.

  • rolling_shutter_type (RollingShutterType | int) – Rolling shutter policy.

  • ut_alpha (float) – UT spread parameter.

  • ut_beta (float) – UT prior-knowledge parameter (2 is optimal for Gaussians).

  • ut_kappa (float) – UT secondary scaling parameter.

  • ut_in_image_margin (float) – Margin, as a fraction of the image size, within which sigma points still count as inside the image.

  • ut_require_all_sigma_points_in_image (bool) – Discard a Gaussian unless every sigma point projects inside the (margin-extended) image.

Returns:
  • radii (torch.Tensor) – Per-axis projected radii, shape [C, N, 2], int32.

  • means2d (torch.Tensor) – Projected 2D centers, shape [C, N, 2].

  • depths (torch.Tensor) – View-space depths, shape [C, N].

  • conics (torch.Tensor) – Inverse 2D covariances as (a, b, c), shape [C, N, 3].

  • compensations (torch.Tensor | None) – Compensation factors, shape [C, N], or None when calc_compensations is False.

Spherical Harmonics

fvdb.functional.evaluate_spherical_harmonics_fwd(sh_degree_to_use: int, num_cameras: int, means: Tensor, world_to_cam_matrices: Tensor, camera_ids: Tensor, gaussian_ids: Tensor, sh0_coeffs: Tensor, sh_n_coeffs: Tensor, radii: Tensor) → Tensor[source]

Evaluate view-dependent spherical harmonics into per-camera, per-Gaussian features.

Dense mode: camera_ids and gaussian_ids are empty, every Gaussian is evaluated for every camera, and coefficients are indexed by Gaussian. Packed mode: num_cameras must be 1 and the inputs describe M work items directly. camera_ids[i] and gaussian_ids[i] select the camera matrix and the mean used for work item i’s view direction, while sh0_coeffs[i], sh_n_coeffs[i] and radii[0, i] are read by work item, so coefficients must already be gathered into work-item order. Work items whose radii are not positive on both axes yield zero features.

Parameters:
  • sh_degree_to_use (int) – Highest SH degree to evaluate, 0 to 3.

  • num_cameras (int) – Number of cameras C in dense mode; must be 1 in packed mode.

  • means (torch.Tensor) – Gaussian centers in world space, shape [N, 3].

  • world_to_cam_matrices (torch.Tensor) – Rigid world-to-camera transforms, shape [C, 4, 4] (any number of matrices in packed mode, indexed by camera_ids).

  • camera_ids (torch.Tensor) – Packed-mode camera matrix index per work item, int32 shape [M], or an empty tensor.

  • gaussian_ids (torch.Tensor) – Packed-mode index into means per work item, int32 shape [M], or an empty tensor.

  • sh0_coeffs (torch.Tensor) – Degree-0 coefficients, shape [N, 1, D] dense or [M, 1, D] packed.

  • sh_n_coeffs (torch.Tensor) – Higher-degree coefficients, shape [N, K-1, D] dense or [M, K-1, D] packed, with K = (sh_degree_to_use + 1)**2, or an empty tensor when sh_degree_to_use == 0.

  • radii (torch.Tensor) – Projected per-axis radii, shape [C, N, 2] dense or [1, M, 2] packed.

Returns:

features (torch.Tensor) – Evaluated features, shape [C, N, D] dense or [1, M, D] packed.

fvdb.functional.evaluate_spherical_harmonics_bwd(sh_degree_to_use: int, num_cameras: int, num_gaussians: int, means: Tensor, world_to_cam_matrices: Tensor, camera_ids: Tensor, gaussian_ids: Tensor, sh_n_coeffs: Tensor, d_loss_d_colors: Tensor, radii: Tensor, compute_d_loss_d_means: bool, compute_d_loss_d_world_to_cam_matrices: bool) → tuple[Tensor, Tensor | None, Tensor | None, Tensor | None][source]

Backward pass of evaluate_spherical_harmonics_fwd().

In packed mode the same work-item layout applies: coefficient gradients come back in work-item order ([M, ...]), while d_loss_d_means and d_loss_d_world_to_cam_matrices are scattered onto the means rows and camera matrices selected by gaussian_ids and camera_ids.

Parameters:
  • sh_degree_to_use (int) – SH degree used in the forward pass.

  • num_cameras (int) – Number of cameras C; 1 in packed mode.

  • num_gaussians (int) – Number of Gaussians N in dense mode, or work items M in packed mode.

  • means (torch.Tensor) – Gaussian centers, shape [N, 3].

  • world_to_cam_matrices (torch.Tensor) – Rigid world-to-camera transforms, shape [C, 4, 4].

  • camera_ids (torch.Tensor) – Packed-mode camera matrix indices, int32 shape [M], or empty.

  • gaussian_ids (torch.Tensor) – Packed-mode indices into means, int32 shape [M], or empty.

  • sh_n_coeffs (torch.Tensor) – Higher-degree coefficients used in the forward pass.

  • d_loss_d_colors (torch.Tensor) – Loss gradient w.r.t. the forward features, shape [C, N, D] dense or [1, M, D] packed.

  • radii (torch.Tensor) – Projected per-axis radii used in the forward pass, shape [C, N, 2] dense or [1, M, 2] packed.

  • compute_d_loss_d_means (bool) – Whether to compute the gradient w.r.t. means.

  • compute_d_loss_d_world_to_cam_matrices (bool) – Whether to compute the gradient w.r.t. world_to_cam_matrices.

Returns:
  • d_loss_d_sh0_coeffs (torch.Tensor) – Gradient w.r.t. the degree-0 coefficients, shape [N, 1, D].

  • d_loss_d_sh_n_coeffs (torch.Tensor | None) – Gradient w.r.t. the higher-degree coefficients, shape [N, K-1, D], or None when sh_degree_to_use == 0.

  • d_loss_d_means (torch.Tensor | None) – Gradient w.r.t. means, shape [N, 3], or None when not requested.

  • d_loss_d_world_to_cam_matrices (torch.Tensor | None) – Gradient w.r.t. the camera matrices, shape [C, 4, 4], or None when not requested.

Tile Intersection

fvdb.functional.intersect_gaussian_tiles(means2d: Tensor, radii: Tensor, depths: Tensor, num_cameras: int, tile_size: int, num_tiles_h: int, num_tiles_w: int, camera_ids: Tensor | None = None, conics: Tensor | None = None, opacities: Tensor | None = None) → tuple[Tensor, Tensor][source]

Bin projected Gaussians into image tiles, sorted by camera, tile and depth.

Inputs may be dense ([C, N, ...]) or packed ([M, ...] with camera_ids). Passing conics and opacities enables a tighter per-tile culling test. The multi-GPU backend requires packed camera_ids to be sorted in nondecreasing order.

Parameters:
  • means2d (torch.Tensor) – Projected 2D centers, shape [C, N, 2] or [M, 2].

  • radii (torch.Tensor) – Per-axis projected radii, shape [C, N, 2] or [M, 2].

  • depths (torch.Tensor) – View-space depths, shape [C, N] or [M].

  • num_cameras (int) – Number of cameras C.

  • tile_size (int) – Tile side length in pixels.

  • num_tiles_h (int) – Number of tiles along the image height.

  • num_tiles_w (int) – Number of tiles along the image width.

  • camera_ids (torch.Tensor | None) – Packed-mode camera index per Gaussian, shape [M].

  • conics (torch.Tensor | None) – Inverse 2D covariances for tighter culling, shape matching means2d.

  • opacities (torch.Tensor | None) – Opacities for tighter culling, shape matching depths.

Returns:
  • tile_offsets (torch.Tensor) – Start index into tile_gaussian_ids per tile, shape [C, num_tiles_h, num_tiles_w].

  • tile_gaussian_ids (torch.Tensor) – Flattened Gaussian index per intersection, shape [n_isects].

fvdb.functional.intersect_gaussian_tiles_sparse(means2d: Tensor, radii: Tensor, depths: Tensor, tile_mask: Tensor, active_tiles: Tensor, num_cameras: int, tile_size: int, num_tiles_h: int, num_tiles_w: int, camera_ids: Tensor | None = None, conics: Tensor | None = None, opacities: Tensor | None = None) → tuple[Tensor, Tensor][source]

Bin projected Gaussians into the active tiles of a sparse pixel set.

tile_mask and active_tiles come from build_sparse_gaussian_tile_layout().

Parameters:
  • means2d (torch.Tensor) – Projected 2D centers, shape [C, N, 2] or [M, 2].

  • radii (torch.Tensor) – Per-axis projected radii, shape [C, N, 2] or [M, 2].

  • depths (torch.Tensor) – View-space depths, shape [C, N] or [M].

  • tile_mask (torch.Tensor) – Boolean mask of active tiles, shape [C, num_tiles_h, num_tiles_w].

  • active_tiles (torch.Tensor) – Flattened indices of the active tiles, shape [AT].

  • num_cameras (int) – Number of cameras C.

  • tile_size (int) – Tile side length in pixels.

  • num_tiles_h (int) – Number of tiles along the image height.

  • num_tiles_w (int) – Number of tiles along the image width.

  • camera_ids (torch.Tensor | None) – Packed-mode camera index per Gaussian, shape [M].

  • conics (torch.Tensor | None) – Inverse 2D covariances for tighter culling.

  • opacities (torch.Tensor | None) – Opacities for tighter culling.

Returns:
  • tile_offsets (torch.Tensor) – Start index into tile_gaussian_ids per active tile, with a trailing end offset, shape [AT + 1].

  • tile_gaussian_ids (torch.Tensor) – Flattened Gaussian index per intersection, shape [n_isects].

fvdb.functional.build_sparse_gaussian_tile_layout(tile_size: int, num_tiles_h: int, num_tiles_w: int, pixels_to_render: JaggedTensor | Tensor, *, image_width: int, image_height: int) → tuple[Tensor, Tensor, Tensor, Tensor, Tensor][source]

Build the tile bookkeeping needed to rasterize an arbitrary set of pixels.

Coordinates must lie inside the image_height by image_width image and each pixel may appear only once per camera; the kernel raises ValueError otherwise. The sparse rasterizers trust the layout and do not check pixel bounds again. Let AT be the number of tiles that contain at least one requested pixel and AP the total pixel count. An empty selection yields AT = 0 outputs of the same dtypes.

Parameters:
  • tile_size (int) – Tile side length in pixels. Must be 16.

  • num_tiles_h (int) – Number of tiles along the image height.

  • num_tiles_w (int) – Number of tiles along the image width.

  • pixels_to_render (JaggedTensor | torch.Tensor) – Integer (row, col) pixel coordinates, one [P_c, 2] list per camera (int32 or int64).

  • image_width (int) – Image width in pixels. Must fit the tile grid, i.e. num_tiles_w == ceil(image_width / tile_size).

  • image_height (int) – Image height in pixels. Must fit the tile grid, i.e. num_tiles_h == ceil(image_height / tile_size).

Returns:
  • active_tiles (torch.Tensor) – Flattened indices of the active tiles, shape [AT].

  • active_tile_mask (torch.Tensor) – Boolean mask of active tiles, shape [C, num_tiles_h, num_tiles_w].

  • tile_pixel_mask (torch.Tensor) – Per-tile uint64 bitmask of requested pixels in raster order, shape [AT, words_per_tile].

  • tile_pixel_cumsum (torch.Tensor) – Inclusive cumulative count of requested pixels per active tile, shape [AT].

  • pixel_map (torch.Tensor) – Output slot for the k-th requested pixel of each active tile, shape [AP].

fvdb.functional.as_pixel_jagged(value: JaggedTensor | Tensor) → JaggedTensor[source]

Normalize a pixels_to_render selection to a JaggedTensor with one [P_c, 2] list per camera.

The sparse tile-layout and rasterization wrappers call this on their input; callers that build their own sparse pipeline (deduplicating pixels first, say) can call it to get the same checks. Only shapes and dtypes are checked here; coordinate bounds and uniqueness are checked by the layout kernel at the synchronization it performs anyway.

Parameters:

value (JaggedTensor | torch.Tensor) – (row, col) integer pixels, either a JaggedTensor with one [P_c, 2] list per camera or a dense [C, P, 2] tensor with C > 0.

Returns:

pixels (JaggedTensor) – The selection as a JaggedTensor. A JaggedTensor input is returned as is.

Raises:
  • TypeError – If value is neither a JaggedTensor nor a Tensor, or its coordinates are not int32 or int64.

  • ValueError – If the shape is not [C, P, 2] (tensor) or [P, 2] per list (JaggedTensor), or a JaggedTensor nests lists (ldim != 1).

Rasterization

fvdb.functional.rasterize_screen_space_gaussians_fwd(means2d: Tensor, conics: Tensor, features: Tensor, opacities: Tensor, image_width: int, image_height: int, image_origin_w: int, image_origin_h: int, tile_size: int, tile_offsets: Tensor, tile_gaussian_ids: Tensor, num_shared_channels_override: int = -1, backgrounds: Tensor | None = None, masks: Tensor | None = None) → tuple[Tensor, Tensor, Tensor][source]

Alpha-blend projected 2D Gaussians into dense images.

Parameters:
  • means2d (torch.Tensor) – Projected 2D centers, shape [C, N, 2].

  • conics (torch.Tensor) – Inverse 2D covariances as (a, b, c), shape [C, N, 3].

  • features (torch.Tensor) – Per-camera, per-Gaussian features to blend, shape [C, N, D].

  • opacities (torch.Tensor) – Per-camera, per-Gaussian opacities, shape [C, N].

  • image_width (int) – Width of the render window in pixels.

  • image_height (int) – Height of the render window in pixels.

  • image_origin_w (int) – Horizontal pixel offset of the render window.

  • image_origin_h (int) – Vertical pixel offset of the render window.

  • tile_size (int) – Tile side length used for tile_offsets.

  • tile_offsets (torch.Tensor) – Per-tile start offsets from intersect_gaussian_tiles().

  • tile_gaussian_ids (torch.Tensor) – Per-intersection Gaussian ids from intersect_gaussian_tiles().

  • num_shared_channels_override (int) – Shared-memory channel count, one of 16, 32 or 64, or -1 to pick automatically.

  • backgrounds (torch.Tensor | None) – Per-camera background features, shape [C, D].

  • masks (torch.Tensor | None) – Per-tile boolean render mask, shape [C, num_tiles_h, num_tiles_w].

Returns:
  • rendered_features (torch.Tensor) – Blended features, shape [C, image_height, image_width, D].

  • rendered_alphas (torch.Tensor) – Accumulated alpha, shape [C, image_height, image_width, 1].

  • last_ids (torch.Tensor) – Tile-relative index of the last blended intersection per pixel, or -1, shape [C, image_height, image_width].

fvdb.functional.rasterize_screen_space_gaussians_bwd(means2d: Tensor, conics: Tensor, features: Tensor, opacities: Tensor, image_width: int, image_height: int, image_origin_w: int, image_origin_h: int, tile_size: int, tile_offsets: Tensor, tile_gaussian_ids: Tensor, rendered_alphas: Tensor, last_ids: Tensor, d_loss_d_rendered_features: Tensor, d_loss_d_rendered_alphas: Tensor, abs_grad: bool, num_shared_channels_override: int = -1, backgrounds: Tensor | None = None, masks: Tensor | None = None) → tuple[Tensor | None, Tensor, Tensor, Tensor, Tensor][source]

Backward pass of rasterize_screen_space_gaussians_fwd().

Parameters:
  • means2d (torch.Tensor) – Projected 2D centers, shape [C, N, 2].

  • conics (torch.Tensor) – Inverse 2D covariances, shape [C, N, 3].

  • features (torch.Tensor) – Per-camera, per-Gaussian features, shape [C, N, D].

  • opacities (torch.Tensor) – Per-camera, per-Gaussian opacities, shape [C, N].

  • image_width (int) – Width of the render window in pixels.

  • image_height (int) – Height of the render window in pixels.

  • image_origin_w (int) – Horizontal pixel offset of the render window.

  • image_origin_h (int) – Vertical pixel offset of the render window.

  • tile_size (int) – Tile side length used for tile_offsets.

  • tile_offsets (torch.Tensor) – Per-tile start offsets used in the forward pass.

  • tile_gaussian_ids (torch.Tensor) – Per-intersection Gaussian ids used in the forward pass.

  • rendered_alphas (torch.Tensor) – Forward alphas, shape [C, image_height, image_width, 1].

  • last_ids (torch.Tensor) – Forward last-intersection indices, shape [C, image_height, image_width].

  • d_loss_d_rendered_features (torch.Tensor) – Loss gradient w.r.t. the rendered features.

  • d_loss_d_rendered_alphas (torch.Tensor) – Loss gradient w.r.t. the rendered alphas.

  • abs_grad (bool) – Also accumulate the absolute value of the 2D mean gradient.

  • num_shared_channels_override (int) – Shared-memory channel count, or -1 for automatic.

  • backgrounds (torch.Tensor | None) – Per-camera background features used in the forward pass.

  • masks (torch.Tensor | None) – Per-tile boolean render mask used in the forward pass.

Returns:
  • d_loss_d_means2d_abs (torch.Tensor | None) – Absolute 2D mean gradient, shape [C, N, 2], or None when abs_grad is False.

  • d_loss_d_means2d (torch.Tensor) – Gradient w.r.t. means2d, shape [C, N, 2].

  • d_loss_d_conics (torch.Tensor) – Gradient w.r.t. conics, shape [C, N, 3].

  • d_loss_d_features (torch.Tensor) – Gradient w.r.t. features, shape [C, N, D].

  • d_loss_d_opacities (torch.Tensor) – Gradient w.r.t. opacities, shape [C, N].

fvdb.functional.rasterize_screen_space_gaussians_sparse_fwd(pixels_to_render: JaggedTensor | Tensor, means2d: Tensor, conics: Tensor, features: Tensor, opacities: Tensor, image_width: int, image_height: int, image_origin_w: int, image_origin_h: int, tile_size: int, tile_offsets: Tensor, tile_gaussian_ids: Tensor, active_tiles: Tensor, tile_pixel_mask: Tensor, tile_pixel_cumsum: Tensor, pixel_map: Tensor, num_shared_channels_override: int = -1, backgrounds: Tensor | None = None, masks: Tensor | None = None) → tuple[JaggedTensor, JaggedTensor, JaggedTensor][source]

Alpha-blend projected 2D Gaussians at an arbitrary set of pixels.

The tile bookkeeping arguments come from build_sparse_gaussian_tile_layout() and the intersections from intersect_gaussian_tiles_sparse(). Outputs are jagged with the same per-camera structure as pixels_to_render.

Parameters:
  • pixels_to_render (JaggedTensor | torch.Tensor) – Integer (row, col) pixel coordinates, one list per camera.

  • means2d (torch.Tensor) – Projected 2D centers, shape [C, N, 2].

  • conics (torch.Tensor) – Inverse 2D covariances, shape [C, N, 3].

  • features (torch.Tensor) – Per-camera, per-Gaussian features, shape [C, N, D].

  • opacities (torch.Tensor) – Per-camera, per-Gaussian opacities, shape [C, N].

  • image_width (int) – Width of the render window in pixels.

  • image_height (int) – Height of the render window in pixels.

  • image_origin_w (int) – Horizontal pixel offset of the render window.

  • image_origin_h (int) – Vertical pixel offset of the render window.

  • tile_size (int) – Tile side length. Must be 16.

  • tile_offsets (torch.Tensor) – Per-tile start offsets from intersect_gaussian_tiles_sparse().

  • tile_gaussian_ids (torch.Tensor) – Per-intersection Gaussian ids from intersect_gaussian_tiles_sparse().

  • active_tiles (torch.Tensor) – Flattened indices of the active tiles, shape [AT].

  • tile_pixel_mask (torch.Tensor) – Per-tile bitmask of requested pixels, shape [AT, words_per_tile].

  • tile_pixel_cumsum (torch.Tensor) – Cumulative requested-pixel count per active tile, shape [AT].

  • pixel_map (torch.Tensor) – Output slot per requested pixel, shape [AP].

  • num_shared_channels_override (int) – Shared-memory channel count, or -1 for automatic.

  • backgrounds (torch.Tensor | None) – Per-camera background features, shape [C, D].

  • masks (torch.Tensor | None) – Per-tile boolean render mask, shape [C, num_tiles_h, num_tiles_w].

Returns:
  • rendered_features (JaggedTensor) – Blended features per requested pixel, element shape [D].

  • rendered_alphas (JaggedTensor) – Accumulated alpha per requested pixel, element shape [1].

  • last_ids (JaggedTensor) – Tile-relative index of the last blended intersection per requested pixel, or -1.

fvdb.functional.rasterize_screen_space_gaussians_sparse_bwd(pixels_to_render: JaggedTensor | Tensor, means2d: Tensor, conics: Tensor, features: Tensor, opacities: Tensor, image_width: int, image_height: int, image_origin_w: int, image_origin_h: int, tile_size: int, tile_offsets: Tensor, tile_gaussian_ids: Tensor, rendered_alphas: JaggedTensor, last_ids: JaggedTensor, d_loss_d_rendered_features: JaggedTensor, d_loss_d_rendered_alphas: JaggedTensor, active_tiles: Tensor, tile_pixel_mask: Tensor, tile_pixel_cumsum: Tensor, pixel_map: Tensor, abs_grad: bool, num_shared_channels_override: int = -1, backgrounds: Tensor | None = None, masks: Tensor | None = None) → tuple[Tensor | None, Tensor, Tensor, Tensor, Tensor][source]

Backward pass of rasterize_screen_space_gaussians_sparse_fwd().

Parameters:
  • pixels_to_render (JaggedTensor | torch.Tensor) – Pixel coordinates used in the forward pass.

  • means2d (torch.Tensor) – Projected 2D centers, shape [C, N, 2].

  • conics (torch.Tensor) – Inverse 2D covariances, shape [C, N, 3].

  • features (torch.Tensor) – Per-camera, per-Gaussian features, shape [C, N, D].

  • opacities (torch.Tensor) – Per-camera, per-Gaussian opacities, shape [C, N].

  • image_width (int) – Width of the render window in pixels.

  • image_height (int) – Height of the render window in pixels.

  • image_origin_w (int) – Horizontal pixel offset of the render window.

  • image_origin_h (int) – Vertical pixel offset of the render window.

  • tile_size (int) – Tile side length. Must be 16.

  • tile_offsets (torch.Tensor) – Per-tile start offsets used in the forward pass.

  • tile_gaussian_ids (torch.Tensor) – Per-intersection Gaussian ids used in the forward pass.

  • rendered_alphas (JaggedTensor) – Forward alphas per requested pixel.

  • last_ids (JaggedTensor) – Forward last-intersection indices per requested pixel.

  • d_loss_d_rendered_features (JaggedTensor) – Loss gradient w.r.t. the rendered features, jagged like pixels_to_render.

  • d_loss_d_rendered_alphas (JaggedTensor) – Loss gradient w.r.t. the rendered alphas, jagged like pixels_to_render.

  • active_tiles (torch.Tensor) – Flattened indices of the active tiles, shape [AT].

  • tile_pixel_mask (torch.Tensor) – Per-tile bitmask of requested pixels.

  • tile_pixel_cumsum (torch.Tensor) – Cumulative requested-pixel count per active tile.

  • pixel_map (torch.Tensor) – Output slot per requested pixel.

  • abs_grad (bool) – Also accumulate the absolute value of the 2D mean gradient.

  • num_shared_channels_override (int) – Shared-memory channel count, or -1 for automatic.

  • backgrounds (torch.Tensor | None) – Per-camera background features used in the forward pass.

  • masks (torch.Tensor | None) – Per-tile boolean render mask used in the forward pass.

Returns:
  • d_loss_d_means2d_abs (torch.Tensor | None) – Absolute 2D mean gradient, shape [C, N, 2], or None when abs_grad is False.

  • d_loss_d_means2d (torch.Tensor) – Gradient w.r.t. means2d, shape [C, N, 2].

  • d_loss_d_conics (torch.Tensor) – Gradient w.r.t. conics, shape [C, N, 3].

  • d_loss_d_features (torch.Tensor) – Gradient w.r.t. features, shape [C, N, D].

  • d_loss_d_opacities (torch.Tensor) – Gradient w.r.t. opacities, shape [C, N].

fvdb.functional.rasterize_world_space_gaussians_fwd(means: Tensor, quats: Tensor, log_scales: Tensor, features: Tensor, opacities: Tensor, world_to_cam_matrices_start: Tensor, world_to_cam_matrices_end: Tensor, projection_matrices: Tensor, distortion_coeffs: Tensor, rolling_shutter_type: RollingShutterType | int, camera_model: CameraModel | int, image_width: int, image_height: int, image_origin_w: int, image_origin_h: int, tile_size: int, tile_offsets: Tensor, tile_gaussian_ids: Tensor, backgrounds: Tensor | None = None, masks: Tensor | None = None) → tuple[Tensor, Tensor, Tensor][source]

Rasterize 3D Gaussians directly by evaluating them along per-pixel rays.

This is the dense rendering path for the unscented-transform pipeline. Tile intersections are still computed from a 2D projection, for example project_gaussians_ut_fwd() followed by intersect_gaussian_tiles().

Parameters:
  • means (torch.Tensor) – Gaussian centers in world space, shape [N, 3].

  • quats (torch.Tensor) – Gaussian quaternions, shape [N, 4].

  • log_scales (torch.Tensor) – Natural-log scale factors, shape [N, 3].

  • features (torch.Tensor) – Per-camera, per-Gaussian features, shape [C, N, D].

  • opacities (torch.Tensor) – Per-camera, per-Gaussian opacities, shape [C, N].

  • world_to_cam_matrices_start (torch.Tensor) – World-to-camera transforms at exposure start, shape [C, 4, 4].

  • world_to_cam_matrices_end (torch.Tensor) – World-to-camera transforms at exposure end, shape [C, 4, 4].

  • projection_matrices (torch.Tensor) – Camera intrinsics, shape [C, 3, 3].

  • distortion_coeffs (torch.Tensor) – Packed OpenCV distortion coefficients, shape [C, 12] or [C, 0].

  • rolling_shutter_type (RollingShutterType | int) – Rolling shutter policy.

  • camera_model (CameraModel | int) – Camera model used for ray generation.

  • image_width (int) – Width of the render window in pixels.

  • image_height (int) – Height of the render window in pixels.

  • image_origin_w (int) – Horizontal pixel offset of the render window.

  • image_origin_h (int) – Vertical pixel offset of the render window.

  • tile_size (int) – Tile side length used for tile_offsets.

  • tile_offsets (torch.Tensor) – Per-tile start offsets from intersect_gaussian_tiles().

  • tile_gaussian_ids (torch.Tensor) – Per-intersection Gaussian ids from intersect_gaussian_tiles().

  • backgrounds (torch.Tensor | None) – Per-camera background features, shape [C, D].

  • masks (torch.Tensor | None) – Per-tile boolean render mask, shape [C, num_tiles_h, num_tiles_w].

Returns:
  • rendered_features (torch.Tensor) – Blended features, shape [C, image_height, image_width, D].

  • rendered_alphas (torch.Tensor) – Accumulated alpha, shape [C, image_height, image_width, 1].

  • last_ids (torch.Tensor) – Tile-relative index of the last blended intersection per pixel, or -1, shape [C, image_height, image_width].

fvdb.functional.rasterize_world_space_gaussians_bwd(means: Tensor, quats: Tensor, log_scales: Tensor, features: Tensor, opacities: Tensor, world_to_cam_matrices_start: Tensor, world_to_cam_matrices_end: Tensor, projection_matrices: Tensor, distortion_coeffs: Tensor, rolling_shutter_type: RollingShutterType | int, camera_model: CameraModel | int, image_width: int, image_height: int, image_origin_w: int, image_origin_h: int, tile_size: int, tile_offsets: Tensor, tile_gaussian_ids: Tensor, rendered_alphas: Tensor, last_ids: Tensor, d_loss_d_rendered_features: Tensor, d_loss_d_rendered_alphas: Tensor, backgrounds: Tensor | None = None, masks: Tensor | None = None) → tuple[Tensor, Tensor, Tensor, Tensor, Tensor][source]

Backward pass of rasterize_world_space_gaussians_fwd().

Parameters:
  • means (torch.Tensor) – Gaussian centers, shape [N, 3].

  • quats (torch.Tensor) – Gaussian quaternions, shape [N, 4].

  • log_scales (torch.Tensor) – Natural-log scale factors, shape [N, 3].

  • features (torch.Tensor) – Per-camera, per-Gaussian features, shape [C, N, D].

  • opacities (torch.Tensor) – Per-camera, per-Gaussian opacities, shape [C, N].

  • world_to_cam_matrices_start (torch.Tensor) – World-to-camera transforms at exposure start, shape [C, 4, 4].

  • world_to_cam_matrices_end (torch.Tensor) – World-to-camera transforms at exposure end, shape [C, 4, 4].

  • projection_matrices (torch.Tensor) – Camera intrinsics, shape [C, 3, 3].

  • distortion_coeffs (torch.Tensor) – Packed OpenCV distortion coefficients, shape [C, 12] or [C, 0].

  • rolling_shutter_type (RollingShutterType | int) – Rolling shutter policy used in the forward pass.

  • camera_model (CameraModel | int) – Camera model used in the forward pass.

  • image_width (int) – Width of the render window in pixels.

  • image_height (int) – Height of the render window in pixels.

  • image_origin_w (int) – Horizontal pixel offset of the render window.

  • image_origin_h (int) – Vertical pixel offset of the render window.

  • tile_size (int) – Tile side length used for tile_offsets.

  • tile_offsets (torch.Tensor) – Per-tile start offsets used in the forward pass.

  • tile_gaussian_ids (torch.Tensor) – Per-intersection Gaussian ids used in the forward pass.

  • rendered_alphas (torch.Tensor) – Forward alphas, shape [C, image_height, image_width, 1].

  • last_ids (torch.Tensor) – Forward last-intersection indices, shape [C, image_height, image_width].

  • d_loss_d_rendered_features (torch.Tensor) – Loss gradient w.r.t. the rendered features.

  • d_loss_d_rendered_alphas (torch.Tensor) – Loss gradient w.r.t. the rendered alphas.

  • backgrounds (torch.Tensor | None) – Per-camera background features used in the forward pass.

  • masks (torch.Tensor | None) – Per-tile boolean render mask used in the forward pass.

Returns:
  • d_loss_d_means (torch.Tensor) – Gradient w.r.t. means, shape [N, 3].

  • d_loss_d_quats (torch.Tensor) – Gradient w.r.t. quats, shape [N, 4].

  • d_loss_d_log_scales (torch.Tensor) – Gradient w.r.t. log_scales, shape [N, 3].

  • d_loss_d_features (torch.Tensor) – Gradient w.r.t. features, shape [C, N, D].

  • d_loss_d_opacities (torch.Tensor) – Gradient w.r.t. opacities, shape [C, N].

Analysis

fvdb.functional.rasterize_num_contributing_gaussians(means2d: Tensor, conics: Tensor, opacities: Tensor, tile_offsets: Tensor, tile_gaussian_ids: Tensor, image_width: int, image_height: int, image_origin_w: int, image_origin_h: int, tile_size: int) → tuple[Tensor, Tensor][source]

Count the Gaussians that contribute non-negligible opacity to each pixel.

Parameters:
  • means2d (torch.Tensor) – Projected 2D centers, shape [C, N, 2].

  • conics (torch.Tensor) – Inverse 2D covariances, shape [C, N, 3].

  • opacities (torch.Tensor) – Per-camera, per-Gaussian opacities, shape [C, N].

  • tile_offsets (torch.Tensor) – Per-tile start offsets from intersect_gaussian_tiles().

  • tile_gaussian_ids (torch.Tensor) – Per-intersection Gaussian ids from intersect_gaussian_tiles().

  • image_width (int) – Width of the render window in pixels.

  • image_height (int) – Height of the render window in pixels.

  • image_origin_w (int) – Horizontal pixel offset of the render window.

  • image_origin_h (int) – Vertical pixel offset of the render window.

  • tile_size (int) – Tile side length used for tile_offsets.

Returns:
  • num_contributing (torch.Tensor) – Contributing Gaussian count per pixel, shape [C, image_height, image_width], int32.

  • alphas (torch.Tensor) – Accumulated alpha per pixel, shape [C, image_height, image_width].

fvdb.functional.rasterize_num_contributing_gaussians_sparse(means2d: Tensor, conics: Tensor, opacities: Tensor, tile_offsets: Tensor, tile_gaussian_ids: Tensor, pixels_to_render: JaggedTensor | Tensor, active_tiles: Tensor, tile_pixel_mask: Tensor, tile_pixel_cumsum: Tensor, pixel_map: Tensor, image_width: int, image_height: int, image_origin_w: int, image_origin_h: int, tile_size: int) → tuple[JaggedTensor, JaggedTensor][source]

Count contributing Gaussians at an arbitrary set of pixels.

Parameters:
  • means2d (torch.Tensor) – Projected 2D centers, shape [C, N, 2].

  • conics (torch.Tensor) – Inverse 2D covariances, shape [C, N, 3].

  • opacities (torch.Tensor) – Per-camera, per-Gaussian opacities, shape [C, N].

  • tile_offsets (torch.Tensor) – Per-tile start offsets from intersect_gaussian_tiles_sparse().

  • tile_gaussian_ids (torch.Tensor) – Per-intersection Gaussian ids from intersect_gaussian_tiles_sparse().

  • pixels_to_render (JaggedTensor | torch.Tensor) – Integer (row, col) pixel coordinates, one list per camera.

  • active_tiles (torch.Tensor) – Flattened indices of the active tiles, shape [AT].

  • tile_pixel_mask (torch.Tensor) – Per-tile bitmask of requested pixels.

  • tile_pixel_cumsum (torch.Tensor) – Cumulative requested-pixel count per active tile.

  • pixel_map (torch.Tensor) – Output slot per requested pixel.

  • image_width (int) – Width of the render window in pixels.

  • image_height (int) – Height of the render window in pixels.

  • image_origin_w (int) – Horizontal pixel offset of the render window.

  • image_origin_h (int) – Vertical pixel offset of the render window.

  • tile_size (int) – Tile side length. Must be 16.

Returns:
  • num_contributing (JaggedTensor) – Contributing Gaussian count per requested pixel, int32.

  • alphas (JaggedTensor) – Accumulated alpha per requested pixel, one scalar per pixel.

fvdb.functional.rasterize_contributing_gaussian_ids(means2d: Tensor, conics: Tensor, opacities: Tensor, tile_offsets: Tensor, tile_gaussian_ids: Tensor, image_width: int, image_height: int, image_origin_w: int, image_origin_h: int, tile_size: int, num_depth_samples: int, num_contributing_gaussians: Tensor | None = None) → tuple[JaggedTensor, JaggedTensor][source]

List the Gaussians that contribute to each pixel, front to back, with their blend weights.

num_depth_samples selects the mode. A positive value records at most that many of the most visible contributors per pixel and ignores num_contributing_gaussians. Zero or a negative value records every contributor and then requires num_contributing_gaussians, the counts from rasterize_num_contributing_gaussians(), to size the output.

Parameters:
  • means2d (torch.Tensor) – Projected 2D centers, shape [C, N, 2].

  • conics (torch.Tensor) – Inverse 2D covariances, shape [C, N, 3].

  • opacities (torch.Tensor) – Per-camera, per-Gaussian opacities, shape [C, N].

  • tile_offsets (torch.Tensor) – Per-tile start offsets from intersect_gaussian_tiles().

  • tile_gaussian_ids (torch.Tensor) – Per-intersection Gaussian ids from intersect_gaussian_tiles().

  • image_width (int) – Width of the render window in pixels.

  • image_height (int) – Height of the render window in pixels.

  • image_origin_w (int) – Horizontal pixel offset of the render window.

  • image_origin_h (int) – Vertical pixel offset of the render window.

  • tile_size (int) – Tile side length used for tile_offsets.

  • num_depth_samples (int) – Top-K mode when positive; all-contributors mode when <= 0.

  • num_contributing_gaussians (torch.Tensor | None) – Per-pixel counts, shape [C, image_height, image_width]. Required in all-contributors mode, ignored otherwise.

Returns:
  • gaussian_ids (JaggedTensor) – Contributing Gaussian indices per pixel, int32.

  • weights (JaggedTensor) – Blend weight of each listed Gaussian.

fvdb.functional.rasterize_contributing_gaussian_ids_sparse(means2d: Tensor, conics: Tensor, opacities: Tensor, tile_offsets: Tensor, tile_gaussian_ids: Tensor, pixels_to_render: JaggedTensor | Tensor, active_tiles: Tensor, tile_pixel_mask: Tensor, tile_pixel_cumsum: Tensor, pixel_map: Tensor, image_width: int, image_height: int, image_origin_w: int, image_origin_h: int, tile_size: int, num_depth_samples: int, num_contributing_gaussians: JaggedTensor | None = None) → tuple[JaggedTensor, JaggedTensor][source]

List contributing Gaussians, with blend weights, at an arbitrary set of pixels.

Mode selection follows rasterize_contributing_gaussian_ids(): a positive num_depth_samples keeps the top-K contributors per pixel, while <= 0 returns every contributor and requires num_contributing_gaussians.

The results nest cameras, then pixels, then contributors (ldim == 2). A selection with no pixels cannot be expressed that way, so an empty layout returns ldim == 1 results with one empty list per camera; fvdb.jcat() will not mix the two forms.

Parameters:
  • means2d (torch.Tensor) – Projected 2D centers, shape [C, N, 2].

  • conics (torch.Tensor) – Inverse 2D covariances, shape [C, N, 3].

  • opacities (torch.Tensor) – Per-camera, per-Gaussian opacities, shape [C, N].

  • tile_offsets (torch.Tensor) – Per-tile start offsets from intersect_gaussian_tiles_sparse().

  • tile_gaussian_ids (torch.Tensor) – Per-intersection Gaussian ids from intersect_gaussian_tiles_sparse().

  • pixels_to_render (JaggedTensor | torch.Tensor) – Integer (row, col) pixel coordinates, one list per camera.

  • active_tiles (torch.Tensor) – Flattened indices of the active tiles, shape [AT].

  • tile_pixel_mask (torch.Tensor) – Per-tile bitmask of requested pixels.

  • tile_pixel_cumsum (torch.Tensor) – Cumulative requested-pixel count per active tile.

  • pixel_map (torch.Tensor) – Output slot per requested pixel.

  • image_width (int) – Width of the render window in pixels.

  • image_height (int) – Height of the render window in pixels.

  • image_origin_w (int) – Horizontal pixel offset of the render window.

  • image_origin_h (int) – Vertical pixel offset of the render window.

  • tile_size (int) – Tile side length. Must be 16.

  • num_depth_samples (int) – Top-K mode when positive; all-contributors mode when <= 0.

  • num_contributing_gaussians (JaggedTensor | None) – Per-pixel counts from rasterize_num_contributing_gaussians_sparse(). Required in all-contributors mode, ignored otherwise.

Returns:
  • gaussian_ids (JaggedTensor) – Contributing Gaussian indices per requested pixel, int32.

  • weights (JaggedTensor) – Blend weight of each listed Gaussian.

fvdb.functional.rasterize_top_contributing_gaussian_ids(means2d: Tensor, conics: Tensor, opacities: Tensor, tile_offsets: Tensor, tile_gaussian_ids: Tensor, image_width: int, image_height: int, image_origin_w: int, image_origin_h: int, tile_size: int, num_depth_samples: int) → tuple[Tensor, Tensor][source]

Record the num_depth_samples most visible Gaussians per pixel with their blend weights.

Slots without a contributor hold id -1 and weight 0.

Parameters:
  • means2d (torch.Tensor) – Projected 2D centers, shape [C, N, 2].

  • conics (torch.Tensor) – Inverse 2D covariances, shape [C, N, 3].

  • opacities (torch.Tensor) – Per-camera, per-Gaussian opacities, shape [C, N].

  • tile_offsets (torch.Tensor) – Per-tile start offsets from intersect_gaussian_tiles().

  • tile_gaussian_ids (torch.Tensor) – Per-intersection Gaussian ids from intersect_gaussian_tiles().

  • image_width (int) – Width of the render window in pixels.

  • image_height (int) – Height of the render window in pixels.

  • image_origin_w (int) – Horizontal pixel offset of the render window.

  • image_origin_h (int) – Vertical pixel offset of the render window.

  • tile_size (int) – Tile side length used for tile_offsets.

  • num_depth_samples (int) – Number of contributors recorded per pixel.

Returns:
  • gaussian_ids (torch.Tensor) – Top contributor indices, shape [C, image_height, image_width, num_depth_samples], int32.

  • weights (torch.Tensor) – Blend weight of each recorded contributor, same shape.

fvdb.functional.rasterize_top_contributing_gaussian_ids_sparse(means2d: Tensor, conics: Tensor, opacities: Tensor, tile_offsets: Tensor, tile_gaussian_ids: Tensor, pixels_to_render: JaggedTensor | Tensor, active_tiles: Tensor, tile_pixel_mask: Tensor, tile_pixel_cumsum: Tensor, pixel_map: Tensor, image_width: int, image_height: int, image_origin_w: int, image_origin_h: int, tile_size: int, num_depth_samples: int) → tuple[JaggedTensor, JaggedTensor][source]

Record the most visible Gaussians, with blend weights, at an arbitrary set of pixels.

Parameters:
  • means2d (torch.Tensor) – Projected 2D centers, shape [C, N, 2].

  • conics (torch.Tensor) – Inverse 2D covariances, shape [C, N, 3].

  • opacities (torch.Tensor) – Per-camera, per-Gaussian opacities, shape [C, N].

  • tile_offsets (torch.Tensor) – Per-tile start offsets from intersect_gaussian_tiles_sparse().

  • tile_gaussian_ids (torch.Tensor) – Per-intersection Gaussian ids from intersect_gaussian_tiles_sparse().

  • pixels_to_render (JaggedTensor | torch.Tensor) – Integer (row, col) pixel coordinates, one list per camera.

  • active_tiles (torch.Tensor) – Flattened indices of the active tiles, shape [AT].

  • tile_pixel_mask (torch.Tensor) – Per-tile bitmask of requested pixels.

  • tile_pixel_cumsum (torch.Tensor) – Cumulative requested-pixel count per active tile.

  • pixel_map (torch.Tensor) – Output slot per requested pixel.

  • image_width (int) – Width of the render window in pixels.

  • image_height (int) – Height of the render window in pixels.

  • image_origin_w (int) – Horizontal pixel offset of the render window.

  • image_origin_h (int) – Vertical pixel offset of the render window.

  • tile_size (int) – Tile side length. Must be 16.

  • num_depth_samples (int) – Number of contributors recorded per pixel.

Returns:
  • gaussian_ids (JaggedTensor) – Top contributor indices per requested pixel, element shape [num_depth_samples], int32.

  • weights (JaggedTensor) – Blend weight of each recorded contributor, same structure.

MCMC Densification

fvdb.functional.mcmc_relocate_gaussians(log_scales: Tensor, logit_opacities: Tensor, ratios: Tensor, binomial_coeffs: Tensor, n_max: int, min_opacity: float) → tuple[Tensor, Tensor][source]

Compute the opacity and scale a Gaussian should take when split into ratios copies.

Implements the relocation rule of MCMC-based densification so that the sum of the copies matches the original Gaussian’s appearance.

Parameters:
  • log_scales (torch.Tensor) – Natural-log scale factors, shape [N, 3].

  • logit_opacities (torch.Tensor) – Logit opacities, shape [N].

  • ratios (torch.Tensor) – Replication count per Gaussian, int32 shape [N].

  • binomial_coeffs (torch.Tensor) – Binomial coefficient table, shape [n_max, n_max].

  • n_max (int) – Largest supported replication count.

  • min_opacity (float) – Lower clamp applied to the relocated opacity.

Returns:
  • logit_opacities_new (torch.Tensor) – Relocated logit opacities, shape [N].

  • log_scales_new (torch.Tensor) – Relocated log scales, shape [N, 3].

fvdb.functional.mcmc_add_noise_to_means(means: Tensor, log_scales: Tensor, logit_opacities: Tensor, quats: Tensor, noise_scale: float, t: float, k: float) → None[source]

Perturb Gaussian centers in place with covariance-shaped noise, damped by opacity.

Parameters:
  • means (torch.Tensor) – Gaussian centers, shape [N, 3], modified in place.

  • log_scales (torch.Tensor) – Natural-log scale factors, shape [N, 3].

  • logit_opacities (torch.Tensor) – Logit opacities, shape [N].

  • quats (torch.Tensor) – Gaussian quaternions, shape [N, 4].

  • noise_scale (float) – Overall noise magnitude.

  • t (float) – Opacity threshold of the damping sigmoid.

  • k (float) – Sharpness of the damping sigmoid.

PLY I/O

fvdb.functional.save_gaussian_ply(filename: str, means: Tensor, quats: Tensor, log_scales: Tensor, logit_opacities: Tensor, sh0: Tensor, shN: Tensor, metadata: Mapping[str, Any] | None = None) → None[source]

Save Gaussian parameters, and optional metadata, to a PLY file.

Parameters:
  • filename (str) – Output path.

  • means (torch.Tensor) – Gaussian centers, shape [N, 3].

  • quats (torch.Tensor) – Gaussian quaternions, shape [N, 4].

  • log_scales (torch.Tensor) – Natural-log scale factors, shape [N, 3].

  • logit_opacities (torch.Tensor) – Logit opacities, shape [N].

  • sh0 (torch.Tensor) – Degree-0 SH coefficients, shape [N, 1, D].

  • shN (torch.Tensor) – Higher-degree SH coefficients, shape [N, K-1, D].

  • metadata (Mapping[str, Any] | None) – Extra key-value pairs to store. Values may be str, int, float or torch.Tensor.

fvdb.functional.load_gaussian_ply(filename: str, device: device | str = 'cpu') → tuple[Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, dict[str, Any]][source]

Load Gaussian parameters, and any stored metadata, from a PLY file.

Parameters:
  • filename (str) – Path of the PLY file.

  • device (torch.device | str) – Device the loaded tensors are moved to.

Returns:
  • means (torch.Tensor) – Gaussian centers, shape [N, 3].

  • quats (torch.Tensor) – Gaussian quaternions, shape [N, 4].

  • log_scales (torch.Tensor) – Natural-log scale factors, shape [N, 3].

  • logit_opacities (torch.Tensor) – Logit opacities, shape [N].

  • sh0 (torch.Tensor) – Degree-0 SH coefficients, shape [N, 1, D].

  • shN (torch.Tensor) – Higher-degree SH coefficients, shape [N, K-1, D].

  • metadata (dict[str, Any]) – Stored metadata, empty if the file has none.