I have a (B, N, 3) pointsets and (B, N, 1) pointwise features which I wish to voxelize. The goal of this voxelisation is to be able to query from the voxel, (approximated) feature at any given point with minimal computation time. For example, given a new point and I wish to compute its feature, with a voxel representation, I can interpolate from neighbouring nodes of the given point, which is easy to compute knowing the edge information. Alternatively, I can use KNN , but when N is large (typically 1million), this operation is quite slow.

I can construct my voxels from pointset using torch.histogram, but how can I fill those voxels with my features instead of binary values? I can possibly use the weights option in torch.histogram however, my point-wise features contain negative values while I can imagine the histogram weights to be positive. Can someone please help me out?

Depending on the numbers B, N, and the size of the voxel grid here, one option might be to do kernel regression. This is quite computationally intensive during voxelization, but in contrast to binning like histograms do, does interpolation, too.

A blunt way to mimic what a histogram does is to quantize the coordinates into integers starting from 0 and then use them as the indices of a sparse tensor. These are allowed to have duplicate indices. Then tensor.coalesce() will sum all values at a given coordinate.

Of course, there so many ways to do this, but these are the ones I’d try first.

A blunt way to mimic what a histogram does is to quantize the coordinates into integers starting from 0 and then use them as the indices of a sparse tensor. These are allowed to have duplicate indices. Then tensor.coalesce() will sum all values at a given coordinate.

Could you please elaborate on the quantizing part? If suppose my batched point cloud A = torch.randn((32, 10000, 3)) is quantized to a variable B (an integer) such that B.shape == (32, 10000, 3) with each value pointing to a place where corresponding point in A falls into the grid of shape (64,64,64) that would be excellent for my usecase.

With those indices, I can then do scatter_mean over my feature tensor.

So if you just scale your coordinates to fall into the range 0 <= x_i < 64 and take int, it should work…
I’m not sure whether scatter_mean supports multidimensional indices, so you might then multiply x_0 * (64 * 64) + x_1 * 64 + x_2 and to get a 64**3 tensor from scatter_mean that you can then view as a 64, 64, 64 tensor.