Skip to content
Merged
16 changes: 8 additions & 8 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:

strategy:
matrix:
python: ['3.9', '3.10', '3.11', '3.12']
python: ['3.9', '3.10', '3.11']

continue-on-error: true

Expand Down Expand Up @@ -148,7 +148,7 @@ jobs:

- name: Test conda channel
run: |
mamba search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
cat ${{ env.ver-json-path }}

- name: Get package version
Expand Down Expand Up @@ -182,7 +182,7 @@ jobs:
id: run_tests_linux
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
with:
timeout_minutes: 10
timeout_minutes: 12
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
retry_on: any
command: |
Expand All @@ -193,7 +193,7 @@ jobs:
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests

test_linux_all_dtypes:
name: Test ['ubuntu-latest', python='${{ matrix.python }}']
name: Test ['ubuntu-latest-all-dtypes', python='${{ matrix.python }}']

needs: build

Expand Down Expand Up @@ -274,7 +274,7 @@ jobs:
env:
DPNP_TEST_ALL_INT_TYPES: 1
run: |
pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests

test_windows:
name: Test ['windows-2019', python='${{ matrix.python }}']
Expand All @@ -289,7 +289,7 @@ jobs:

strategy:
matrix:
python: ['3.9', '3.10', '3.11', '3.12']
python: ['3.9', '3.10', '3.11']

continue-on-error: true

Expand Down Expand Up @@ -348,7 +348,7 @@ jobs:
- name: Test conda channel
run: |
@echo on
mamba search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}

- name: Dump version.json
run: more ${{ env.ver-json-path }}
Expand Down Expand Up @@ -409,7 +409,7 @@ jobs:
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests

test_windows_all_dtypes:
name: Test ['windows-2019', python='${{ matrix.python }}']
name: Test ['windows-2019-all-dtypes', python='${{ matrix.python }}']

needs: build

Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/kernels/dpnp_krnl_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* sycl::ext::oneapi::experimental::properties was added.
*/
#ifndef __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT
#define __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT 20241129
#define __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT 20241208L
#endif

namespace mkl_blas = oneapi::mkl::blas;
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/kernels/elementwise_functions/i0.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* sycl::ext::intel::math::cyl_bessel_i0(x) is fully resolved.
*/
#ifndef __SYCL_COMPILER_BESSEL_I0_SUPPORT
#define __SYCL_COMPILER_BESSEL_I0_SUPPORT 20241114L
#define __SYCL_COMPILER_BESSEL_I0_SUPPORT 20241208L
#endif

#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_BESSEL_I0_SUPPORT
Expand Down
29 changes: 19 additions & 10 deletions dpnp/dpnp_iface_linearalgebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@

"""

# pylint: disable=no-name-in-module
import numpy

import dpnp

from .dpnp_utils import map_dtype_to_device
from .dpnp_utils.dpnp_utils_einsum import dpnp_einsum
from .dpnp_utils.dpnp_utils_linearalgebra import (
dpnp_dot,
Expand All @@ -64,6 +66,17 @@
]


# TODO: implement a specific scalar-array kernel
def _call_multiply(a, b, out=None):
"""Call multiply function for special cases of scalar-array dots."""

sc, arr = (a, b) if dpnp.isscalar(a) else (b, a)
sc_dtype = map_dtype_to_device(type(sc), arr.sycl_device)
res_dtype = dpnp.result_type(sc_dtype, arr)
res = dpnp.multiply(a, b, dtype=res_dtype)
return dpnp.get_result_array(res, out, casting="no")


def dot(a, b, out=None):
"""
Dot product of `a` and `b`.
Expand Down Expand Up @@ -137,8 +150,7 @@ def dot(a, b, out=None):
raise ValueError("Only C-contiguous array is acceptable.")

if dpnp.isscalar(a) or dpnp.isscalar(b):
# TODO: use specific scalar-vector kernel
return dpnp.multiply(a, b, out=out)
return _call_multiply(a, b, out=out)

a_ndim = a.ndim
b_ndim = b.ndim
Expand Down Expand Up @@ -627,8 +639,7 @@ def inner(a, b):
dpnp.check_supported_arrays_type(a, b, scalar_type=True)

if dpnp.isscalar(a) or dpnp.isscalar(b):
# TODO: use specific scalar-vector kernel
return dpnp.multiply(a, b)
return _call_multiply(a, b)

if a.ndim == 0 or b.ndim == 0:
# TODO: use specific scalar-vector kernel
Expand Down Expand Up @@ -706,8 +717,7 @@ def kron(a, b):
dpnp.check_supported_arrays_type(a, b, scalar_type=True)

if dpnp.isscalar(a) or dpnp.isscalar(b):
# TODO: use specific scalar-vector kernel
return dpnp.multiply(a, b)
return _call_multiply(a, b)

a_ndim = a.ndim
b_ndim = b.ndim
Expand Down Expand Up @@ -1043,8 +1053,7 @@ def tensordot(a, b, axes=2):
raise ValueError(
"One of the inputs is scalar, axes should be zero."
)
# TODO: use specific scalar-vector kernel
return dpnp.multiply(a, b)
return _call_multiply(a, b)

return dpnp_tensordot(a, b, axes=axes)

Expand Down Expand Up @@ -1107,13 +1116,13 @@ def vdot(a, b):
if b.size != 1:
raise ValueError("The second array should be of size one.")
a_conj = numpy.conj(a)
return dpnp.multiply(a_conj, b)
return _call_multiply(a_conj, b)

if dpnp.isscalar(b):
if a.size != 1:
raise ValueError("The first array should be of size one.")
a_conj = dpnp.conj(a)
return dpnp.multiply(a_conj, b)
return _call_multiply(a_conj, b)

if a.ndim == 1 and b.ndim == 1:
return dpnp_dot(a, b, out=None, conjugate=True)
Expand Down
4 changes: 2 additions & 2 deletions dpnp/dpnp_iface_nanfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ def nanstd(
ddof : {int, float}, optional
Means Delta Degrees of Freedom. The divisor used in calculations
is ``N - ddof``, where ``N`` the number of non-NaN elements.
Default: `0.0`.
Default: ``0.0``.
keepdims : {None, bool}, optional
If ``True``, the reduced axes (dimensions) are included in the result
as singleton dimensions, so that the returned array remains
Expand Down Expand Up @@ -1087,7 +1087,7 @@ def nanvar(
ddof : {int, float}, optional
Means Delta Degrees of Freedom. The divisor used in calculations
is ``N - ddof``, where ``N`` represents the number of non-NaN elements.
Default: `0.0`.
Default: ``0.0``.
keepdims : {None, bool}, optional
If ``True``, the reduced axes (dimensions) are included in the result
as singleton dimensions, so that the returned array remains
Expand Down
5 changes: 4 additions & 1 deletion dpnp/fft/dpnp_utils_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@ def _copy_array(x, complex_input):
# r2c FFT, if input is integer or float16 dtype, convert to
# float32 or float64 depending on device capabilities
copy_flag = True
dtype = map_dtype_to_device(dpnp.float64, x.sycl_device)
if dtype in [dpnp.float16]:
dtype = dpnp.float32
else:
dtype = map_dtype_to_device(dpnp.float64, x.sycl_device)

if copy_flag:
x_copy = dpnp.empty_like(x, dtype=dtype, order="C")
Expand Down
32 changes: 16 additions & 16 deletions dpnp/tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,19 @@ def assert_dtype_allclose(
assert dpnp_arr.dtype == numpy_arr.dtype


def get_integer_dtypes():
def get_integer_dtypes(no_unsigned=False):
"""
Build a list of integer types supported by DPNP.
"""

dtypes = [dpnp.int32, dpnp.int64]

if config.all_int_types:
return [
dpnp.int8,
dpnp.int16,
dpnp.int32,
dpnp.int64,
dpnp.uint8,
dpnp.uint16,
dpnp.uint32,
dpnp.uint64,
]
dtypes += [dpnp.int8, dpnp.int16]
if not no_unsigned:
dtypes += [dpnp.uint8, dpnp.uint16, dpnp.uint32, dpnp.uint64]

return [dpnp.int32, dpnp.int64]
return dtypes


def get_complex_dtypes(device=None):
Expand Down Expand Up @@ -152,12 +147,14 @@ def get_all_dtypes(
no_float16=True,
no_complex=False,
no_none=False,
device=None,
xfail_dtypes=None,
exclude=None,
no_unsigned=False,
device=None,
):
"""
Build a list of types supported by DPNP based on input flags and device capabilities.
Build a list of types supported by DPNP based on
input flags and device capabilities.
"""

dev = dpctl.select_default_device() if device is None else device
Expand All @@ -166,7 +163,7 @@ def get_all_dtypes(
dtypes = [dpnp.bool] if not no_bool else []

# add integer types
dtypes.extend(get_integer_dtypes())
dtypes.extend(get_integer_dtypes(no_unsigned=no_unsigned))

# add floating types
dtypes.extend(get_float_dtypes(no_float16=no_float16, device=dev))
Expand Down Expand Up @@ -239,10 +236,13 @@ def generate_random_numpy_array(
seed_value = 42
numpy.random.seed(seed_value)

if numpy.issubdtype(dtype, numpy.unsignedinteger):
low = 0

# dtype=int is needed for 0d arrays
size = numpy.prod(shape, dtype=int)
a = numpy.random.uniform(low, high, size).astype(dtype)
if numpy.issubdtype(a.dtype, numpy.complexfloating):
if numpy.issubdtype(dtype, numpy.complexfloating):
a += 1j * numpy.random.uniform(low, high, size)

a = a.reshape(shape)
Expand Down
20 changes: 11 additions & 9 deletions dpnp/tests/test_amin_amax.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ def test_amax_amin(func, keepdims, dtype):
[[-2.0, 5.0], [-2, -1.2]],
[[1.0, -2.0], [5.0, -1.1]],
],
dtype=dtype,
)
if numpy.issubdtype(dtype, numpy.unsignedinteger):
a = numpy.abs(a)
a = a.astype(dtype)
ia = dpnp.array(a)

for axis in range(len(a)):
Expand All @@ -28,20 +30,20 @@ def test_amax_amin(func, keepdims, dtype):


def _get_min_max_input(type, shape):
size = 1
for i in range(len(shape)):
size *= shape[i]

size = numpy.prod(shape)
a = numpy.arange(size, dtype=type)
a[int(size / 2)] = size * size
a[int(size / 3)] = -(size * size)
a[int(size / 2)] = size + 5
if numpy.issubdtype(type, numpy.unsignedinteger):
a[int(size / 3)] = size
else:
a[int(size / 3)] = -(size + 5)

return a.reshape(shape)


@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True))
@pytest.mark.parametrize(
"shape", [(4,), (2, 3), (4, 5, 6)], ids=["(4,)", "(2,3)", "(4,5,6)"]
"shape", [(4,), (2, 3), (4, 5, 6)], ids=["(4,)", "(2, 3)", "(4, 5, 6)"]
)
def test_amax_diff_shape(dtype, shape):
a = _get_min_max_input(dtype, shape)
Expand All @@ -59,7 +61,7 @@ def test_amax_diff_shape(dtype, shape):

@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True))
@pytest.mark.parametrize(
"shape", [(4,), (2, 3), (4, 5, 6)], ids=["(4,)", "(2,3)", "(4,5,6)"]
"shape", [(4,), (2, 3), (4, 5, 6)], ids=["(4,)", "(2, 3)", "(4, 5, 6)"]
)
def test_amin_diff_shape(dtype, shape):
a = _get_min_max_input(dtype, shape)
Expand Down
14 changes: 8 additions & 6 deletions dpnp/tests/test_arraycreation.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,12 @@ def test_exception_subok(func, args):
"dtype", get_all_dtypes(no_bool=True, no_float16=False)
)
def test_arange(start, stop, step, dtype):
rtol_mult = 2
if dpnp.issubdtype(dtype, dpnp.float16):
# numpy casts to float32 type when computes float16 data
rtol_mult = 4
if numpy.issubdtype(dtype, numpy.unsignedinteger):
start = abs(start)
stop = abs(stop) if stop else None

# numpy casts to float32 type when computes float16 data
rtol_mult = 4 if dpnp.issubdtype(dtype, dpnp.float16) else 2

func = lambda xp: xp.arange(start, stop=stop, step=step, dtype=dtype)

Expand Down Expand Up @@ -701,7 +703,7 @@ def test_dpctl_tensor_input(func, args):


@pytest.mark.parametrize("start", [0, -5, 10, -2.5, 9.7])
@pytest.mark.parametrize("stop", [0, 10, -2, 20.5, 1000])
@pytest.mark.parametrize("stop", [0, 10, -2, 20.5, 120])
@pytest.mark.parametrize(
"num",
[1, 5, numpy.array(10), dpnp.array(17), dpt.asarray(100)],
Expand Down Expand Up @@ -850,7 +852,7 @@ def test_space_num_error():
@pytest.mark.parametrize("endpoint", [True, False])
def test_geomspace(sign, dtype, num, endpoint):
start = 2 * sign
stop = 256 * sign
stop = 127 * sign

func = lambda xp: xp.geomspace(
start, stop, num, endpoint=endpoint, dtype=dtype
Expand Down
3 changes: 2 additions & 1 deletion dpnp/tests/test_bitwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ def test_bitwise_aliase2(self, lhs, rhs, dtype):

@pytest.mark.parametrize("dtype", get_integer_dtypes())
def test_invert_out(dtype):
np_a = numpy.arange(-5, 5, dtype=dtype)
low = 0 if numpy.issubdtype(dtype, numpy.unsignedinteger) else -5
np_a = numpy.arange(low, 5, dtype=dtype)
dp_a = inp.array(np_a)

expected = numpy.invert(np_a)
Expand Down
5 changes: 4 additions & 1 deletion dpnp/tests/test_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,10 @@ def test_rfft_1D(self, dtype, n, norm):

result = dpnp.fft.rfft(a, n=n, norm=norm)
expected = numpy.fft.rfft(a_np, n=n, norm=norm)
assert_dtype_allclose(result, expected, check_only_type_kind=True)
factor = 120 if dtype in [dpnp.int8, dpnp.uint8] else 8
assert_dtype_allclose(
result, expected, factor=factor, check_only_type_kind=True
)

@pytest.mark.parametrize("n", [None, 5, 20])
@pytest.mark.parametrize("norm", [None, "backward", "forward", "ortho"])
Expand Down
Loading
Loading