diff --git a/tests/helper.py b/tests/helper.py index 17c62cecd289..142d4ace944c 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -1,5 +1,6 @@ import dpctl import dpnp +import pytest def get_all_dtypes(no_bool=False, @@ -37,3 +38,29 @@ def get_all_dtypes(no_bool=False, if not no_none: dtypes.append(None) return dtypes + + +def skip_or_check_if_dtype_not_supported(dtype, device=None, check_dtype=False): + """ + The function to check input type supported in DPNP based on the device capabilities. + """ + + dev = dpctl.select_default_device() if device is None else device + dev_has_dp = dev.has_aspect_fp64 + if dtype is dpnp.float64 and dev_has_dp is False: + if check_dtype: + return False + else: + pytest.skip( + f"{dev.name} does not support double precision floating point types" + ) + dev_has_hp = dev.has_aspect_fp16 + if dtype is dpnp.complex128 and dev_has_hp is False: + if check_dtype: + return False + else: + pytest.skip( + f"{dev.name} does not support double precision floating point types" + ) + + return True diff --git a/tests/test_absolute.py b/tests/test_absolute.py index aa145cc92023..cd9eedc795ef 100644 --- a/tests/test_absolute.py +++ b/tests/test_absolute.py @@ -1,15 +1,14 @@ import pytest +from .helper import get_all_dtypes import dpnp as inp import numpy -@pytest.mark.parametrize("type", - [numpy.int64], - ids=['int64']) -def test_abs_int(type): - a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9]) +@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) +def test_abs(dtype): + a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9], dtype=dtype) ia = inp.array(a) result = inp.abs(ia) @@ -17,11 +16,11 @@ def test_abs_int(type): numpy.testing.assert_array_equal(expected, result) -@pytest.mark.parametrize("type", - [numpy.int64], - ids=['int64']) -def test_absolute_int(type): - a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9]) +@pytest.mark.parametrize( + "dtype", get_all_dtypes(no_bool=True, no_none=True, no_complex=True) +) +def test_absolute(dtype): + a = numpy.array([[-2.0, 3.0, 9.1], [-2.0, 5.0, -2], [1.0, -2.0, 5.0]], dtype=dtype) ia = inp.array(a) result = inp.absolute(ia) @@ -29,23 +28,18 @@ def test_absolute_int(type): numpy.testing.assert_array_equal(expected, result) -@pytest.mark.parametrize("type", - [numpy.float64], - ids=['float64']) -def test_absolute_float(type): - a = numpy.array([[-2., 3., 9.1], [-2., 5.0, -2], [1.0, -2., 5.0]]) - ia = inp.array(a) - - result = inp.absolute(ia) - expected = numpy.absolute(a) - numpy.testing.assert_array_equal(expected, result) - - -@pytest.mark.parametrize("type", - [numpy.float64], - ids=['float64']) -def test_absolute_float_3(type): - a = numpy.array([[[-2., 3.], [9.1, 0.2]], [[-2., 5.0], [-2, -1.2]], [[1.0, -2.], [5.0, -1.1]]]) +@pytest.mark.parametrize( + "dtype", get_all_dtypes(no_bool=True, no_none=True, no_complex=True) +) +def test_absolute_float_3d(dtype): + a = numpy.array( + [ + [[-2.0, 3.0], [9.1, 0.2]], + [[-2.0, 5.0], [-2, -1.2]], + [[1.0, -2.0], [5.0, -1.1]], + ], + dtype=dtype, + ) ia = inp.array(a) result = inp.absolute(ia) diff --git a/tests/test_amin_amax.py b/tests/test_amin_amax.py index 442690cc15d3..b931026121f0 100644 --- a/tests/test_amin_amax.py +++ b/tests/test_amin_amax.py @@ -1,15 +1,23 @@ import pytest +from .helper import get_all_dtypes import dpnp import numpy -@pytest.mark.parametrize("type", - [numpy.float64], - ids=['float64']) -def test_amax_float64(type): - a = numpy.array([[[-2., 3.], [9.1, 0.2]], [[-2., 5.0], [-2, -1.2]], [[1.0, -2.], [5.0, -1.1]]]) +@pytest.mark.parametrize( + "dtype", get_all_dtypes(no_bool=True, no_none=True, no_complex=True) +) +def test_amax(dtype): + a = numpy.array( + [ + [[-2.0, 3.0], [9.1, 0.2]], + [[-2.0, 5.0], [-2, -1.2]], + [[1.0, -2.0], [5.0, -1.1]], + ], + dtype=dtype, + ) ia = dpnp.array(a) for axis in range(len(a)): @@ -18,23 +26,18 @@ def test_amax_float64(type): numpy.testing.assert_array_equal(expected, result) -@pytest.mark.parametrize("type", - [numpy.int64], - ids=['int64']) -def test_amax_int(type): - a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9]) - ia = dpnp.array(a) - - result = dpnp.amax(ia) - expected = numpy.amax(a) - numpy.testing.assert_array_equal(expected, result) - - -@pytest.mark.parametrize("type", - [numpy.float64], - ids=['float64']) -def test_amin_float64(type): - a = numpy.array([[[-2., 3.], [9.1, 0.2]], [[-2., 5.0], [-2, -1.2]], [[1.0, -2.], [5.0, -1.1]]]) +@pytest.mark.parametrize( + "dtype", get_all_dtypes(no_bool=True, no_none=True, no_complex=True) +) +def test_amin(dtype): + a = numpy.array( + [ + [[-2.0, 3.0], [9.1, 0.2]], + [[-2.0, 5.0], [-2, -1.2]], + [[1.0, -2.0], [5.0, -1.1]], + ], + dtype=dtype, + ) ia = dpnp.array(a) for axis in range(len(a)): @@ -43,18 +46,6 @@ def test_amin_float64(type): numpy.testing.assert_array_equal(expected, result) -@pytest.mark.parametrize("type", - [numpy.int64], - ids=['int64']) -def test_amin_int(type): - a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9]) - ia = dpnp.array(a) - - result = dpnp.amin(ia) - expected = numpy.amin(a) - numpy.testing.assert_array_equal(expected, result) - - def _get_min_max_input(type, shape): size = 1 for i in range(len(shape)): @@ -68,14 +59,14 @@ def _get_min_max_input(type, shape): @pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("type", - [numpy.float64, numpy.float32, numpy.int64, numpy.int32], - ids=['float64', 'float32', 'int64', 'int32']) -@pytest.mark.parametrize("shape", - [(4,), (2, 3), (4, 5, 6)], - ids=['(4,)', '(2,3)', '(4,5,6)']) -def test_amax(type, shape): - a = _get_min_max_input(type, shape) +@pytest.mark.parametrize( + "dtype", get_all_dtypes(no_bool=True, no_none=True, no_complex=True) +) +@pytest.mark.parametrize( + "shape", [(4,), (2, 3), (4, 5, 6)], ids=["(4,)", "(2,3)", "(4,5,6)"] +) +def test_amax_with_shape(dtype, shape): + a = _get_min_max_input(dtype, shape) ia = dpnp.array(a) @@ -89,14 +80,14 @@ def test_amax(type, shape): @pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("type", - [numpy.float64, numpy.float32, numpy.int64, numpy.int32], - ids=['float64', 'float32', 'int64', 'int32']) -@pytest.mark.parametrize("shape", - [(4,), (2, 3), (4, 5, 6)], - ids=['(4,)', '(2,3)', '(4,5,6)']) -def test_amin(type, shape): - a = _get_min_max_input(type, shape) +@pytest.mark.parametrize( + "dtype", get_all_dtypes(no_bool=True, no_none=True, no_complex=True) +) +@pytest.mark.parametrize( + "shape", [(4,), (2, 3), (4, 5, 6)], ids=["(4,)", "(2,3)", "(4,5,6)"] +) +def test_amin_with_shape(dtype, shape): + a = _get_min_max_input(dtype, shape) ia = dpnp.array(a) diff --git a/tests/test_arraycreation.py b/tests/test_arraycreation.py index 71e6a7b7d07d..7223a7caa12b 100644 --- a/tests/test_arraycreation.py +++ b/tests/test_arraycreation.py @@ -102,7 +102,7 @@ def test_eye(N, M, k, dtype, order): @pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) +@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False, no_none=True)) def test_frombuffer(dtype): buffer = b'12345678ABCDEF00' func = lambda xp: xp.frombuffer(buffer, dtype=dtype) diff --git a/tests/test_flat.py b/tests/test_flat.py index c5152559e408..77d6d13f425b 100644 --- a/tests/test_flat.py +++ b/tests/test_flat.py @@ -5,11 +5,9 @@ import numpy -@pytest.mark.parametrize("type", - [numpy.int64], - ids=['int64']) -def test_flat(type): - a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9]) +@pytest.mark.parametrize("dtype", [numpy.int64], ids=["int64"]) +def test_flat(dtype): + a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9], dtype=dtype) ia = inp.array(a) result = ia.flat[0] @@ -17,11 +15,9 @@ def test_flat(type): numpy.testing.assert_array_equal(expected, result) -@pytest.mark.parametrize("type", - [numpy.int64], - ids=['int64']) -def test_flat2(type): - a = numpy.arange(1, 7).reshape(2, 3) +@pytest.mark.parametrize("dtype", [numpy.int64], ids=["int64"]) +def test_flat2(dtype): + a = numpy.arange(1, 7, dtype=dtype).reshape(2, 3) ia = inp.array(a) result = ia.flat[3] @@ -29,11 +25,9 @@ def test_flat2(type): numpy.testing.assert_array_equal(expected, result) -@pytest.mark.parametrize("type", - [numpy.int64], - ids=['int64']) -def test_flat3(type): - a = numpy.arange(1, 7).reshape(2, 3).T +@pytest.mark.parametrize("dtype", [numpy.int64], ids=["int64"]) +def test_flat3(dtype): + a = numpy.arange(1, 7, dtype=dtype).reshape(2, 3).T ia = inp.array(a) result = ia.flat[3] diff --git a/tests/test_manipulation.py b/tests/test_manipulation.py index bb91f5d0d500..95be29cd978f 100644 --- a/tests/test_manipulation.py +++ b/tests/test_manipulation.py @@ -1,13 +1,27 @@ import pytest +from .helper import get_all_dtypes import numpy import dpnp +dtypes_list = get_all_dtypes(no_none=True, no_complex=True) testdata = [] -testdata += [([True, False, True], dtype) for dtype in ['float32', 'float64', 'int32', 'int64', 'bool']] -testdata += [([1, -1, 0], dtype) for dtype in ['float32', 'float64', 'int32', 'int64']] -testdata += [([0.1, 0.0, -0.1], dtype) for dtype in ['float32', 'float64']] -testdata += [([1j, -1j, 1 - 2j], dtype) for dtype in ['complex128']] +testdata += [([True, False, True], dtype) for dtype in dtypes_list] +testdata += [ + ([1, -1, 0], dtype) + for dtype in dtypes_list + if not numpy.issubdtype(dtype, numpy.bool_) +] +testdata += [ + ([0.1, 0.0, -0.1], dtype) + for dtype in dtypes_list + if numpy.issubdtype(dtype, numpy.floating) +] +testdata += [ + ([1j, -1j, 1 - 2j], dtype) + for dtype in ["complex128"] + if numpy.complex128 in get_all_dtypes(no_none=True, no_bool=True) +] @pytest.mark.parametrize("in_obj,out_dtype", testdata) diff --git a/tests/test_mixins.py b/tests/test_mixins.py index 2cb4f1b71a75..161af3ac27c6 100644 --- a/tests/test_mixins.py +++ b/tests/test_mixins.py @@ -1,4 +1,5 @@ import unittest +from .helper import skip_or_check_if_dtype_not_supported import dpnp as inp @@ -7,19 +8,25 @@ class TestMatMul(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.dtype = inp.float64 if skip_or_check_if_dtype_not_supported( + inp.float64, check_dtype=True + ) else inp.float32 + def test_matmul(self): array_data = [1., 2., 3., 4.] size = 2 # DPNP - array1 = inp.reshape(inp.array(array_data, dtype=inp.float64), (size, size)) - array2 = inp.reshape(inp.array(array_data, dtype=inp.float64), (size, size)) + array1 = inp.reshape(inp.array(array_data, dtype=self.dtype), (size, size)) + array2 = inp.reshape(inp.array(array_data, dtype=self.dtype), (size, size)) result = inp.matmul(array1, array2) # print(result) # original - array_1 = numpy.array(array_data, dtype=numpy.float64).reshape((size, size)) - array_2 = numpy.array(array_data, dtype=numpy.float64).reshape((size, size)) + array_1 = numpy.array(array_data, dtype=self.dtype).reshape((size, size)) + array_2 = numpy.array(array_data, dtype=self.dtype).reshape((size, size)) expected = numpy.matmul(array_1, array_2) # print(expected) @@ -33,14 +40,14 @@ def test_matmul2(self): array_data2 = [1., 2., 3., 4., 5., 6., 7., 8.] # DPNP - array1 = inp.reshape(inp.array(array_data1, dtype=inp.float64), (3, 2)) - array2 = inp.reshape(inp.array(array_data2, dtype=inp.float64), (2, 4)) + array1 = inp.reshape(inp.array(array_data1, dtype=self.dtype), (3, 2)) + array2 = inp.reshape(inp.array(array_data2, dtype=self.dtype), (2, 4)) result = inp.matmul(array1, array2) # print(result) # original - array_1 = numpy.array(array_data1, dtype=numpy.float64).reshape((3, 2)) - array_2 = numpy.array(array_data2, dtype=numpy.float64).reshape((2, 4)) + array_1 = numpy.array(array_data1, dtype=self.dtype).reshape((3, 2)) + array_2 = numpy.array(array_data2, dtype=self.dtype).reshape((2, 4)) expected = numpy.matmul(array_1, array_2) # print(expected) @@ -49,17 +56,17 @@ def test_matmul2(self): def test_matmul3(self): array_data1 = numpy.full((513, 513), 5) array_data2 = numpy.full((513, 513), 2) - out = numpy.empty((513, 513), dtype=numpy.float64) + out = numpy.empty((513, 513), dtype=self.dtype) # DPNP - array1 = inp.array(array_data1, dtype=inp.float64) - array2 = inp.array(array_data2, dtype=inp.float64) - out1 = inp.array(out, dtype=inp.float64) + array1 = inp.array(array_data1, dtype=self.dtype) + array2 = inp.array(array_data2, dtype=self.dtype) + out1 = inp.array(out, dtype=self.dtype) result = inp.matmul(array1, array2, out=out1) # original - array_1 = numpy.array(array_data1, dtype=numpy.float64) - array_2 = numpy.array(array_data2, dtype=numpy.float64) + array_1 = numpy.array(array_data1, dtype=self.dtype) + array_2 = numpy.array(array_data2, dtype=self.dtype) expected = numpy.matmul(array_1, array_2, out=out) numpy.testing.assert_array_equal(expected, result) diff --git a/tests/test_sort.py b/tests/test_sort.py index aa633c0c3ad9..f52af574ee0f 100644 --- a/tests/test_sort.py +++ b/tests/test_sort.py @@ -1,29 +1,34 @@ import pytest +from .helper import get_all_dtypes import dpnp import numpy -@pytest.mark.parametrize("kth", - [0, 1], - ids=['0', '1']) -@pytest.mark.parametrize("dtype", - [numpy.float64, numpy.float32, numpy.int64, numpy.int32], - ids=['float64', 'float32', 'int64', 'int32']) -@pytest.mark.parametrize("array", - [[3, 4, 2, 1], - [[1, 0], [3, 0]], - [[3, 2], [1, 6]], - [[4, 2, 3], [3, 4, 1]], - [[[1, -3], [3, 0]], [[5, 2], [0, 1]], [[1, 0], [0, 1]]], - [[[[8, 2], [3, 0]], [[5, 2], [0, 1]]], [[[1, 3], [3, 1]], [[5, 2], [0, 1]]]]], - ids=['[3, 4, 2, 1]', - '[[1, 0], [3, 0]]', - '[[3, 2], [1, 6]]', - '[[4, 2, 3], [3, 4, 1]]', - '[[[1, -3], [3, 0]], [[5, 2], [0, 1]], [[1, 0], [0, 1]]]', - '[[[[8, 2], [3, 0]], [[5, 2], [0, 1]]], [[[1, 3], [3, 1]], [[5, 2], [0, 1]]]]']) +@pytest.mark.parametrize("kth", [0, 1], ids=["0", "1"]) +@pytest.mark.parametrize( + "dtype", get_all_dtypes(no_bool=True, no_none=True, no_complex=True) +) +@pytest.mark.parametrize( + "array", + [ + [3, 4, 2, 1], + [[1, 0], [3, 0]], + [[3, 2], [1, 6]], + [[4, 2, 3], [3, 4, 1]], + [[[1, -3], [3, 0]], [[5, 2], [0, 1]], [[1, 0], [0, 1]]], + [[[[8, 2], [3, 0]], [[5, 2], [0, 1]]], [[[1, 3], [3, 1]], [[5, 2], [0, 1]]]], + ], + ids=[ + "[3, 4, 2, 1]", + "[[1, 0], [3, 0]]", + "[[3, 2], [1, 6]]", + "[[4, 2, 3], [3, 4, 1]]", + "[[[1, -3], [3, 0]], [[5, 2], [0, 1]], [[1, 0], [0, 1]]]", + "[[[[8, 2], [3, 0]], [[5, 2], [0, 1]]], [[[1, 3], [3, 1]], [[5, 2], [0, 1]]]]", + ], +) def test_partition(array, dtype, kth): a = numpy.array(array, dtype) ia = dpnp.array(array, dtype) @@ -33,43 +38,42 @@ def test_partition(array, dtype, kth): @pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("side", - ["left", "right"], - ids=['"left"', '"right"']) -@pytest.mark.parametrize("v_", - [ - [[3, 4], [2, 1]], - [[1, 0], [3, 0]], - [[3, 2, 1, 6]], - [[4, 2], [3, 3], [4, 1]], - [[1, -3, 3], [0, 5, 2], [0, 1, 1], [0, 0, 1]], - [[[[8, 2], [3, 0]], [[5, 2], [0, 1]]], [[[1, 3], [3, 1]], [[5, 2], [0, 1]]]] - ], - ids=[ - '[[3, 4], [2, 1]]', - '[[1, 0], [3, 0]]', - '[[3, 2, 1, 6]]', - '[[4, 2], [3, 3], [4, 1]]', - '[[1, -3, 3], [0, 5, 2], [0, 1, 1], [0, 0, 1]]', - '[[[[8, 2], [3, 0]], [[5, 2], [0, 1]]], [[[1, 3], [3, 1]], [[5, 2], [0, 1]]]]' - ]) -@pytest.mark.parametrize("dtype", - [numpy.float64, numpy.float32, numpy.int64, numpy.int32], - ids=['float64', 'float32', 'int64', 'int32']) -@pytest.mark.parametrize("array", - [ - [1, 2, 3, 4], - [-5, -1, 0, 3, 17, 100] - ], - ids=[ - '[1, 2, 3, 4]', - '[-5, -1, 0, 3, 17, 100]' - # '[1, 0, 3, 0]', - # '[3, 2, 1, 6]', - # '[4, 2, 3, 3, 4, 1]', - # '[1, -3, 3, 0, 5, 2, 0, 1, 1, 0, 0, 1]', - # '[8, 2, 3, 0, 5, 2, 0, 1, 1, 3, 3, 1, 5, 2, 0, 1]' - ]) +@pytest.mark.parametrize("side", ["left", "right"], ids=['"left"', '"right"']) +@pytest.mark.parametrize( + "v_", + [ + [[3, 4], [2, 1]], + [[1, 0], [3, 0]], + [[3, 2, 1, 6]], + [[4, 2], [3, 3], [4, 1]], + [[1, -3, 3], [0, 5, 2], [0, 1, 1], [0, 0, 1]], + [[[[8, 2], [3, 0]], [[5, 2], [0, 1]]], [[[1, 3], [3, 1]], [[5, 2], [0, 1]]]], + ], + ids=[ + "[[3, 4], [2, 1]]", + "[[1, 0], [3, 0]]", + "[[3, 2, 1, 6]]", + "[[4, 2], [3, 3], [4, 1]]", + "[[1, -3, 3], [0, 5, 2], [0, 1, 1], [0, 0, 1]]", + "[[[[8, 2], [3, 0]], [[5, 2], [0, 1]]], [[[1, 3], [3, 1]], [[5, 2], [0, 1]]]]", + ], +) +@pytest.mark.parametrize( + "dtype", get_all_dtypes(no_bool=True, no_none=True, no_complex=True) +) +@pytest.mark.parametrize( + "array", + [[1, 2, 3, 4], [-5, -1, 0, 3, 17, 100]], + ids=[ + "[1, 2, 3, 4]", + "[-5, -1, 0, 3, 17, 100]" + # '[1, 0, 3, 0]', + # '[3, 2, 1, 6]', + # '[4, 2, 3, 3, 4, 1]', + # '[1, -3, 3, 0, 5, 2, 0, 1, 1, 0, 0, 1]', + # '[8, 2, 3, 0, 5, 2, 0, 1, 1, 3, 3, 1, 5, 2, 0, 1]' + ], +) def test_searchsorted(array, dtype, v_, side): a = numpy.array(array, dtype) ia = dpnp.array(array, dtype) diff --git a/tests/test_special.py b/tests/test_special.py index da9938d75e9c..e12654a53249 100644 --- a/tests/test_special.py +++ b/tests/test_special.py @@ -1,11 +1,17 @@ import math import dpnp import numpy +from .helper import skip_or_check_if_dtype_not_supported + + +dtype = numpy.float64 if skip_or_check_if_dtype_not_supported( + numpy.float64, check_dtype=True + ) else numpy.float32 def test_erf(): - a = numpy.linspace(2.0, 3.0, num=10) - ia = dpnp.linspace(2.0, 3.0, num=10) + a = numpy.linspace(2.0, 3.0, num=10, dtype=dtype) + ia = dpnp.linspace(2.0, 3.0, num=10, dtype=dtype) numpy.testing.assert_array_equal(a, ia) @@ -19,8 +25,8 @@ def test_erf(): def test_erf_fallback(): - a = numpy.linspace(2.0, 3.0, num=10) - dpa = dpnp.linspace(2.0, 3.0, num=10) + a = numpy.linspace(2.0, 3.0, num=10, dtype=dtype) + dpa = dpnp.linspace(2.0, 3.0, num=10, dtype=dtype) expected = numpy.empty_like(a) for idx, val in enumerate(a): diff --git a/tests/test_sum.py b/tests/test_sum.py index 21b1a99ffe15..f885092d1b5f 100644 --- a/tests/test_sum.py +++ b/tests/test_sum.py @@ -1,10 +1,23 @@ import dpnp +from .helper import skip_or_check_if_dtype_not_supported import numpy -def test_sum_float64(): - a = numpy.array([[[-2., 3.], [9.1, 0.2]], [[-2., 5.0], [-2, -1.2]], [[1.0, -2.], [5.0, -1.1]]]) +dtype = numpy.float64 if skip_or_check_if_dtype_not_supported( + numpy.float64, check_dtype=True + ) else numpy.float32 + + +def test_sum_float(): + a = numpy.array( + [ + [[-2.0, 3.0], [9.1, 0.2]], + [[-2.0, 5.0], [-2, -1.2]], + [[1.0, -2.0], [5.0, -1.1]], + ], + dtype=dtype, + ) ia = dpnp.array(a) for axis in range(len(a)): @@ -23,7 +36,14 @@ def test_sum_int(): def test_sum_axis(): - a = numpy.array([[[-2., 3.], [9.1, 0.2]], [[-2., 5.0], [-2, -1.2]], [[1.0, -2.], [5.0, -1.1]]]) + a = numpy.array( + [ + [[-2.0, 3.0], [9.1, 0.2]], + [[-2.0, 5.0], [-2, -1.2]], + [[1.0, -2.0], [5.0, -1.1]], + ], + dtype=dtype, + ) ia = dpnp.array(a) result = dpnp.sum(ia, axis=1) diff --git a/tests/third_party/cupy/testing/helper.py b/tests/third_party/cupy/testing/helper.py index 5f9864dadc59..91ccd6657cfd 100644 --- a/tests/third_party/cupy/testing/helper.py +++ b/tests/third_party/cupy/testing/helper.py @@ -15,6 +15,9 @@ # from dpnp.core import internal from tests.third_party.cupy.testing import array from tests.third_party.cupy.testing import parameterized + +from dpctl import select_default_device + # import dpnp # import dpnp.scipy.sparse @@ -655,8 +658,15 @@ def test_func(self, *args, **kw): return decorator +def _get_supported_float_dtypes(): + if select_default_device().has_aspect_fp64: + return (numpy.float64, numpy.float32) + else: + return (numpy.float32,) + + _complex_dtypes = () -_regular_float_dtypes = (numpy.float64, numpy.float32) +_regular_float_dtypes = _get_supported_float_dtypes() _float_dtypes = _regular_float_dtypes _signed_dtypes = () _unsigned_dtypes = tuple(numpy.dtype(i).type for i in 'BHILQ')