From e8236b6368999a3e5b4b837081a6915646871724 Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Fri, 19 Jul 2024 22:33:33 -0500 Subject: [PATCH] Changes to add support for numba 0.60 to numba-dpex. --- environment.yml | 2 +- numba_dpex/kernel_api_impl/spirv/dispatcher.py | 3 --- numba_dpex/kernel_api_impl/spirv/target.py | 18 +++++++++++++++++- .../tests/dpjit_tests/dpnp/test_dpnp_empty.py | 2 +- .../dpjit_tests/dpnp/test_dpnp_empty_like.py | 5 +---- .../tests/dpjit_tests/dpnp/test_dpnp_full.py | 5 +---- .../dpjit_tests/dpnp/test_dpnp_full_like.py | 13 ++----------- .../tests/dpjit_tests/dpnp/test_dpnp_ones.py | 5 +---- .../dpjit_tests/dpnp/test_dpnp_ones_like.py | 13 ++----------- .../tests/dpjit_tests/dpnp/test_dpnp_zeros.py | 5 +---- .../dpjit_tests/dpnp/test_dpnp_zeros_like.py | 13 ++----------- .../test_dpex_target_overload_isolation.py | 4 ++-- .../tests/kernel_tests/test_async_kernel.py | 2 +- 13 files changed, 32 insertions(+), 58 deletions(-) diff --git a/environment.yml b/environment.yml index 4c09d7c2f2..9e52cefb17 100644 --- a/environment.yml +++ b/environment.yml @@ -3,7 +3,7 @@ channels: - defaults - dppy/label/dev - numba - - intel + - https://software.repos.intel.com/python/conda - numba/label/dev - nodefaults dependencies: diff --git a/numba_dpex/kernel_api_impl/spirv/dispatcher.py b/numba_dpex/kernel_api_impl/spirv/dispatcher.py index 92224d9c28..fa2b9bfad7 100644 --- a/numba_dpex/kernel_api_impl/spirv/dispatcher.py +++ b/numba_dpex/kernel_api_impl/spirv/dispatcher.py @@ -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 diff --git a/numba_dpex/kernel_api_impl/spirv/target.py b/numba_dpex/kernel_api_impl/spirv/target.py index 379a76b92d..196ff814e9 100644 --- a/numba_dpex/kernel_api_impl/spirv/target.py +++ b/numba_dpex/kernel_api_impl/spirv/target.py @@ -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 diff --git a/numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_empty.py b/numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_empty.py index 4808bf3f9b..37b7e0b0d3 100644 --- a/numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_empty.py +++ b/numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_empty.py @@ -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) diff --git a/numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_empty_like.py b/numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_empty_like.py index e1cc0b209b..be81f6478c 100644 --- a/numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_empty_like.py +++ b/numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_empty_like.py @@ -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): diff --git a/numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_full.py b/numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_full.py index cc15906a8d..867b502348 100644 --- a/numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_full.py +++ b/numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_full.py @@ -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) diff --git a/numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_full_like.py b/numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_full_like.py index b466b92575..16b436c7f9 100644 --- a/numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_full_like.py +++ b/numba_dpex/tests/dpjit_tests/dpnp/test_dpnp_full_like.py @@ -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): @@ -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(