Skip to content

Commit

Permalink
Add support for dpNP (#12)
Browse files Browse the repository at this point in the history
* Add support for dpNP

Support for dpNP requires biulding of Cython module.

* Small fixes

Add dpnp in conda build dependencies.
Add missing comma in setup.py.
Import module os and Extension class.
  • Loading branch information
PokhodenkoSA authored Nov 17, 2020
1 parent f0e3d2a commit 23ebaab
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ requirements:
- llvm-spirv
- numba
- dpctl
- dpnp
run:
- python
- numba >=0.51
Expand Down
38 changes: 36 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
from setuptools import find_packages, setup
import os
from setuptools import Extension, find_packages, setup
from Cython.Build import cythonize

packages = find_packages(include=["numba_dppy", "numba_dppy.*"])

def get_ext_modules():
ext_modules = []

dpnp_present = False
try:
import dpnp
except:
pass
else:
dpnp_present = True

if dpnp_present:
dpnp_lib_path = []
dpnp_lib_path += [os.path.dirname(dpnp.__file__)]
ext_dpnp_glue = Extension(name='numba_dppy.dpnp_glue.dpnp_fptr_interface',
sources=['numba_dppy/dpnp_glue/dpnp_fptr_interface.pyx'],
include_dirs=[dpnp.get_include()],
libraries=['dpnp_backend_c'],
library_dirs=dpnp_lib_path,
runtime_library_dirs=dpnp_lib_path,
language="c++")
ext_modules += [ext_dpnp_glue]

if dpnp_present:
return cythonize(ext_modules)
else:
return ext_modules


packages = find_packages(include=["numba_dppy", "numba_dppy.*"])
build_requires = ["cython"]
install_requires = [
"numba",
"dpctl",
Expand All @@ -13,7 +45,9 @@
description="Numba extension for Intel CPU and GPU backend",
url="https://github.com/IntelPython/numba-dppy",
packages=packages,
setup_requires=build_requires,
install_requires=install_requires,
ext_modules=get_ext_modules(),
author="Intel Corporation",
classifiers=[
"Development Status :: 4 - Beta",
Expand Down

0 comments on commit 23ebaab

Please sign in to comment.