Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Updated third party tests
  • Loading branch information
antonwolfy committed Jul 31, 2024
commit f038eacb9687bdc2a1e3b816d078a8023d97eb39
1 change: 0 additions & 1 deletion tests/skipped_tests.tbl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ tests/test_umath.py::test_umaths[('divmod', 'ii')]
tests/test_umath.py::test_umaths[('divmod', 'll')]
tests/test_umath.py::test_umaths[('divmod', 'ff')]
tests/test_umath.py::test_umaths[('divmod', 'dd')]
tests/test_umath.py::test_umaths[('float_power', 'dd')]
tests/test_umath.py::test_umaths[('frexp', 'f')]
tests/test_umath.py::test_umaths[('frexp', 'd')]
tests/test_umath.py::test_umaths[('gcd', 'ii')]
Expand Down
2 changes: 0 additions & 2 deletions tests/skipped_tests_gpu.tbl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ tests/test_umath.py::test_umaths[('divmod', 'ii')]
tests/test_umath.py::test_umaths[('divmod', 'll')]
tests/test_umath.py::test_umaths[('divmod', 'ff')]
tests/test_umath.py::test_umaths[('divmod', 'dd')]
tests/test_umath.py::test_umaths[('float_power', 'dd')]
tests/test_umath.py::test_umaths[('floor_divide', 'ff')]
tests/test_umath.py::test_umaths[('frexp', 'f')]
tests/test_umath.py::test_umaths[('frexp', 'd')]
tests/test_umath.py::test_umaths[('gcd', 'ii')]
Expand Down
30 changes: 26 additions & 4 deletions tests/third_party/cupy/math_tests/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"subtract",
"true_divide",
"floor_divide",
"float_power",
"fmod",
"remainder",
],
Expand Down Expand Up @@ -260,7 +261,7 @@ def check_binary(self, xp):
if xp.isscalar(arg1) and xp.isscalar(arg2):
pytest.skip("both scalar inputs is not supported")

if self.name == "power":
if self.name == "power" or self.name == "float_power":
# TODO(niboshi): Fix this: power(0, 1j)
# numpy => 1+0j
# cupy => 0j
Expand Down Expand Up @@ -302,17 +303,38 @@ def check_binary(self, xp):
with warnings.catch_warnings():
warnings.filterwarnings("ignore")
if self.use_dtype:
if (
xp is numpy
and self.name == "float_power"
and self.dtype == numpy.float32
):
# numpy.float_power does not have a loop for float32,
# while dpnp.float_power does
self.dtype = numpy.float64
y = func(arg1, arg2, dtype=self.dtype)
else:
y = func(arg1, arg2)

# TODO(niboshi): Fix this. If rhs is a Python complex,
# numpy returns complex64
# cupy returns complex128
if xp is cupy and isinstance(arg2, complex):
if (
xp is cupy
and isinstance(arg2, complex)
and self.name != "float_power"
):
if dtype1 in (numpy.float16, numpy.float32):
y = y.astype(numpy.complex64)

if xp is cupy and self.name == "float_power" and has_support_aspect64():
# numpy.float_power does not have a loop for float32 and complex64,
# and will upcast input array to float64 or complex128,
# while dpnp has to support float32 and complex64 to compatibility
# with devices without fp64 support
if y.dtype == cupy.float32:
y = y.astype(cupy.float64)
elif y.dtype == cupy.complex64:
y = y.astype(cupy.complex128)
return y


Expand All @@ -331,7 +353,7 @@ def check_binary(self, xp):
for d in all_types
]
+ [0, 0.0, 0j, 2, 2.0, 2j, True, False],
"name": ["add", "multiply", "power", "subtract"],
"name": ["add", "multiply", "power", "subtract", "float_power"],
}
)
+ testing.product(
Expand Down Expand Up @@ -405,7 +427,7 @@ def test_binary(self):
for d in float_types
]
+ [0.0, 2.0, -2.0],
"name": ["power", "true_divide", "subtract"],
"name": ["power", "true_divide", "subtract", "float_power"],
"dtype": [cupy.default_float_type()],
"use_dtype": [True, False],
}
Expand Down