From 738df73ae3f3f548cd113baea8e774f41bf3908a Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 9 Oct 2025 16:20:43 +0200 Subject: [PATCH 1/3] Add third party test for bitwise_count --- .../cupy/binary_tests/test_elementwise.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/dpnp/tests/third_party/cupy/binary_tests/test_elementwise.py b/dpnp/tests/third_party/cupy/binary_tests/test_elementwise.py index 452314802309..431f1f27d8c7 100644 --- a/dpnp/tests/third_party/cupy/binary_tests/test_elementwise.py +++ b/dpnp/tests/third_party/cupy/binary_tests/test_elementwise.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import unittest from dpnp.tests.third_party.cupy import testing @@ -27,6 +29,38 @@ def test_bitwise_or(self): def test_bitwise_xor(self): self.check_binary_int("bitwise_xor") + @testing.with_requires("numpy>=2.0.0") + @testing.for_int_dtypes(no_bool=True) + @testing.numpy_cupy_array_equal() + def test_bitwise_count(self, xp, dtype): + info = xp.iinfo(dtype) + if xp.issubdtype(dtype, xp.signedinteger): + a = xp.array( + [ + 0, + -1, + 1, + info.min, + info.min + 1, + info.max, + info.max - 1, + info.max // 2, + ], + dtype=dtype, + ) + else: + a = xp.array( + [ + 0, + 1, + info.max, + info.max - 1, + info.max // 2, + ], + dtype=dtype, + ) + return xp.bitwise_count(a) + def test_invert(self): self.check_unary_int("invert") From b316e6f1e29d3ce5e6e54d532543c2a56bb0e320 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Thu, 9 Oct 2025 16:22:10 +0200 Subject: [PATCH 2/3] Add small updates in the thrid party tests to reduce diff to the latest content --- .../third_party/cupy/core_tests/test_core.py | 4 +++- .../cupy/core_tests/test_function.py | 7 +++--- .../cupy/functional_tests/test_vectorize.py | 22 ++++++++++++++++++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/dpnp/tests/third_party/cupy/core_tests/test_core.py b/dpnp/tests/third_party/cupy/core_tests/test_core.py index bf0cbecb24c8..9bcf5ae721c9 100644 --- a/dpnp/tests/third_party/cupy/core_tests/test_core.py +++ b/dpnp/tests/third_party/cupy/core_tests/test_core.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import sys import unittest @@ -97,7 +99,7 @@ def test_cupy_ndarray(self, dtype): @testing.parameterize( *testing.product( { - "cxx": (None, "--std=c++11"), + "cxx": (None, "--std=c++14"), } ) ) diff --git a/dpnp/tests/third_party/cupy/core_tests/test_function.py b/dpnp/tests/third_party/cupy/core_tests/test_function.py index 315dcbd09674..2943fc2bcf02 100644 --- a/dpnp/tests/third_party/cupy/core_tests/test_function.py +++ b/dpnp/tests/third_party/cupy/core_tests/test_function.py @@ -1,6 +1,7 @@ +from __future__ import annotations + import unittest -import numpy import pytest import dpnp as cupy @@ -18,9 +19,7 @@ def _compile_func(kernel_name, code): # workaround for hipRTC extra_source = core._get_header_source() if runtime.is_hip else None - mod = compiler._compile_module_with_cache( - code, options=("--std=c++11",), extra_source=extra_source - ) + mod = compiler._compile_module_with_cache(code, extra_source=extra_source) return mod.get_function(kernel_name) diff --git a/dpnp/tests/third_party/cupy/functional_tests/test_vectorize.py b/dpnp/tests/third_party/cupy/functional_tests/test_vectorize.py index 910ab2dc0aa1..9dfff95207ba 100644 --- a/dpnp/tests/third_party/cupy/functional_tests/test_vectorize.py +++ b/dpnp/tests/third_party/cupy/functional_tests/test_vectorize.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import unittest import numpy @@ -8,9 +10,21 @@ # from cupy.cuda import runtime -pytest.skip("dpnp.vectorize is not implemented", allow_module_level=True) + +# def _rocm_version_major(): +# if not getattr(runtime, "is_hip", False): +# return -1 + +# version = runtime.runtimeGetVersion() +# major = version // 10_000_000 +# return int(major) + + +# _ROCM_VER_MAJOR = _rocm_version_major() +# _IS_HIP_LT7 = bool(_ROCM_VER_MAJOR != -1 and int(_ROCM_VER_MAJOR) < 7) +# @pytest.mark.skipif(_IS_HIP_LT7, reason="Skip on ROCm < 7 (HIP).") class TestVectorizeOps(unittest.TestCase): def _run(self, func, xp, dtypes): @@ -225,6 +239,7 @@ def my_usub(x): return self._run(my_usub, xp, [dtype]) +# @pytest.mark.skipif(_IS_HIP_LT7, reason="Skip on ROCm < 7 (HIP).") class TestVectorizeExprs(unittest.TestCase): @testing.for_all_dtypes(name="cond_dtype", no_complex=True) @@ -293,6 +308,7 @@ def my_typecast(x): return f(x) +# @pytest.mark.skipif(_IS_HIP_LT7, reason="Skip on ROCm < 7 (HIP).") class TestVectorizeInstructions(unittest.TestCase): @testing.for_all_dtypes() @@ -371,6 +387,7 @@ def my_nonconst_result(x): return f(x) +# @pytest.mark.skipif(_IS_HIP_LT7, reason="Skip on ROCm < 7 (HIP).") class TestVectorizeStmts(unittest.TestCase): @testing.numpy_cupy_array_equal() @@ -567,6 +584,7 @@ def __init__(self, x): self.x = x +# @pytest.mark.skipif(_IS_HIP_LT7, reason="Skip on ROCm < 7 (HIP).") class TestVectorizeConstants(unittest.TestCase): @testing.numpy_cupy_array_equal() @@ -594,6 +612,7 @@ def my_func(x1, x2): return f(x1, x2) +# @pytest.mark.skipif(_IS_HIP_LT7, reason="Skip on ROCm < 7 (HIP).") class TestVectorizeBroadcast(unittest.TestCase): @testing.for_all_dtypes(no_bool=True) @@ -630,6 +649,7 @@ def my_func(x1, x2): return f(x1, x2) +# @pytest.mark.skipif(_IS_HIP_LT7, reason="Skip on ROCm < 7 (HIP).") class TestVectorize(unittest.TestCase): @testing.for_all_dtypes(no_bool=True) From dda5ce895a4556d08eedaf508c8358e72ee1953e Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Fri, 10 Oct 2025 11:27:31 +0200 Subject: [PATCH 3/3] Skip tests back for dpnp.vectorize --- dpnp/tests/third_party/cupy/functional_tests/test_vectorize.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dpnp/tests/third_party/cupy/functional_tests/test_vectorize.py b/dpnp/tests/third_party/cupy/functional_tests/test_vectorize.py index 9dfff95207ba..74bfedda505e 100644 --- a/dpnp/tests/third_party/cupy/functional_tests/test_vectorize.py +++ b/dpnp/tests/third_party/cupy/functional_tests/test_vectorize.py @@ -24,6 +24,9 @@ # _IS_HIP_LT7 = bool(_ROCM_VER_MAJOR != -1 and int(_ROCM_VER_MAJOR) < 7) +pytest.skip("dpnp.vectorize is not implemented", allow_module_level=True) + + # @pytest.mark.skipif(_IS_HIP_LT7, reason="Skip on ROCm < 7 (HIP).") class TestVectorizeOps(unittest.TestCase):