diff --git a/dpnp/tests/conftest.py b/dpnp/tests/conftest.py index a0a76e3edb4e..a22eff8c914b 100644 --- a/dpnp/tests/conftest.py +++ b/dpnp/tests/conftest.py @@ -41,6 +41,8 @@ import dpnp +from .helper import get_dev_id + skip_mark = pytest.mark.skip(reason="Skipping test.") @@ -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}") diff --git a/dpnp/tests/helper.py b/dpnp/tests/helper.py index f1222b4c2a2e..edb077a161c2 100644 --- a/dpnp/tests/helper.py +++ b/dpnp/tests/helper.py @@ -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( @@ -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, @@ -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) @@ -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. @@ -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): @@ -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(): diff --git a/dpnp/tests/test_arraycreation.py b/dpnp/tests/test_arraycreation.py index 336162582928..8e4553dcbe4e 100644 --- a/dpnp/tests/test_arraycreation.py +++ b/dpnp/tests/test_arraycreation.py @@ -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 @@ -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]