Lidar_AI_Solution icon indicating copy to clipboard operation
Lidar_AI_Solution copied to clipboard

SparseConv2d and SubMConv2d support

Open HuangVictorAuto opened this issue 1 year ago • 9 comments

Hi, thanks for the great work.

I have used some spconv 2d layers in my network. I read your code, I see that the 3D versions are all converted to 'SparseConvolution' onnx node and will be parsed and used in spconv engine during inference. I wonder if the engine or libspconv also compatialbe with the sparse 2D versions? I can also convert the 2d versions to 'SparseConvolution' onnx node?

thanks!

HuangVictorAuto avatar Jul 12 '23 08:07 HuangVictorAuto

The 2d SPCONV is a specific form of 3d SPCONV. You just set z to 1 at indices which can achieve the 2d SPCONV.

hopef avatar Jul 12 '23 14:07 hopef

Thanks for the reply. I will covert some parameters of SPCONV2D to suit the 'SparseConvlution' parameters.

HuangVictorAuto avatar Jul 13 '23 01:07 HuangVictorAuto

@HuangVictorAuto Hi! can you explain how did you convert it if you already did? thanks!

AhmedNasr7 avatar Sep 12 '23 01:09 AhmedNasr7

@AhmedNasr7 , just as above mentioned, 2d sparsconv is just a special case for 3d sparseconv, just set z dimension to 1. you can update your pytorch network from 2d to 3d first, and then do the onnx export.

HuangVictorAuto avatar Sep 12 '23 02:09 HuangVictorAuto

I guess this requires re-training the network, no out of the box solutions for pretrained models?

AhmedNasr7 avatar Sep 12 '23 06:09 AhmedNasr7

I manage to load a pretrained model, update the 2d spconvs to 3d spconv weights and bias accordingly to suit the libspconv 'sparseconvlution'.

HuangVictorAuto avatar Sep 13 '23 05:09 HuangVictorAuto

@hopef , I manage to convert the 2d sparseconv/submanifold to 3d, by two methods, update the weights and shapes during the onnx node create stage. And I also update the pytorch model from 2d to 3d and then covert to onnx.

But both method, I found that the result of sparseconv2d is aligned between pytorch and engine. But the result from submanifold 2d is not aligned. Have you test the libspconv submanifold3d (with special case z=1 ) situation?

following is my onnx, I checked node 1 output, result is ok. node 2 output, result is not OK. image

HuangVictorAuto avatar Sep 14 '23 09:09 HuangVictorAuto

@HuangVictorAuto could you give me a reproduce data? For example a simple pytorch code and a simple input data(features, indices, grid_size).

hopef avatar Oct 19 '23 02:10 hopef

Hi, attached file is a short sample for subm2d network. please check it. I found big difference between the pytorch and engine result, just for 1 subm2d node. could you please help check whether there is bug during my 2d sparse submanifold to 3d sparse submanifold or there is some bug inside the engine? Thanks! subm2d.zip

HuangVictorAuto avatar Oct 25 '23 07:10 HuangVictorAuto