Skip to content

Commit 71e7d82

Browse files
authored
Extend tests scope for dpnp.bitwise count (#2618)
The PR aligns with the latest changes and updates third party tests scope.
1 parent e188991 commit 71e7d82

File tree

4 files changed

+63
-5
lines changed

4 files changed

+63
-5
lines changed

dpnp/tests/third_party/cupy/binary_tests/test_elementwise.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import unittest
24

35
from dpnp.tests.third_party.cupy import testing
@@ -27,6 +29,38 @@ def test_bitwise_or(self):
2729
def test_bitwise_xor(self):
2830
self.check_binary_int("bitwise_xor")
2931

32+
@testing.with_requires("numpy>=2.0.0")
33+
@testing.for_int_dtypes(no_bool=True)
34+
@testing.numpy_cupy_array_equal()
35+
def test_bitwise_count(self, xp, dtype):
36+
info = xp.iinfo(dtype)
37+
if xp.issubdtype(dtype, xp.signedinteger):
38+
a = xp.array(
39+
[
40+
0,
41+
-1,
42+
1,
43+
info.min,
44+
info.min + 1,
45+
info.max,
46+
info.max - 1,
47+
info.max // 2,
48+
],
49+
dtype=dtype,
50+
)
51+
else:
52+
a = xp.array(
53+
[
54+
0,
55+
1,
56+
info.max,
57+
info.max - 1,
58+
info.max // 2,
59+
],
60+
dtype=dtype,
61+
)
62+
return xp.bitwise_count(a)
63+
3064
def test_invert(self):
3165
self.check_unary_int("invert")
3266

dpnp/tests/third_party/cupy/core_tests/test_core.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import sys
24
import unittest
35

@@ -97,7 +99,7 @@ def test_cupy_ndarray(self, dtype):
9799
@testing.parameterize(
98100
*testing.product(
99101
{
100-
"cxx": (None, "--std=c++11"),
102+
"cxx": (None, "--std=c++14"),
101103
}
102104
)
103105
)

dpnp/tests/third_party/cupy/core_tests/test_function.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from __future__ import annotations
2+
13
import unittest
24

3-
import numpy
45
import pytest
56

67
import dpnp as cupy
@@ -18,9 +19,7 @@
1819
def _compile_func(kernel_name, code):
1920
# workaround for hipRTC
2021
extra_source = core._get_header_source() if runtime.is_hip else None
21-
mod = compiler._compile_module_with_cache(
22-
code, options=("--std=c++11",), extra_source=extra_source
23-
)
22+
mod = compiler._compile_module_with_cache(code, extra_source=extra_source)
2423
return mod.get_function(kernel_name)
2524

2625

dpnp/tests/third_party/cupy/functional_tests/test_vectorize.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import unittest
24

35
import numpy
@@ -8,9 +10,24 @@
810

911
# from cupy.cuda import runtime
1012

13+
14+
# def _rocm_version_major():
15+
# if not getattr(runtime, "is_hip", False):
16+
# return -1
17+
18+
# version = runtime.runtimeGetVersion()
19+
# major = version // 10_000_000
20+
# return int(major)
21+
22+
23+
# _ROCM_VER_MAJOR = _rocm_version_major()
24+
# _IS_HIP_LT7 = bool(_ROCM_VER_MAJOR != -1 and int(_ROCM_VER_MAJOR) < 7)
25+
26+
1127
pytest.skip("dpnp.vectorize is not implemented", allow_module_level=True)
1228

1329

30+
# @pytest.mark.skipif(_IS_HIP_LT7, reason="Skip on ROCm < 7 (HIP).")
1431
class TestVectorizeOps(unittest.TestCase):
1532

1633
def _run(self, func, xp, dtypes):
@@ -225,6 +242,7 @@ def my_usub(x):
225242
return self._run(my_usub, xp, [dtype])
226243

227244

245+
# @pytest.mark.skipif(_IS_HIP_LT7, reason="Skip on ROCm < 7 (HIP).")
228246
class TestVectorizeExprs(unittest.TestCase):
229247

230248
@testing.for_all_dtypes(name="cond_dtype", no_complex=True)
@@ -293,6 +311,7 @@ def my_typecast(x):
293311
return f(x)
294312

295313

314+
# @pytest.mark.skipif(_IS_HIP_LT7, reason="Skip on ROCm < 7 (HIP).")
296315
class TestVectorizeInstructions(unittest.TestCase):
297316

298317
@testing.for_all_dtypes()
@@ -371,6 +390,7 @@ def my_nonconst_result(x):
371390
return f(x)
372391

373392

393+
# @pytest.mark.skipif(_IS_HIP_LT7, reason="Skip on ROCm < 7 (HIP).")
374394
class TestVectorizeStmts(unittest.TestCase):
375395

376396
@testing.numpy_cupy_array_equal()
@@ -567,6 +587,7 @@ def __init__(self, x):
567587
self.x = x
568588

569589

590+
# @pytest.mark.skipif(_IS_HIP_LT7, reason="Skip on ROCm < 7 (HIP).")
570591
class TestVectorizeConstants(unittest.TestCase):
571592

572593
@testing.numpy_cupy_array_equal()
@@ -594,6 +615,7 @@ def my_func(x1, x2):
594615
return f(x1, x2)
595616

596617

618+
# @pytest.mark.skipif(_IS_HIP_LT7, reason="Skip on ROCm < 7 (HIP).")
597619
class TestVectorizeBroadcast(unittest.TestCase):
598620

599621
@testing.for_all_dtypes(no_bool=True)
@@ -630,6 +652,7 @@ def my_func(x1, x2):
630652
return f(x1, x2)
631653

632654

655+
# @pytest.mark.skipif(_IS_HIP_LT7, reason="Skip on ROCm < 7 (HIP).")
633656
class TestVectorize(unittest.TestCase):
634657

635658
@testing.for_all_dtypes(no_bool=True)

0 commit comments

Comments
 (0)