Point/voxel backend routes¶
Point/voxel utilities convert continuous point rows to sparse voxel tensors and back. They are backed by native CPU and Metal primitives because the expensive work is coordinate hashing, stable compaction, scatter/gather, and interpolation map construction.
Quantization¶
For point \(p=(p_x,p_y,p_z)\), origin \(o\), and voxel size \(s\), voxel coordinates are:
The native quantization primitive returns:
Output |
Meaning |
|---|---|
|
Unique batched voxel coordinates. |
|
Lazy scalar row count for the voxel coordinate buffer. |
|
Point-row to voxel-row map. |
|
Number of points assigned to each voxel. |
Metal quantization uses an integer coordinate hash table, stable compaction, and a final point-to-voxel map pass. CPU quantization uses the same semantic contract with host data structures.
Voxel feature aggregation¶
voxelize_features supports sum and mean reductions. For voxel row
\(v\) and point set \(P_v\):
The Metal route clears the output feature matrix and scatters point contributions into voxel rows. The gradient route gathers the voxel cotangent back to contributing point rows with the same reduction scale.
Point-to-voxel maps¶
build_point_voxel_map supports nearest and linear interpolation. The map
contains voxel row ids and interpolation weights for each point. Devoxelization
then computes:
where \(r_{p,j}\) is a voxel row id and \(\alpha_{p,j}\) is its interpolation weight.
Operation |
Native work |
Dtype boundary |
|---|---|---|
|
Quantize points, hash unique voxels, compact active rows |
|
|
Quantize + feature scatter |
|
|
Hash voxel coordinates and lookup interpolation stencil |
|
|
Weighted gather from voxel features to point rows |
|
Batch handling¶
Batch ids are part of the voxel coordinate key. Two points with the same
spatial voxel and different batch ids map to different voxel rows. Passing
batch_indices is therefore required whenever a point array contains more
than one sample.
Backend thresholds¶
Coordinate set operations use a compact/scatter split on Metal. Large selected sets use stable parallel compaction; small sets use a single compact kernel. The threshold is defined in the native coordinate runtime detail and applies to set-style operations such as downsample, union, intersection, and quantization planning. This keeps public semantics deterministic while allowing the backend to choose the cheaper compaction mechanism for the row count.