def define_extensions(use_cython=False):
if sys.platform.startswith("win"):
# compile args from
# https://msdn.microsoft.com/en-us/library/fwkeyyhe.aspx
compile_args = ['/O2', '/openmp']
link_args = []
else:
compile_args = ['-Wno-unused-function', '-Wno-maybe-uninitialized', '-O3', '-ffast-math']
link_args = []
if use_openmp:
compile_args.append("-fopenmp")
link_args.append("-fopenmp")
src_ext = '.pyx' if use_cython else '.cpp'
modules = [Extension("implicit." + name,
[os.path.join("implicit", name + src_ext)],
language='c++',
extra_compile_args=compile_args, extra_link_args=link_args)
for name in ['_als', '_nearest_neighbours']]
if CUDA:
modules.append(Extension("implicit.cuda._cuda",
[os.path.join("implicit", "cuda", "_cuda" + src_ext),
os.path.join("implicit", "cuda", "als.cu"),
os.path.join("implicit", "cuda", "matrix.cu")],
language="c++",
extra_compile_args=compile_args,
extra_link_args=link_args,
library_dirs=[CUDA['lib64']],
libraries=['cudart', 'cublas'],
runtime_library_dirs=[CUDA['lib64']],
include_dirs=[CUDA['include'], '.']))
if use_cython:
return cythonize(modules)
else:
return modules
# set_gcc copied from glove-python project
# https://github.com/maciejkula/glove-python
评论列表
文章目录