Skip to content

Commit

Permalink
Changes to add support for numba 0.60 to numba-dpex.
Browse files Browse the repository at this point in the history
  • Loading branch information
Diptorup Deb authored and ZzEeKkAa committed Aug 5, 2024
1 parent 252e7d9 commit e8236b6
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 58 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- defaults
- dppy/label/dev
- numba
- intel
- https://software.repos.intel.com/python/conda
- numba/label/dev
- nodefaults
dependencies:
Expand Down
3 changes: 0 additions & 3 deletions numba_dpex/kernel_api_impl/spirv/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,6 @@ def add_overload(self, cres):
self.overloads[args] = cres

def compile(self, sig) -> any:
disp = self._get_dispatcher_for_current_target()
if disp is not self:
return disp.compile(sig)

with ExitStack() as scope:
cres = None
Expand Down
18 changes: 17 additions & 1 deletion numba_dpex/kernel_api_impl/spirv/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,23 @@ def load_additional_registries(self):
target context.
"""
# pylint: disable=import-outside-toplevel
# pylint: disable=import-outside-toplevel, unused-import, too-many-locals
from numba.cpython import (
builtins,
charseq,
enumimpl,
hashing,
heapq,
iterators,
listobj,
numbers,
rangeobj,
setobj,
slicing,
tupleobj,
unicode,
)

from numba_dpex.dpctl_iface import dpctlimpl
from numba_dpex.dpnp_iface import dpnpimpl

Expand Down
2 changes: 1 addition & 1 deletion numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def func(shape, queue):
)
return c

with pytest.raises(errors.TypingError):
with pytest.raises((errors.TypingError, TypeError)):
queue = dpctl.SyclQueue()
func(10, queue)

Expand Down
5 changes: 1 addition & 4 deletions numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_empty_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,10 @@ def func1(x, queue):
y = dpnp.empty_like(x, sycl_queue=queue, device=device)
return y

try:
with pytest.raises((errors.TypingError, TypeError)):
queue = dpctl.SyclQueue()
a = dpnp.ones(10, dtype=dpnp.float32)
func1(a, queue)
except Exception as e:
assert isinstance(e, errors.TypingError)
assert "`device` and `sycl_queue` are exclusive keywords" in str(e)

@dpjit
def func2(x):
Expand Down
5 changes: 1 addition & 4 deletions numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ def func(shape, fill_value, queue):
c = dpnp.ones(shape, fill_value, sycl_queue=queue, device=device)
return c

try:
with pytest.raises((errors.TypingError, TypeError)):
queue = dpctl.SyclQueue()
func(10, 7, queue)
except Exception as e:
assert isinstance(e, errors.TypingError)
assert "`device` and `sycl_queue` are exclusive keywords" in str(e)
13 changes: 2 additions & 11 deletions numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_full_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,10 @@ def func1(x, fill_value, queue):
y = dpnp.full_like(x, 7, sycl_queue=queue, device=device)
return y

try:
with pytest.raises((errors.TypingError, TypeError)):
queue = dpctl.SyclQueue()
a = dpnp.zeros(10)
func1(a, 7, queue)
except Exception as e:
assert isinstance(e, errors.TypingError)
assert "`device` and `sycl_queue` are exclusive keywords" in str(e)

@dpjit
def func2(x, fill_value):
Expand Down Expand Up @@ -241,11 +238,5 @@ def func(shape, fill_value):
x = dpnp.full_like(shape, fill_value)
return x

try:
with pytest.raises((errors.TypingError, AttributeError)):
func(shape, 7)
except Exception as e:
assert isinstance(e, errors.TypingError)
assert (
"No implementation of function Function(<function full_like"
in str(e)
)
5 changes: 1 addition & 4 deletions numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_ones.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ def func(shape, queue):
c = dpnp.ones(shape, sycl_queue=queue, device=device)
return c

try:
with pytest.raises((errors.TypingError, TypeError)):
queue = dpctl.SyclQueue()
func(10, queue)
except Exception as e:
assert isinstance(e, errors.TypingError)
assert "`device` and `sycl_queue` are exclusive keywords" in str(e)
13 changes: 2 additions & 11 deletions numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_ones_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,10 @@ def func1(x, queue):
y = dpnp.ones_like(x, sycl_queue=queue, device=device)
return y

try:
with pytest.raises((errors.TypingError, TypeError)):
queue = dpctl.SyclQueue()
a = dpnp.zeros(10, dtype=dpnp.float32)
func1(a, queue)
except Exception as e:
assert isinstance(e, errors.TypingError)
assert "`device` and `sycl_queue` are exclusive keywords" in str(e)

@dpjit
def func2(x):
Expand Down Expand Up @@ -198,11 +195,5 @@ def func(shape):
x = dpnp.ones_like(shape)
return x

try:
with pytest.raises((errors.TypingError, TypeError)):
func(shape)
except Exception as e:
assert isinstance(e, errors.TypingError)
assert (
"No implementation of function Function(<function ones_like"
in str(e)
)
5 changes: 1 addition & 4 deletions numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_zeros.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ def func(shape, queue):
c = dpnp.zeros(shape, sycl_queue=queue, device=device)
return c

try:
with pytest.raises((errors.TypingError, TypeError)):
queue = dpctl.SyclQueue()
func(10, queue)
except Exception as e:
assert isinstance(e, errors.TypingError)
assert "`device` and `sycl_queue` are exclusive keywords" in str(e)
13 changes: 2 additions & 11 deletions numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_zeros_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,10 @@ def func1(x, queue):
y = dpnp.zeros_like(x, sycl_queue=queue, device=device)
return y

try:
with pytest.raises((errors.TypingError, TypeError)):
queue = dpctl.SyclQueue()
a = dpnp.ones(10, dtype=dpnp.float32)
func1(a, queue)
except Exception as e:
assert isinstance(e, errors.TypingError)
assert "`device` and `sycl_queue` are exclusive keywords" in str(e)

@dpjit
def func2(x):
Expand Down Expand Up @@ -199,11 +196,5 @@ def func(shape):
x = dpnp.zeros_like(shape)
return x

try:
with pytest.raises((errors.TypingError, TypeError)):
func(shape)
except Exception as e:
assert isinstance(e, errors.TypingError)
assert (
"No implementation of function Function(<function zeros_like"
in str(e)
)
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def intrinsic_bar():
def test_dpex_overload_from_njit():
bar_njit = njit(bar)

with pytest.raises(errors.TypingError):
with pytest.raises((errors.TypingError, errors.UnsupportedError)):
bar_njit()


Expand All @@ -72,7 +72,7 @@ def test_dpex_overload_from_dpjit():
def test_dpex_intrinsic_from_njit():
bar_njit = njit(intrinsic_bar)

with pytest.raises(errors.TypingError):
with pytest.raises((errors.TypingError, errors.UnsupportedError)):
bar_njit()


Expand Down
2 changes: 1 addition & 1 deletion numba_dpex/tests/kernel_tests/test_async_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_async_dependent_add_list_exception():

# TODO: should capture ValueError, but numba captures it and generates
# TypingError. ValueError is still readable there.
with pytest.raises(TypingError):
with pytest.raises((TypingError, ValueError)):
dpex.call_kernel_async(
add,
Range(size),
Expand Down

0 comments on commit e8236b6

Please sign in to comment.