This repository has been archived by the owner on Jul 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 427
/
setup.py
171 lines (163 loc) · 6.24 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import os
import torch
from setuptools import find_packages, setup
from torch.utils.cpp_extension import BuildExtension, CppExtension, CUDAExtension
def make_cuda_ext(
name, module, sources, sources_cuda=[], extra_args=[], extra_include_path=[]
):
define_macros = []
extra_compile_args = {"cxx": [] + extra_args}
if (torch.cuda.is_available() and torch.version.cuda is not None) or os.getenv("FORCE_CUDA", "0") == "1":
define_macros += [("WITH_CUDA", None)]
extension = CUDAExtension
extra_compile_args["nvcc"] = extra_args + [
"-D__CUDA_NO_HALF_OPERATORS__",
"-D__CUDA_NO_HALF_CONVERSIONS__",
"-D__CUDA_NO_HALF2_OPERATORS__",
"-gencode=arch=compute_70,code=sm_70",
"-gencode=arch=compute_75,code=sm_75",
"-gencode=arch=compute_80,code=sm_80",
"-gencode=arch=compute_86,code=sm_86",
]
sources += sources_cuda
elif (torch.cuda.is_available() and torch.version.hip is not None) or os.getenv("FORCE_ROCM", "0") == 1:
define_macros += [("WITH_ROCM", None)]
extension = CUDAExtension
extra_compile_args["hipcc"] = extra_args + [
"-D__HIP_NO_HALF_OPERATORS__",
"-D__HIP_NO_HALF_CONVERSIONS__",
"-D__HIP_NO_HALF2_OPERATORS__",
]
sources += sources_cuda
else:
print("Compiling {} without CUDA".format(name))
extension = CppExtension
return extension(
name="{}.{}".format(module, name),
sources=[os.path.join(*module.split("."), p) for p in sources],
include_dirs=extra_include_path,
define_macros=define_macros,
extra_compile_args=extra_compile_args,
)
if __name__ == "__main__":
setup(
name="mmdet3d",
packages=find_packages(),
include_package_data=True,
package_data={"mmdet3d.ops": ["*/*.so"]},
classifiers=[
"Development Status :: 4 - Beta",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
],
license="Apache License 2.0",
ext_modules=[
make_cuda_ext(
name="sparse_conv_ext",
module="mmdet3d.ops.spconv",
extra_include_path=[
# PyTorch 1.5 uses ninjia, which requires absolute path
# of included files, relative path will cause failure.
os.path.abspath(
os.path.join(*"mmdet3d.ops.spconv".split("."), "include/")
)
],
sources=[
"src/all.cc",
"src/reordering_cpu.cc",
"src/reordering_cuda.cu",
"src/indice_cpu.cc",
"src/indice_cuda.cu",
"src/maxpool_cpu.cc",
"src/maxpool_cuda.cu",
],
extra_args=["-w", "-std=c++17"],
),
make_cuda_ext(
name="bev_pool_ext",
module="mmdet3d.ops.bev_pool",
sources=[
"src/bev_pool_cpu.cpp",
"src/bev_pool_cuda.cu",
],
),
make_cuda_ext(
name="iou3d_cuda",
module="mmdet3d.ops.iou3d",
sources=[
"src/iou3d.cpp",
"src/iou3d_kernel.cu",
],
),
make_cuda_ext(
name="voxel_layer",
module="mmdet3d.ops.voxel",
sources=[
"src/voxelization.cpp",
"src/scatter_points_cpu.cpp",
"src/scatter_points_cuda.cu",
"src/voxelization_cpu.cpp",
"src/voxelization_cuda.cu",
],
),
make_cuda_ext(
name="roiaware_pool3d_ext",
module="mmdet3d.ops.roiaware_pool3d",
sources=[
"src/roiaware_pool3d.cpp",
"src/points_in_boxes_cpu.cpp",
],
sources_cuda=[
"src/roiaware_pool3d_kernel.cu",
"src/points_in_boxes_cuda.cu",
],
),
make_cuda_ext(
name="ball_query_ext",
module="mmdet3d.ops.ball_query",
sources=["src/ball_query_cpu.cpp"],
sources_cuda=["src/ball_query_cuda.cu"],
),
make_cuda_ext(
name="knn_ext",
module="mmdet3d.ops.knn",
sources=["src/knn_cpu.cpp"],
sources_cuda=["src/knn_cuda.cu"],
),
make_cuda_ext(
name="assign_score_withk_ext",
module="mmdet3d.ops.paconv",
sources=["src/assign_score_withk.cpp"],
sources_cuda=["src/assign_score_withk_cuda.cu"],
),
make_cuda_ext(
name="group_points_ext",
module="mmdet3d.ops.group_points",
sources=["src/group_points_cpu.cpp"],
sources_cuda=["src/group_points_cuda.cu"],
),
make_cuda_ext(
name="interpolate_ext",
module="mmdet3d.ops.interpolate",
sources=["src/interpolate.cpp"],
sources_cuda=["src/three_interpolate_cuda.cu", "src/three_nn_cuda.cu"],
),
make_cuda_ext(
name="furthest_point_sample_ext",
module="mmdet3d.ops.furthest_point_sample",
sources=["src/furthest_point_sample_cpu.cpp"],
sources_cuda=["src/furthest_point_sample_cuda.cu"],
),
make_cuda_ext(
name="gather_points_ext",
module="mmdet3d.ops.gather_points",
sources=["src/gather_points_cpu.cpp"],
sources_cuda=["src/gather_points_cuda.cu"],
),
],
cmdclass={"build_ext": BuildExtension},
zip_safe=False,
)