Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dpnp/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@

import dpnp

from .helper import get_dev_id

skip_mark = pytest.mark.skip(reason="Skipping test.")


Expand Down Expand Up @@ -138,6 +140,7 @@ def pytest_collection_modifyitems(config, items):
print(
f"DPNP Test scope includes all integer dtypes: {bool(dtype_config.all_int_types)}"
)
print(f"DPNP current device ID: 0x{get_dev_id(dev):04X}")
print(f"DPNP current device is CPU: {is_cpu}")
print(f"DPNP current device is GPU: {is_gpu}")
print(f"DPNP current device supports fp64: {support_fp64}")
Expand Down
58 changes: 37 additions & 21 deletions dpnp/tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ def _assert_shape(a, b):


def _get_dev_mask(device=None):
dev = dpctl.select_default_device() if device is None else device
dev_info = dpctl.utils.intel_device_info(dev)
return dev_info.get("device_id", 0) & 0xFF00
return get_dev_id(device) & 0xFF00


def assert_dtype_allclose(
Expand Down Expand Up @@ -110,6 +108,19 @@ def assert_dtype_allclose(
_assert_dtype(dpnp_arr.dtype, numpy_arr.dtype, check_only_type_kind)


def factor_to_tol(dtype, factor):
"""
Calculate the tolerance for comparing floating point and complex arrays.
The tolerance is based on the maximum resolution of the input dtype multiplied by the factor.
"""

tol = 0
if numpy.issubdtype(dtype, numpy.inexact):
tol = numpy.finfo(dtype).resolution

return factor * tol


def generate_random_numpy_array(
shape,
dtype=None,
Expand Down Expand Up @@ -208,19 +219,6 @@ def generate_random_numpy_array(
return a


def factor_to_tol(dtype, factor):
"""
Calculate the tolerance for comparing floating point and complex arrays.
The tolerance is based on the maximum resolution of the input dtype multiplied by the factor.
"""

tol = 0
if numpy.issubdtype(dtype, numpy.inexact):
tol = numpy.finfo(dtype).resolution

return factor * tol


def get_abs_array(data, dtype=None):
if numpy.issubdtype(dtype, numpy.unsignedinteger):
data = numpy.abs(data)
Expand Down Expand Up @@ -305,6 +303,16 @@ def get_complex_dtypes(device=None):
return dtypes


def get_dev_id(device=None):
"""
Obtain Intel Device ID for a device (the default device if not provided).
"""

dev = dpctl.select_default_device() if device is None else device
dev_info = dpctl.utils.intel_device_info(dev)
return dev_info.get("device_id", 0)


def get_float_dtypes(no_float16=True, device=None):
"""
Build a list of floating types supported by DPNP based on device capabilities.
Expand Down Expand Up @@ -456,11 +464,11 @@ def is_intel_numpy():
return all(dep["name"].startswith("mkl") for dep in [blas, lapack])


def is_iris_xe(device=None):
def is_lnl(device=None):
"""
Return True if a test is running on Iris Xe GPU device, False otherwise.
Return True if a test is running on Lunar Lake GPU device, False otherwise.
"""
return _get_dev_mask(device) == 0x9A00
return _get_dev_mask(device) == 0x6400


def is_lts_driver(device=None):
Expand All @@ -474,10 +482,18 @@ def is_lts_driver(device=None):

def is_ptl(device=None):
"""
Return True if a test is running on Panther Lake with Iris Xe3 GPU device,
Return True if a test is running on Panther Lake with Iris Xe3 GPU device
(which includes PTL-U, PTL-H and WCL), False otherwise.
"""
return _get_dev_mask(device) in (0xB000, 0xFD00)


def is_tgllp_iris_xe(device=None):
"""
Return True if a test is running on Tiger Lake-LP with Iris Xe GPU device,
False otherwise.
"""
return _get_dev_mask(device) == 0xB000
return get_dev_id(device) in (0x9A49, 0x9A40)


def is_win_platform():
Expand Down
4 changes: 2 additions & 2 deletions dpnp/tests/test_arraycreation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
assert_dtype_allclose,
get_all_dtypes,
get_array,
is_iris_xe,
is_lts_driver,
is_tgllp_iris_xe,
is_win_platform,
)
from .third_party.cupy import testing
Expand Down Expand Up @@ -916,7 +916,7 @@ def test_geomspace_num0():
@pytest.mark.parametrize("num", [2, 4, 8, 3, 9, 27])
@pytest.mark.parametrize("endpoint", [True, False])
def test_logspace(dtype, num, endpoint):
if not is_win_platform() and is_iris_xe() and is_lts_driver():
if not is_win_platform() and is_tgllp_iris_xe() and is_lts_driver():
if (
dpnp.issubdtype(dtype, dpnp.integer)
and num in [8, 27]
Expand Down
Loading