-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path__init__.py
30 lines (26 loc) · 1.21 KB
/
__init__.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
import os
import torch
from torch.utils import cpp_extension
cwd = os.path.dirname(os.path.realpath(__file__))
sources = []
sources.append(os.path.join(cwd, 'correlation.cpp'))
if torch.cuda.is_available():
sources.append(os.path.join(cwd, 'correlation_sampler.cpp'))
sources.append(os.path.join(cwd, 'correlation_cuda_kernel.cu'))
correlation = cpp_extension.load('correlation',
sources=sources,
build_directory=cwd,
extra_cflags=['-fopenmp'],
extra_ldflags=['-lgomp'],
with_cuda=True,
verbose=False)
else:
# CPU only version
sources.append(os.path.join(cwd, 'correlation_sampler_cpu.cpp'))
correlation = cpp_extension.load('correlation',
sources=sources,
build_directory=cwd,
extra_cflags=['-fopenmp'],
extra_ldflags=['-lgomp'],
with_cuda=False,
verbose=False)