traveller59 / spconv

Spatial Sparse Convolution Library
Apache License 2.0
1.89k stars 366 forks source link

[How to] 3D Convs with batch size = 1, Inverse 3D Convs with batch size = N #711

Open simo23 opened 4 months ago

simo23 commented 4 months ago

Hi,

I have a script that does:

  1. Feature extraction of a pointcloud using an spconv-based UNet
  2. Downsamples the features using a series of 3D convolutions
  3. Converts the spconv tensor into a torch tensor
  4. Replicates the tensor N times (simulating batch size = N)
  5. Updates the N-replicated tensor with other torch modules
  6. Converts the N-replicated tensor into spconv tensor
  7. Upsamples the updated N-replicated tensor to original resolution with a series of inverse convolutions (inverse of step 2)

I have the same indices in step 2 and 7, the difference is that in step 7 they are replicated N times. Now spconv throws an error and does not allow to do this in a naive way. I also tried to replicate the internal ImplicitGemmIndiceData used by the convolution without luck, by replicating the indices and setting the proper batch idx.

A workaround is to do a for loop over the N elements but its not optimal. Is there a nice way to do it?

Thank you