-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
59 lines (47 loc) · 1.31 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
import os
import sys
from glob import glob
from setuptools import setup, find_packages
import torch
from torch.utils.cpp_extension import CUDAExtension
from torch.utils.cpp_extension import BuildExtension
requirements = ["torch", "torchvision"]
def get_extensions():
srcs = glob("cc_torch/csrc/*.cu")
extra_compile_args = {
"cxx": [],
"nvcc": [
"-O3",
"-DCUDA_HAS_FP16=1",
"-D__CUDA_NO_HALF_OPERATORS__",
"-D__CUDA_NO_HALF_CONVERSIONS__",
"-D__CUDA_NO_HALF2_OPERATORS__",
]
}
CC = os.environ.get("CC", None)
if CC is not None:
extra_compile_args["nvcc"].append("-ccbin={}".format(CC))
include_dirs = ["cc_torch/csrc"]
ext_modules = [
CUDAExtension(
"cc_torch._C",
srcs,
include_dirs=include_dirs,
define_macros=[],
extra_compile_args=extra_compile_args
)
]
return ext_modules
setup(
# Meta Data
name='cc_torch',
version='0.1',
description='Connected Components Labeling for PyTorch',
# Package Info
zip_safe=False,
packages=find_packages(exclude=('tests',)),
ext_modules=get_extensions(),
cmdclass={
"build_ext": BuildExtension.with_options(no_python_abi_suffix=True),
},
)