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
06c6091c
Commit
06c6091c
authored
Mar 22, 2019
by
traveller59
Browse files
Add windows 10 support .
parent
8da6f967
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
47 additions
and
21 deletions
+47
-21
CMakeLists.txt
CMakeLists.txt
+1
-1
README.md
README.md
+16
-2
include/spconv/box_iou.h
include/spconv/box_iou.h
+1
-1
include/spconv/geometry.h
include/spconv/geometry.h
+7
-3
include/spconv/nms.h
include/spconv/nms.h
+3
-3
setup.py
setup.py
+12
-8
spconv/__init__.py
spconv/__init__.py
+5
-1
src/utils/CMakeLists.txt
src/utils/CMakeLists.txt
+2
-2
No files found.
CMakeLists.txt
View file @
06c6091c
cmake_minimum_required
(
VERSION 3.13 FATAL_ERROR
)
cmake_minimum_required
(
VERSION 3.13 FATAL_ERROR
)
project
(
SparseConv LANGUAGES CXX CUDA VERSION 1.0
)
project
(
SparseConv LANGUAGES CXX CUDA VERSION 1.0
)
option
(
SPCONV_BuildTests
"Build the unit tests when BUILD_TESTING is enabled."
O
N
)
option
(
SPCONV_BuildTests
"Build the unit tests when BUILD_TESTING is enabled."
O
FF
)
set
(
CMAKE_CXX_EXTENSIONS OFF
)
# avoid gnu++11 be added to CXX flags
set
(
CMAKE_CXX_EXTENSIONS OFF
)
# avoid gnu++11 be added to CXX flags
set
(
CUDA_TOOLKIT_ROOT_DIR
"
${
CMAKE_CUDA_COMPILER
}
"
)
set
(
CUDA_TOOLKIT_ROOT_DIR
"
${
CMAKE_CUDA_COMPILER
}
"
)
...
...
README.md
View file @
06c6091c
...
@@ -8,7 +8,7 @@ The GPU Indice Generation algorithm is a unofficial implementation of paper [SEC
...
@@ -8,7 +8,7 @@ The GPU Indice Generation algorithm is a unofficial implementation of paper [SEC
This project only support CUDA 9.0+. If you are using cuda 8.0, please update it to 9.0.
This project only support CUDA 9.0+. If you are using cuda 8.0, please update it to 9.0.
## Install
## Install
on Ubuntu 16.04/18.04
0.
Use
```git clone xxx.git --recursive```
to clone this repo.
0.
Use
```git clone xxx.git --recursive```
to clone this repo.
...
@@ -16,7 +16,21 @@ This project only support CUDA 9.0+. If you are using cuda 8.0, please update it
...
@@ -16,7 +16,21 @@ 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 bdist_wheel```
(don't use
```python setup.py install```
).
3.
Ensure you have installed 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.
## Install on Windows 10 with CUDA 10 and python 3.6 (python 3.7 may have problem, see [this](https://github.com/pytorch/pytorch/issues/17233))
Since install newest driver and CUDA is very simple on windows, please use CUDA 10 on windows.
0.
Use
```git clone xxx.git --recursive```
to clone this repo.
1.
Download compressed files from boost official website and copy headers (i.e. boost_1_69/boost) to spconv/include.
2.
Download and install cmake >= 3.13.2, select add cmake to User or System PATH.
3.
Ensure you have installed 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.
4.
Run
```cd ./dist```
, use pip to install generated whl file.
...
...
include/spconv/box_iou.h
View file @
06c6091c
...
@@ -54,7 +54,7 @@ rbbox_iou(py::array_t<DType> box_corners, py::array_t<DType> qbox_corners,
...
@@ -54,7 +54,7 @@ rbbox_iou(py::array_t<DType> box_corners, py::array_t<DType> qbox_corners,
auto
standup_iou_r
=
standup_iou
.
template
unchecked
<
2
>();
auto
standup_iou_r
=
standup_iou
.
template
unchecked
<
2
>();
auto
N
=
box_corners_r
.
shape
(
0
);
auto
N
=
box_corners_r
.
shape
(
0
);
auto
K
=
qbox_corners_r
.
shape
(
0
);
auto
K
=
qbox_corners_r
.
shape
(
0
);
py
::
array_t
<
DType
>
overlaps
=
zeros
<
DType
>
({
N
,
K
});
py
::
array_t
<
DType
>
overlaps
=
zeros
<
DType
>
({
int
(
N
),
int
(
K
)
});
auto
overlaps_rw
=
overlaps
.
template
mutable_unchecked
<
2
>();
auto
overlaps_rw
=
overlaps
.
template
mutable_unchecked
<
2
>();
if
(
N
==
0
||
K
==
0
)
{
if
(
N
==
0
||
K
==
0
)
{
return
overlaps
;
return
overlaps
;
...
...
include/spconv/geometry.h
View file @
06c6091c
...
@@ -166,7 +166,8 @@ Index getIndicePairsConv(tv::TensorView<const Index> indicesIn,
...
@@ -166,7 +166,8 @@ Index getIndicePairsConv(tv::TensorView<const Index> indicesIn,
kernelVolume
*=
kernelSize
[
i
];
kernelVolume
*=
kernelSize
[
i
];
}
}
Index
numValidPoints
=
0
;
Index
numValidPoints
=
0
;
Index
validPoints
[
kernelVolume
*
(
NDim
+
1
)];
std
::
vector
<
Index
>
validPoints_
(
kernelVolume
*
(
NDim
+
1
));
Index
*
validPoints
=
validPoints_
.
data
();
Index
*
pointPtr
=
nullptr
;
Index
*
pointPtr
=
nullptr
;
for
(
int
j
=
0
;
j
<
numActIn
;
++
j
)
{
for
(
int
j
=
0
;
j
<
numActIn
;
++
j
)
{
batchIdx
=
indicesIn
(
j
,
0
);
batchIdx
=
indicesIn
(
j
,
0
);
...
@@ -216,7 +217,8 @@ Index getIndicePairsDeConv(tv::TensorView<const Index> indicesIn,
...
@@ -216,7 +217,8 @@ Index getIndicePairsDeConv(tv::TensorView<const Index> indicesIn,
kernelVolume
*=
kernelSize
[
i
];
kernelVolume
*=
kernelSize
[
i
];
}
}
Index
numValidPoints
=
0
;
Index
numValidPoints
=
0
;
Index
validPoints
[
kernelVolume
*
(
NDim
+
1
)];
std
::
vector
<
Index
>
validPoints_
(
kernelVolume
*
(
NDim
+
1
));
Index
*
validPoints
=
validPoints_
.
data
();
Index
*
pointPtr
=
nullptr
;
Index
*
pointPtr
=
nullptr
;
for
(
int
j
=
0
;
j
<
numActIn
;
++
j
)
{
for
(
int
j
=
0
;
j
<
numActIn
;
++
j
)
{
batchIdx
=
indicesIn
(
j
,
0
);
batchIdx
=
indicesIn
(
j
,
0
);
...
@@ -265,7 +267,9 @@ Index getIndicePairsSubM(tv::TensorView<const Index> indicesIn,
...
@@ -265,7 +267,9 @@ Index getIndicePairsSubM(tv::TensorView<const Index> indicesIn,
kernelVolume
*=
kernelSize
[
i
];
kernelVolume
*=
kernelSize
[
i
];
}
}
Index
numValidPoints
=
0
;
Index
numValidPoints
=
0
;
Index
validPoints
[
kernelVolume
*
(
NDim
+
1
)];
// Index validPoints[kernelVolume * (NDim + 1)];
std
::
vector
<
Index
>
validPoints_
(
kernelVolume
*
(
NDim
+
1
));
Index
*
validPoints
=
validPoints_
.
data
();
Index
*
pointPtr
=
nullptr
;
Index
*
pointPtr
=
nullptr
;
Index
index
=
0
;
Index
index
=
0
;
for
(
int
j
=
0
;
j
<
numActIn
;
++
j
)
{
for
(
int
j
=
0
;
j
<
numActIn
;
++
j
)
{
...
...
include/spconv/nms.h
View file @
06c6091c
...
@@ -34,9 +34,9 @@ std::vector<int> non_max_suppression_cpu(py::array_t<DType> boxes,
...
@@ -34,9 +34,9 @@ std::vector<int> non_max_suppression_cpu(py::array_t<DType> boxes,
auto
ndets
=
boxes
.
shape
(
0
);
auto
ndets
=
boxes
.
shape
(
0
);
auto
boxes_r
=
boxes
.
template
unchecked
<
2
>();
auto
boxes_r
=
boxes
.
template
unchecked
<
2
>();
auto
order_r
=
order
.
template
unchecked
<
1
>();
auto
order_r
=
order
.
template
unchecked
<
1
>();
auto
suppressed
=
zeros
<
int
>
({
ndets
});
auto
suppressed
=
zeros
<
int
>
({
int
(
ndets
)
});
auto
suppressed_rw
=
suppressed
.
template
mutable_unchecked
<
1
>();
auto
suppressed_rw
=
suppressed
.
template
mutable_unchecked
<
1
>();
auto
area
=
zeros
<
DType
>
({
ndets
});
auto
area
=
zeros
<
DType
>
({
int
(
ndets
)
});
auto
area_rw
=
area
.
template
mutable_unchecked
<
1
>();
auto
area_rw
=
area
.
template
mutable_unchecked
<
1
>();
// get areas
// get areas
for
(
int
i
=
0
;
i
<
ndets
;
++
i
)
{
for
(
int
i
=
0
;
i
<
ndets
;
++
i
)
{
...
@@ -82,7 +82,7 @@ std::vector<int> rotate_non_max_suppression_cpu(py::array_t<DType> box_corners,
...
@@ -82,7 +82,7 @@ std::vector<int> rotate_non_max_suppression_cpu(py::array_t<DType> box_corners,
auto
ndets
=
box_corners
.
shape
(
0
);
auto
ndets
=
box_corners
.
shape
(
0
);
auto
box_corners_r
=
box_corners
.
template
unchecked
<
3
>();
auto
box_corners_r
=
box_corners
.
template
unchecked
<
3
>();
auto
order_r
=
order
.
template
unchecked
<
1
>();
auto
order_r
=
order
.
template
unchecked
<
1
>();
auto
suppressed
=
zeros
<
int
>
({
ndets
});
auto
suppressed
=
zeros
<
int
>
({
int
(
ndets
)
});
auto
suppressed_rw
=
suppressed
.
template
mutable_unchecked
<
1
>();
auto
suppressed_rw
=
suppressed
.
template
mutable_unchecked
<
1
>();
auto
standup_iou_r
=
standup_iou
.
template
unchecked
<
2
>();
auto
standup_iou_r
=
standup_iou
.
template
unchecked
<
2
>();
std
::
vector
<
int
>
keep
;
std
::
vector
<
int
>
keep
;
...
...
setup.py
View file @
06c6091c
...
@@ -17,7 +17,6 @@ LIBTORCH_ROOT = str(Path(torch.__file__).parent)
...
@@ -17,7 +17,6 @@ LIBTORCH_ROOT = str(Path(torch.__file__).parent)
PYTHON_VERSION
=
"{}.{}"
.
format
(
sys
.
version_info
.
major
,
sys
.
version_info
.
minor
)
PYTHON_VERSION
=
"{}.{}"
.
format
(
sys
.
version_info
.
major
,
sys
.
version_info
.
minor
)
class
CMakeExtension
(
Extension
):
class
CMakeExtension
(
Extension
):
def
__init__
(
self
,
name
,
sourcedir
=
''
,
library_dirs
=
[]):
def
__init__
(
self
,
name
,
sourcedir
=
''
,
library_dirs
=
[]):
Extension
.
__init__
(
self
,
name
,
sources
=
[],
library_dirs
=
library_dirs
)
Extension
.
__init__
(
self
,
name
,
sources
=
[],
library_dirs
=
library_dirs
)
...
@@ -33,30 +32,35 @@ class CMakeBuild(build_ext):
...
@@ -33,30 +32,35 @@ class CMakeBuild(build_ext):
", "
.
join
(
e
.
name
for
e
in
self
.
extensions
))
", "
.
join
(
e
.
name
for
e
in
self
.
extensions
))
if
platform
.
system
()
==
"Windows"
:
if
platform
.
system
()
==
"Windows"
:
raise
NotImplementedError
cmake_version
=
LooseVersion
(
re
.
search
(
r
'version\s*([\d.]+)'
,
out
.
decode
()).
group
(
1
))
if
cmake_version
<
'3.13.0'
:
raise
RuntimeError
(
"CMake >= 3.13.0 is required on Windows"
)
for
ext
in
self
.
extensions
:
for
ext
in
self
.
extensions
:
self
.
build_extension
(
ext
)
self
.
build_extension
(
ext
)
def
build_extension
(
self
,
ext
):
def
build_extension
(
self
,
ext
):
extdir
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
self
.
get_ext_fullpath
(
ext
.
name
)))
extdir
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
self
.
get_ext_fullpath
(
ext
.
name
)))
print
(
extdir
)
cmake_args
=
[
# '-G "Visual Studio 15 2017 Win64"',
cmake_args
=
[
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY='
+
extdir
+
"/spconv"
,
'-DCMAKE_PREFIX_PATH={}'
.
format
(
LIBTORCH_ROOT
),
'-DCMAKE_PREFIX_PATH='
+
LIBTORCH_ROOT
,
'-DPYBIND11_PYTHON_VERSION={}'
.
format
(
PYTHON_VERSION
),
'-DPYBIND11_PYTHON_VERSION={}'
.
format
(
PYTHON_VERSION
),
'-DSPCONV_BuildTests=OFF'
,
'-DSPCONV_BuildTests=OFF'
,
'-DCMAKE_CUDA_FLAGS="--expt-relaxed-constexpr"'
]
'-DCMAKE_CUDA_FLAGS="--expt-relaxed-constexpr"'
]
assert
self
.
debug
is
False
,
"pytorch ops don't support debug build."
cfg
=
'Debug'
if
self
.
debug
else
'Release'
cfg
=
'Debug'
if
self
.
debug
else
'Release'
# cfg = 'Debug'
# cfg = 'Debug'
build_args
=
[
'--config'
,
cfg
]
build_args
=
[
'--config'
,
cfg
]
print
(
cfg
)
print
(
cfg
)
if
platform
.
system
()
==
"Windows"
:
if
platform
.
system
()
==
"Windows"
:
cmake_args
+=
[
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'
.
format
(
cfg
.
upper
(),
extdir
)]
cmake_args
+=
[
'-DCMAKE_BUILD_TYPE='
+
cfg
]
cmake_args
+=
[
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'
.
format
(
cfg
.
upper
(),
str
(
Path
(
extdir
)
/
"spconv"
))]
# cmake_args += ['-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_{}={}'.format(cfg.upper(), str(Path(extdir) / "spconv"))]
cmake_args
+=
[
'-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_{}={}'
.
format
(
cfg
.
upper
(),
str
(
Path
(
extdir
)
/
"spconv"
))]
if
sys
.
maxsize
>
2
**
32
:
if
sys
.
maxsize
>
2
**
32
:
cmake_args
+=
[
'-A'
,
'x64'
]
cmake_args
+=
[
'-A'
,
'x64'
]
build_args
+=
[
'--'
,
'/m'
]
build_args
+=
[
'--'
,
'/m'
]
else
:
else
:
cmake_args
+=
[
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={}'
.
format
(
extdir
+
str
(
Path
(
extdir
)
/
"spconv"
))]
cmake_args
+=
[
'-DCMAKE_BUILD_TYPE='
+
cfg
]
cmake_args
+=
[
'-DCMAKE_BUILD_TYPE='
+
cfg
]
build_args
+=
[
'--'
,
'-j4'
]
build_args
+=
[
'--'
,
'-j4'
]
...
@@ -65,7 +69,7 @@ class CMakeBuild(build_ext):
...
@@ -65,7 +69,7 @@ class CMakeBuild(build_ext):
self
.
distribution
.
get_version
())
self
.
distribution
.
get_version
())
if
not
os
.
path
.
exists
(
self
.
build_temp
):
if
not
os
.
path
.
exists
(
self
.
build_temp
):
os
.
makedirs
(
self
.
build_temp
)
os
.
makedirs
(
self
.
build_temp
)
print
(
"|||||||||"
,
cmake_args
)
subprocess
.
check_call
([
'cmake'
,
ext
.
sourcedir
]
+
cmake_args
,
cwd
=
self
.
build_temp
,
env
=
env
)
subprocess
.
check_call
([
'cmake'
,
ext
.
sourcedir
]
+
cmake_args
,
cwd
=
self
.
build_temp
,
env
=
env
)
subprocess
.
check_call
([
'cmake'
,
'--build'
,
'.'
]
+
build_args
,
cwd
=
self
.
build_temp
)
subprocess
.
check_call
([
'cmake'
,
'--build'
,
'.'
]
+
build_args
,
cwd
=
self
.
build_temp
)
...
...
spconv/__init__.py
View file @
06c6091c
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
from
pathlib
import
Path
from
pathlib
import
Path
import
platform
import
numpy
as
np
import
numpy
as
np
import
torch
import
torch
from
spconv
import
utils
from
spconv
import
utils
...
@@ -23,7 +24,10 @@ from spconv.conv import SparseInverseConv2d, SparseInverseConv3d
...
@@ -23,7 +24,10 @@ from spconv.conv import SparseInverseConv2d, SparseInverseConv3d
from
spconv.modules
import
SparseModule
,
SparseSequential
from
spconv.modules
import
SparseModule
,
SparseSequential
from
spconv.pool
import
SparseMaxPool2d
,
SparseMaxPool3d
from
spconv.pool
import
SparseMaxPool2d
,
SparseMaxPool3d
_LIB_PATH
=
str
(
Path
(
__file__
).
parent
/
"libspconv.so"
)
_LIB_FILE_NAME
=
"libspconv.so"
if
platform
.
system
()
==
"Windows"
:
_LIB_FILE_NAME
=
"spconv.dll"
_LIB_PATH
=
str
(
Path
(
__file__
).
parent
/
_LIB_FILE_NAME
)
torch
.
ops
.
load_library
(
_LIB_PATH
)
torch
.
ops
.
load_library
(
_LIB_PATH
)
def
scatter_nd
(
indices
,
updates
,
shape
):
def
scatter_nd
(
indices
,
updates
,
shape
):
...
...
src/utils/CMakeLists.txt
View file @
06c6091c
add_library
(
spconv_nms S
HARED
nms.cu
)
add_library
(
spconv_nms S
TATIC
nms.cu
)
set_target_properties
(
spconv_nms PROPERTIES VERSION
${
PROJECT_VERSION
}
)
set_target_properties
(
spconv_nms PROPERTIES VERSION
${
PROJECT_VERSION
}
)
set_target_properties
(
spconv_nms PROPERTIES SOVERSION 1
)
set_target_properties
(
spconv_nms PROPERTIES SOVERSION 1
)
target_include_directories
(
spconv_nms PRIVATE
${
ALL_INCLUDE
}
)
target_include_directories
(
spconv_nms PRIVATE
${
ALL_INCLUDE
}
)
...
@@ -17,6 +17,6 @@ set_property(TARGET spconv_utils PROPERTY CXX_STANDARD 14)
...
@@ -17,6 +17,6 @@ set_property(TARGET spconv_utils PROPERTY CXX_STANDARD 14)
set_property
(
TARGET spconv_utils PROPERTY CUDA_STANDARD 14
)
set_property
(
TARGET spconv_utils PROPERTY CUDA_STANDARD 14
)
set_target_properties
(
spconv_utils PROPERTIES PREFIX
"
${
PYTHON_MODULE_PREFIX
}
"
set_target_properties
(
spconv_utils PROPERTIES PREFIX
"
${
PYTHON_MODULE_PREFIX
}
"
SUFFIX
"
${
PYTHON_MODULE_EXTENSION
}
"
)
SUFFIX
"
${
PYTHON_MODULE_EXTENSION
}
"
)
target_link_libraries
(
spconv_utils
${
CUDA_CUDART
}
pybind11::module
-Wl,--no-as-needed
spconv_nms
)
target_link_libraries
(
spconv_utils
${
CUDA_CUDART
}
pybind11::module spconv_nms
)
install
(
TARGETS spconv_utils DESTINATION lib
)
install
(
TARGETS spconv_utils DESTINATION lib
)
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