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
32 changes: 22 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,20 @@
]


# 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)
if out is not None and out.dtype == arr.dtype:
res = dpnp.multiply(a, b, out=out)
else:
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 +153,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 +642,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 +720,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 +1056,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 +1119,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 == 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
55 changes: 37 additions & 18 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 @@ -147,17 +142,25 @@ def get_float_complex_dtypes(no_float16=True, device=None):
return dtypes


def get_abs_array(data, dtype=None):
if numpy.issubdtype(dtype, numpy.unsignedinteger):
data = numpy.abs(data)
return numpy.array(data, dtype=dtype)


def get_all_dtypes(
no_bool=False,
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 +169,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 @@ -194,7 +197,13 @@ def not_excluded(dtype):


def generate_random_numpy_array(
shape, dtype=None, hermitian=False, seed_value=None, low=-10, high=10
shape,
dtype=None,
order="C",
hermitian=False,
seed_value=None,
low=-10,
high=10,
):
"""
Generate a random numpy array with the specified shape and dtype.
Expand All @@ -210,6 +219,9 @@ def generate_random_numpy_array(
Desired data-type for the output array.
If not specified, data type will be determined by numpy.
Default : ``None``
order : {"C", "F"}, optional
Specify the memory layout of the output array.
Default: ``"C"``.
hermitian : bool, optional
If True, generates a Hermitian (symmetric if `dtype` is real) matrix.
Default : ``False``
Expand All @@ -226,7 +238,7 @@ def generate_random_numpy_array(
Returns
-------
out : numpy.ndarray
A random numpy array of the specified shape and dtype.
A random numpy array of the specified shape, dtype and memory layout.
The array is Hermitian or symmetric if `hermitian` is True.

Note:
Expand All @@ -239,10 +251,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 All @@ -256,6 +271,10 @@ def generate_random_numpy_array(
a = a.reshape(orig_shape)
else:
a = numpy.conj(a.T) @ a

# a.reshape(shape) returns an array in C order by default
if order != "C" and a.ndim > 1:
a = numpy.array(a, order=order)
return a


Expand Down
Loading
Loading