-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1394 from IntelPython/fix/KernelHasReturnValueErr…
…or_in_KernelDispatcher Fix KernelHasReturnValueError inside KernelDispatcher.
- Loading branch information
Showing
2 changed files
with
51 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
numba_dpex/tests/experimental/test_kernel_has_return_value_error.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# SPDX-FileCopyrightText: 2020 - 2024 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import dpnp | ||
import pytest | ||
from numba.core.errors import TypingError | ||
|
||
import numba_dpex.experimental as dpex | ||
from numba_dpex import int32, usm_ndarray | ||
from numba_dpex.core.exceptions import KernelHasReturnValueError | ||
from numba_dpex.core.types.kernel_api.index_space_ids import ItemType | ||
|
||
i32arrty = usm_ndarray(ndim=1, dtype=int32, layout="C") | ||
item_ty = ItemType(ndim=1) | ||
|
||
|
||
def f(item, a): | ||
return a | ||
|
||
|
||
list_of_sig = [ | ||
None, | ||
(i32arrty(item_ty, i32arrty)), | ||
] | ||
|
||
|
||
@pytest.fixture(params=list_of_sig) | ||
def sig(request): | ||
return request.param | ||
|
||
|
||
def test_return(sig): | ||
a = dpnp.arange(1024, dtype=dpnp.int32) | ||
|
||
with pytest.raises((TypingError, KernelHasReturnValueError)) as excinfo: | ||
kernel_fn = dpex.kernel(sig)(f) | ||
dpex.call_kernel(kernel_fn, dpex.Range(a.size), a) | ||
|
||
if isinstance(excinfo.type, TypingError): | ||
assert "KernelHasReturnValueError" in excinfo.value.args[0] |