masszhou / spconv_lite

sparse convolution lib. derived from spconv
Apache License 2.0
53 stars 11 forks source link

Update

I wrote a article to explain how sparse convolution works with detail.

1. Introduction

Implementation of sparse convolution is quite different from traditional dense convolution in GPU level.

this project is a lightweight version of spconv project by Yan Yan

The work in this repository is mainly involved with following papers:

I made following major changes:

Github do not support math rendering, this document can be rendered by e.g. MathJax.

this library has been used in my repo second_lite

My results

2. Build

dependencies for usage

build with cmake

python setup.py bdist_wheel

build with docker container

pull the builder container

docker pull masszhou/toolchains:dev-spconv-lite-1.0

to build spconv_lite, under the root path of this project {spconv_lite_root}/ run

docker build -t masszhou/spconv_lite:1.0 -f docker/build_spconv_lite.Dockerfile .

start a container by

docker run -d masszhou/spconv_lite:1.0

copy pip package to host, then install package in your virtualenv

docker cp <CONTAINER_ID>:/root/spconv_lite/dist/spconv_lite-1.0.0-cp38-cp38-linux_x86_64.whl .
pip install spconv_lite-1.0.0-cp38-cp38-linux_x86_64.whl

shutdown container

docker stop <CONTAINER_ID>

run unittest under {spconv_lite_root}/unittest

python -m test.test_all

3. My understanding about sparse convolution

3.1 input

here we asumme the input siginal is 2D with channel=3, like a image. 2D signal is easier to draw the tensor. There is no essential difference for the convolution between 2D and 3D signals.

consider a image similar signal, which contains only sparse data. P1, P2 are data points. other cells are zeros.

3.2 convolution

notation:

3.3 output and active sites

notation:

as we can see from the figure. the output is also sparse. there are two kinds of definitions, which proposed by 3D Semantic Segmentation with Submanifold Sparse Convolutional Networks

In the program, we can choose either of these definitions, depends on the application.

3.4 build hash-table

3.5 build rulebook

3.6 Sparse Convolution

4. ToDos

Author

License

The project is derived from spconv

The spconv code is licensed under Apache-2.0 License The CUDPP hash code is licensed under BSD License. The robin-map code is licensed under MIT license.

Besides, if you want directly use any of the figures for algorithm explanation, which were my original works and could be used in my future publications, so please cite this repo for these figures.

Thanks