From 9e97a254f78a25bedcf9970d82ebe7ac8d28f36f Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 15 May 2025 06:36:23 -0500 Subject: [PATCH 1/3] Correct the expected result in spacing test --- dpnp/tests/helper.py | 16 ++++++++++++++++ dpnp/tests/test_mathematical.py | 7 ++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/dpnp/tests/helper.py b/dpnp/tests/helper.py index 32f4d392fb5a..ba111b8348e0 100644 --- a/dpnp/tests/helper.py +++ b/dpnp/tests/helper.py @@ -414,6 +414,22 @@ def is_gpu_device(device=None): return dev.has_aspect_gpu +def is_intel_numpy(): + """ + Return True if Intel NumPy is used during testing. + + The check is based on MKL backend name stored in Build Dependencies, where + in case of Intel Numpy there "mkl-dynamic" is expected to be a part of the + name for both BLAS and LAPACK (the full name is "mkl-dynamic-ilp64-iomp"). + + """ + + build_deps = numpy.show_config(mode="dicts")["Build Dependencies"] + blas = build_deps["blas"] + lapack = build_deps["lapack"] + return all("mkl-dynamic" in dep["name"] for dep in [blas, lapack]) + + def is_win_platform(): """ Return True if a test is running on Windows OS, False otherwise. diff --git a/dpnp/tests/test_mathematical.py b/dpnp/tests/test_mathematical.py index 3aef83d317d9..bd15b4ca7281 100644 --- a/dpnp/tests/test_mathematical.py +++ b/dpnp/tests/test_mathematical.py @@ -32,6 +32,7 @@ get_integer_float_dtypes, has_support_aspect16, has_support_aspect64, + is_intel_numpy, numpy_version, ) from .third_party.cupy import testing @@ -1751,11 +1752,11 @@ def test_zeros(self, dt): result = dpnp.spacing(ia) expected = numpy.spacing(a) - if numpy_version() < "2.0.0": + if is_intel_numpy(): assert_allclose(result, expected) else: - # numpy.spacing(-0.0) == numpy.spacing(0.0), i.e. NumPy returns - # positive value (looks as a bug in NumPy), because for any other + # numpy.spacing(-0.0) == numpy.spacing(0.0), i.e. the stock NumPy + # returns positive value (looks as a bug), because for any other # negative input the NumPy result will be also a negative value. expected[1] *= -1 assert_allclose(result, expected) From 5515e01f03eca4804116ea5226002885ad026cb7 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 15 May 2025 14:42:48 +0200 Subject: [PATCH 2/3] Add special handling for numpy 1.26.4 --- dpnp/tests/helper.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dpnp/tests/helper.py b/dpnp/tests/helper.py index ba111b8348e0..1f0e695c1d1a 100644 --- a/dpnp/tests/helper.py +++ b/dpnp/tests/helper.py @@ -427,6 +427,10 @@ def is_intel_numpy(): build_deps = numpy.show_config(mode="dicts")["Build Dependencies"] blas = build_deps["blas"] lapack = build_deps["lapack"] + + if numpy_version() < "2.0.0": + # numpy 1.26.4 has LAPACK name equals to 'dep140030038112336' + return "mkl-dynamic" in blas["name"] return all("mkl-dynamic" in dep["name"] for dep in [blas, lapack]) From 1871ca308011c6bd4068cae1a5b8cb6be069120b Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 15 May 2025 17:24:10 +0200 Subject: [PATCH 3/3] BLAS name on Windows in numpy 1.26.4 = 'mkl' --- dpnp/tests/helper.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dpnp/tests/helper.py b/dpnp/tests/helper.py index 1f0e695c1d1a..1f5365220595 100644 --- a/dpnp/tests/helper.py +++ b/dpnp/tests/helper.py @@ -419,8 +419,8 @@ def is_intel_numpy(): Return True if Intel NumPy is used during testing. The check is based on MKL backend name stored in Build Dependencies, where - in case of Intel Numpy there "mkl-dynamic" is expected to be a part of the - name for both BLAS and LAPACK (the full name is "mkl-dynamic-ilp64-iomp"). + in case of Intel Numpy there "mkl" is expected at the beginning of the name + for both BLAS and LAPACK (the full name is "mkl-dynamic-ilp64-iomp"). """ @@ -430,8 +430,8 @@ def is_intel_numpy(): if numpy_version() < "2.0.0": # numpy 1.26.4 has LAPACK name equals to 'dep140030038112336' - return "mkl-dynamic" in blas["name"] - return all("mkl-dynamic" in dep["name"] for dep in [blas, lapack]) + return blas["name"].startswith("mkl") + return all(dep["name"].startswith("mkl") for dep in [blas, lapack]) def is_win_platform():