2018-02-13 23:02:50 +00:00
|
|
|
import torch.cuda
|
|
|
|
|
from setuptools import setup
|
|
|
|
|
from torch.utils.cpp_extension import CppExtension, CUDAExtension
|
2018-01-23 00:49:11 +00:00
|
|
|
|
|
|
|
|
ext_modules = [
|
2018-02-13 23:02:50 +00:00
|
|
|
CppExtension(
|
2018-02-17 03:31:04 +00:00
|
|
|
'torch_test_cpp_extension', ['extension.cpp'],
|
2018-02-13 23:02:50 +00:00
|
|
|
extra_compile_args=['-g']),
|
2018-01-23 00:49:11 +00:00
|
|
|
]
|
|
|
|
|
|
2018-02-13 23:02:50 +00:00
|
|
|
if torch.cuda.is_available():
|
|
|
|
|
extension = CUDAExtension(
|
|
|
|
|
'torch_test_cuda_extension',
|
|
|
|
|
['cuda_extension.cpp', 'cuda_extension_kernel.cu'],
|
|
|
|
|
extra_compile_args={'cxx': ['-g'],
|
|
|
|
|
'nvcc': ['-O2']})
|
|
|
|
|
ext_modules.append(extension)
|
|
|
|
|
|
2018-01-23 00:49:11 +00:00
|
|
|
setup(
|
2018-02-17 03:31:04 +00:00
|
|
|
name='torch_test_cpp_extension',
|
2018-01-23 00:49:11 +00:00
|
|
|
ext_modules=ext_modules,
|
|
|
|
|
cmdclass={'build_ext': torch.utils.cpp_extension.BuildExtension})
|