Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
one
spconv
Commits
20557e83
Commit
20557e83
authored
Jan 26, 2019
by
traveller59
Browse files
1. add cuda kernel error check
2. update install command
parent
a09b086a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
2 deletions
+22
-2
README.md
README.md
+4
-2
src/spconv/indice.cu
src/spconv/indice.cu
+7
-0
src/spconv/maxpool.cu
src/spconv/maxpool.cu
+6
-0
src/spconv/reordering.cu
src/spconv/reordering.cu
+5
-0
No files found.
README.md
View file @
20557e83
...
@@ -16,7 +16,9 @@ This project only support CUDA 9.0+. If you are using cuda 8.0, please update it
...
@@ -16,7 +16,9 @@ This project only support CUDA 9.0+. If you are using cuda 8.0, please update it
2.
Download cmake >= 3.13.2, then add cmake executables to PATH.
2.
Download cmake >= 3.13.2, then add cmake executables to PATH.
3.
Ensure you have install pytorch 1.0 in your environment, run
```python setup.py install```
.
3.
Ensure you have install pytorch 1.0 in your environment, run
```python setup.py bdist_wheel```
(don't use
```python setup.py install```
).
4.
Run
```cd ./dist```
, use pip to install generated whl file.
## Compare with SparseConvNet
## Compare with SparseConvNet
...
@@ -40,7 +42,7 @@ indices = # your indices/coordinates with shape [N, ndim + 1], batch index must
...
@@ -40,7 +42,7 @@ indices = # your indices/coordinates with shape [N, ndim + 1], batch index must
spatial_shape = # spatial shape of your sparse tensor.
spatial_shape = # spatial shape of your sparse tensor.
batch_size = # batch size of your sparse tensor.
batch_size = # batch size of your sparse tensor.
x = spconv.SparseConvTensor(features, indices, spatial_shape, batch_size)
x = spconv.SparseConvTensor(features, indices, spatial_shape, batch_size)
x_dense_NHW
C
= x.dense() # convert sparse tensor to dense NCHW tensor.
x_dense_N
C
HW = x.dense() # convert sparse tensor to dense NCHW tensor.
print(x.sparity) # helper function to check sparity.
print(x.sparity) # helper function to check sparity.
```
```
...
...
src/spconv/indice.cu
View file @
20557e83
...
@@ -56,6 +56,7 @@ struct CreateConvIndicePairFunctorP1<tv::GPU, Index, IndexGrid, NDim> {
...
@@ -56,6 +56,7 @@ struct CreateConvIndicePairFunctorP1<tv::GPU, Index, IndexGrid, NDim> {
d
.
stream
()
>>>
(
indicesIn
,
indicesOut
,
gridsOut
,
indicePairs
,
d
.
stream
()
>>>
(
indicesIn
,
indicesOut
,
gridsOut
,
indicePairs
,
indiceNum
,
indicePairUnique
,
kernelSize
,
stride
,
indiceNum
,
indicePairUnique
,
kernelSize
,
stride
,
padding
,
dilation
,
outSpatialShape
);
padding
,
dilation
,
outSpatialShape
);
TV_CHECK_CUDA_ERR
();
// std::cout << "p1 gene time " << timer.report() / 1000.0 << std::endl;
// std::cout << "p1 gene time " << timer.report() / 1000.0 << std::endl;
return
1
;
return
1
;
}
}
...
@@ -81,14 +82,17 @@ struct CreateConvIndicePairFunctorP2<tv::GPU, Index, IndexGrid, NDim> {
...
@@ -81,14 +82,17 @@ struct CreateConvIndicePairFunctorP2<tv::GPU, Index, IndexGrid, NDim> {
<<<
tv
::
launch
::
getBlocks
(
numAct
),
tv
::
launch
::
CUDA_NUM_THREADS
,
0
,
<<<
tv
::
launch
::
getBlocks
(
numAct
),
tv
::
launch
::
CUDA_NUM_THREADS
,
0
,
d
.
stream
()
>>>
(
indicesOut
,
gridsOut
,
numAct
,
indicePairs
,
d
.
stream
()
>>>
(
indicesOut
,
gridsOut
,
numAct
,
indicePairs
,
indicePairUnique
,
outSpatialShape
,
batchSize
);
indicePairUnique
,
outSpatialShape
,
batchSize
);
TV_CHECK_CUDA_ERR
();
assignIndicePairsKernel
<
Index
,
IndexGrid
,
NDim
>
assignIndicePairsKernel
<
Index
,
IndexGrid
,
NDim
>
<<<
tv
::
launch
::
getBlocks
(
numActIn
),
tv
::
launch
::
CUDA_NUM_THREADS
,
0
,
<<<
tv
::
launch
::
getBlocks
(
numActIn
),
tv
::
launch
::
CUDA_NUM_THREADS
,
0
,
d
.
stream
()
>>>
(
indicesOut
,
gridsOut
,
numActIn
,
indicePairs
,
d
.
stream
()
>>>
(
indicesOut
,
gridsOut
,
numActIn
,
indicePairs
,
indicePairUnique
,
outSpatialShape
);
indicePairUnique
,
outSpatialShape
);
TV_CHECK_CUDA_ERR
();
if
(
resetGrid
)
{
if
(
resetGrid
)
{
resetGridKernel
<
Index
,
IndexGrid
,
NDim
>
resetGridKernel
<
Index
,
IndexGrid
,
NDim
>
<<<
tv
::
launch
::
getBlocks
(
numAct
),
tv
::
launch
::
CUDA_NUM_THREADS
,
0
,
<<<
tv
::
launch
::
getBlocks
(
numAct
),
tv
::
launch
::
CUDA_NUM_THREADS
,
0
,
d
.
stream
()
>>>
(
indicePairUnique
.
data
(),
gridsOut
,
numAct
);
d
.
stream
()
>>>
(
indicePairUnique
.
data
(),
gridsOut
,
numAct
);
TV_CHECK_CUDA_ERR
();
}
}
return
numAct
;
return
numAct
;
}
}
...
@@ -113,15 +117,18 @@ struct CreateSubMIndicePairFunctor<tv::GPU, Index, IndexGrid, NDim> {
...
@@ -113,15 +117,18 @@ struct CreateSubMIndicePairFunctor<tv::GPU, Index, IndexGrid, NDim> {
prepareSubMGridKernel
<
Index
,
IndexGrid
,
NDim
>
prepareSubMGridKernel
<
Index
,
IndexGrid
,
NDim
>
<<<
tv
::
launch
::
getBlocks
(
numActIn
),
tv
::
launch
::
CUDA_NUM_THREADS
,
0
,
<<<
tv
::
launch
::
getBlocks
(
numActIn
),
tv
::
launch
::
CUDA_NUM_THREADS
,
0
,
d
.
stream
()
>>>
(
indicesIn
,
gridsOut
,
outSpatialShape
);
d
.
stream
()
>>>
(
indicesIn
,
gridsOut
,
outSpatialShape
);
TV_CHECK_CUDA_ERR
();
getSubMIndicePairsKernel
<
Index
,
IndexGrid
,
NDim
>
getSubMIndicePairsKernel
<
Index
,
IndexGrid
,
NDim
>
<<<
tv
::
launch
::
getBlocks
(
numActIn
),
tv
::
launch
::
CUDA_NUM_THREADS
,
0
,
<<<
tv
::
launch
::
getBlocks
(
numActIn
),
tv
::
launch
::
CUDA_NUM_THREADS
,
0
,
d
.
stream
()
>>>
(
indicesIn
,
gridsOut
,
indicePairs
,
indiceNum
,
d
.
stream
()
>>>
(
indicesIn
,
gridsOut
,
indicePairs
,
indiceNum
,
kernelSize
,
stride
,
padding
,
dilation
,
outSpatialShape
);
kernelSize
,
stride
,
padding
,
dilation
,
outSpatialShape
);
TV_CHECK_CUDA_ERR
();
// std::cout << "subm gene time " << timer.report() / 1000.0 << std::endl;
// std::cout << "subm gene time " << timer.report() / 1000.0 << std::endl;
if
(
resetGrid
)
{
if
(
resetGrid
)
{
resetGridSubMKernel
<
Index
,
IndexGrid
,
NDim
>
resetGridSubMKernel
<
Index
,
IndexGrid
,
NDim
>
<<<
tv
::
launch
::
getBlocks
(
numActIn
),
tv
::
launch
::
CUDA_NUM_THREADS
,
0
,
<<<
tv
::
launch
::
getBlocks
(
numActIn
),
tv
::
launch
::
CUDA_NUM_THREADS
,
0
,
d
.
stream
()
>>>
(
indicesIn
.
data
(),
gridsOut
,
outSpatialShape
,
numActIn
);
d
.
stream
()
>>>
(
indicesIn
.
data
(),
gridsOut
,
outSpatialShape
,
numActIn
);
TV_CHECK_CUDA_ERR
();
}
}
return
numActIn
;
return
numActIn
;
}
}
...
...
src/spconv/maxpool.cu
View file @
20557e83
...
@@ -343,6 +343,7 @@ struct SparseMaxPoolForwardFunctor<tv::GPU, T, Index> {
...
@@ -343,6 +343,7 @@ struct SparseMaxPoolForwardFunctor<tv::GPU, T, Index> {
indices
.
subview
(
0
).
data
()
+
numHotBlock
,
indices
.
subview
(
0
).
data
()
+
numHotBlock
,
indices
.
subview
(
1
).
data
()
+
numHotBlock
,
indices
.
subview
(
1
).
data
()
+
numHotBlock
,
size
-
numHotBlock
,
numPlanes
);
size
-
numHotBlock
,
numPlanes
);
TV_CHECK_CUDA_ERR
();
}
}
notFound
=
false
;
notFound
=
false
;
}
}
...
@@ -360,6 +361,7 @@ struct SparseMaxPoolForwardFunctor<tv::GPU, T, Index> {
...
@@ -360,6 +361,7 @@ struct SparseMaxPoolForwardFunctor<tv::GPU, T, Index> {
outFeatures
.
data
(),
inFeatures
.
data
(),
outFeatures
.
data
(),
inFeatures
.
data
(),
indices
.
subview
(
0
).
data
(),
indices
.
subview
(
1
).
data
(),
indices
.
subview
(
0
).
data
(),
indices
.
subview
(
1
).
data
(),
numHotBlock
,
numPlanes
);
numHotBlock
,
numPlanes
);
TV_CHECK_CUDA_ERR
();
}
}
if
(
size
>
numHotBlock
)
{
if
(
size
>
numHotBlock
)
{
...
@@ -370,6 +372,7 @@ struct SparseMaxPoolForwardFunctor<tv::GPU, T, Index> {
...
@@ -370,6 +372,7 @@ struct SparseMaxPoolForwardFunctor<tv::GPU, T, Index> {
indices
.
subview
(
0
).
data
()
+
numHotBlock
,
indices
.
subview
(
0
).
data
()
+
numHotBlock
,
indices
.
subview
(
1
).
data
()
+
numHotBlock
,
size
-
numHotBlock
,
indices
.
subview
(
1
).
data
()
+
numHotBlock
,
size
-
numHotBlock
,
numPlanes
);
numPlanes
);
TV_CHECK_CUDA_ERR
();
}
}
}
}
}
}
...
@@ -416,6 +419,7 @@ struct SparseMaxPoolBackwardFunctor<tv::GPU, T, Index> {
...
@@ -416,6 +419,7 @@ struct SparseMaxPoolBackwardFunctor<tv::GPU, T, Index> {
indices
.
subview
(
0
).
data
()
+
numHotBlock
,
indices
.
subview
(
0
).
data
()
+
numHotBlock
,
indices
.
subview
(
1
).
data
()
+
numHotBlock
,
indices
.
subview
(
1
).
data
()
+
numHotBlock
,
size
-
numHotBlock
,
numPlanes
);
size
-
numHotBlock
,
numPlanes
);
TV_CHECK_CUDA_ERR
();
}
}
notFound
=
false
;
notFound
=
false
;
}
}
...
@@ -433,6 +437,7 @@ struct SparseMaxPoolBackwardFunctor<tv::GPU, T, Index> {
...
@@ -433,6 +437,7 @@ struct SparseMaxPoolBackwardFunctor<tv::GPU, T, Index> {
outFeatures
.
data
(),
inFeatures
.
data
(),
dout
.
data
(),
din
.
data
(),
outFeatures
.
data
(),
inFeatures
.
data
(),
dout
.
data
(),
din
.
data
(),
indices
.
subview
(
0
).
data
(),
indices
.
subview
(
1
).
data
(),
indices
.
subview
(
0
).
data
(),
indices
.
subview
(
1
).
data
(),
numHotBlock
,
numPlanes
);
numHotBlock
,
numPlanes
);
TV_CHECK_CUDA_ERR
();
}
}
if
(
size
>
numHotBlock
)
{
if
(
size
>
numHotBlock
)
{
...
@@ -443,6 +448,7 @@ struct SparseMaxPoolBackwardFunctor<tv::GPU, T, Index> {
...
@@ -443,6 +448,7 @@ struct SparseMaxPoolBackwardFunctor<tv::GPU, T, Index> {
indices
.
subview
(
0
).
data
()
+
numHotBlock
,
indices
.
subview
(
0
).
data
()
+
numHotBlock
,
indices
.
subview
(
1
).
data
()
+
numHotBlock
,
size
-
numHotBlock
,
indices
.
subview
(
1
).
data
()
+
numHotBlock
,
size
-
numHotBlock
,
numPlanes
);
numPlanes
);
TV_CHECK_CUDA_ERR
();
}
}
}
}
}
}
...
...
src/spconv/reordering.cu
View file @
20557e83
...
@@ -62,6 +62,7 @@ struct SparseGatherFunctor<tv::GPU, T, Index> {
...
@@ -62,6 +62,7 @@ struct SparseGatherFunctor<tv::GPU, T, Index> {
d
.
stream
()
>>>
(
buffer
.
data
()
+
nHotBlock
*
numPlanes
,
d
.
stream
()
>>>
(
buffer
.
data
()
+
nHotBlock
*
numPlanes
,
features
.
data
(),
indices
.
data
()
+
nHotBlock
,
features
.
data
(),
indices
.
data
()
+
nHotBlock
,
size
-
nHotBlock
,
numPlanes
/
vecloadFactor
);
size
-
nHotBlock
,
numPlanes
/
vecloadFactor
);
TV_CHECK_CUDA_ERR
();
}
}
notFound
=
false
;
notFound
=
false
;
}
}
...
@@ -76,6 +77,7 @@ struct SparseGatherFunctor<tv::GPU, T, Index> {
...
@@ -76,6 +77,7 @@ struct SparseGatherFunctor<tv::GPU, T, Index> {
tv
::
launch
::
DivUp
(
numPlanes
,
NumTLP
)),
tv
::
launch
::
DivUp
(
numPlanes
,
NumTLP
)),
dim3
(
NumTLP
/
NumILP
,
NumTLP
),
0
,
d
.
stream
()
>>>
(
dim3
(
NumTLP
/
NumILP
,
NumTLP
),
0
,
d
.
stream
()
>>>
(
buffer
.
data
(),
features
.
data
(),
indices
.
data
(),
size
,
numPlanes
);
buffer
.
data
(),
features
.
data
(),
indices
.
data
(),
size
,
numPlanes
);
TV_CHECK_CUDA_ERR
();
}
}
}
}
};
};
...
@@ -108,6 +110,7 @@ struct SparseScatterAddFunctor<tv::GPU, T, Index> {
...
@@ -108,6 +110,7 @@ struct SparseScatterAddFunctor<tv::GPU, T, Index> {
d
.
stream
()
>>>
(
outFeatures
.
data
(),
buffer
.
data
(),
d
.
stream
()
>>>
(
outFeatures
.
data
(),
buffer
.
data
(),
indices
.
data
(),
nHotBlock
,
indices
.
data
(),
nHotBlock
,
numPlanes
/
vecloadFactor
);
numPlanes
/
vecloadFactor
);
TV_CHECK_CUDA_ERR
();
}
}
if
(
size
-
nHotBlock
>
0
)
{
if
(
size
-
nHotBlock
>
0
)
{
scatterAddGenericKernel
<
T
,
Index
,
int
(
NumTLP
),
NumILP
>
scatterAddGenericKernel
<
T
,
Index
,
int
(
NumTLP
),
NumILP
>
...
@@ -115,6 +118,7 @@ struct SparseScatterAddFunctor<tv::GPU, T, Index> {
...
@@ -115,6 +118,7 @@ struct SparseScatterAddFunctor<tv::GPU, T, Index> {
0
,
d
.
stream
()
>>>
(
0
,
d
.
stream
()
>>>
(
outFeatures
.
data
(),
buffer
.
data
()
+
nHotBlock
*
numPlanes
,
outFeatures
.
data
(),
buffer
.
data
()
+
nHotBlock
*
numPlanes
,
indices
.
data
()
+
nHotBlock
,
size
-
nHotBlock
,
numPlanes
);
indices
.
data
()
+
nHotBlock
,
size
-
nHotBlock
,
numPlanes
);
TV_CHECK_CUDA_ERR
();
}
}
notFound
=
false
;
notFound
=
false
;
}
}
...
@@ -129,6 +133,7 @@ struct SparseScatterAddFunctor<tv::GPU, T, Index> {
...
@@ -129,6 +133,7 @@ struct SparseScatterAddFunctor<tv::GPU, T, Index> {
dim3
(
NumTLP
/
NumILP
,
NumTLP
),
0
,
d
.
stream
()
>>>
(
dim3
(
NumTLP
/
NumILP
,
NumTLP
),
0
,
d
.
stream
()
>>>
(
outFeatures
.
data
(),
buffer
.
data
(),
indices
.
data
(),
size
,
outFeatures
.
data
(),
buffer
.
data
(),
indices
.
data
(),
size
,
numPlanes
);
numPlanes
);
TV_CHECK_CUDA_ERR
();
}
}
}
}
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment