Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated tests to run on Iris Xe. #1548

Merged
merged 3 commits into from
Sep 8, 2023
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
2 changes: 1 addition & 1 deletion dpnp/dpnp_algo/dpnp_algo_mathematical.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ cpdef utils.dpnp_descriptor dpnp_gradient(utils.dpnp_descriptor y1, int dx=1):
# ceate result array with type given by FPTR data
cdef shape_type_c result_shape = utils._object_to_tuple(size)
cdef utils.dpnp_descriptor result = utils_py.create_output_descriptor_py(result_shape,
dpnp.float64,
dpnp.default_float_type(y1_obj.sycl_queue),
None,
device=y1_obj.sycl_device,
usm_type=y1_obj.usm_type,
Expand Down
419 changes: 1 addition & 418 deletions tests/skipped_tests_gpu_no_fp64.tbl

Large diffs are not rendered by default.

35 changes: 22 additions & 13 deletions tests/test_sycl_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,16 @@ def vvsort(val, vec, size, xp):
ids=[device.filter_string for device in valid_devices],
)
def test_array_creation(func, arg, kwargs, device):
numpy_array = getattr(numpy, func)(*arg, **kwargs)
dtype = dpnp.default_float_type(device)
numpy_array = getattr(numpy, func)(*arg, dtype=dtype, **kwargs)

dpnp_kwargs = dict(kwargs)
dpnp_kwargs["device"] = device
dpnp_array = getattr(dpnp, func)(*arg, **dpnp_kwargs)
dpnp_array = getattr(dpnp, func)(*arg, dtype=dtype, **dpnp_kwargs)

assert_allclose(numpy_array, dpnp_array)
rtol = 1e-03 if dtype == numpy.float32 else 1e-07

assert_allclose(numpy_array, dpnp_array, rtol=rtol)
npolina4 marked this conversation as resolved.
Show resolved Hide resolved
assert dpnp_array.sycl_device == device


Expand Down Expand Up @@ -766,11 +769,12 @@ def test_eig(device):
)

size = 4
a = numpy.arange(size * size, dtype="float64").reshape((size, size))
dtype = dpnp.default_float_type(device)
a = numpy.arange(size * size, dtype=dtype).reshape((size, size))
symm_orig = (
numpy.tril(a)
+ numpy.tril(a, -1).T
+ numpy.diag(numpy.full((size,), size * size, dtype="float64"))
+ numpy.diag(numpy.full((size,), size * size, dtype=dtype))
)
numpy_data = symm_orig
dpnp_symm_orig = dpnp.array(numpy_data, device=device)
Expand Down Expand Up @@ -815,11 +819,12 @@ def test_eig(device):
)
def test_eigh(device):
size = 4
a = numpy.arange(size * size, dtype=numpy.float64).reshape((size, size))
dtype = dpnp.default_float_type(device)
a = numpy.arange(size * size, dtype=dtype).reshape((size, size))
symm_orig = (
numpy.tril(a)
+ numpy.tril(a, -1).T
+ numpy.diag(numpy.full((size,), size * size, dtype=numpy.float64))
+ numpy.diag(numpy.full((size,), size * size, dtype=dtype))
)
numpy_data = symm_orig
dpnp_symm_orig = dpnp.array(numpy_data, device=device)
Expand Down Expand Up @@ -911,9 +916,10 @@ def test_matrix_rank(device):
ids=[device.filter_string for device in valid_devices],
)
def test_qr(device):
tol = 1e-11
dtype = dpnp.default_float_type(device)
tol = 1e-06 if dtype == numpy.float32 else 1e-11
npolina4 marked this conversation as resolved.
Show resolved Hide resolved
data = [[1, 2, 3], [1, 2, 3]]
numpy_data = numpy.array(data)
numpy_data = numpy.array(data, dtype=dtype)
dpnp_data = dpnp.array(data, device=device)

np_q, np_r = numpy.linalg.qr(numpy_data, "reduced")
Expand Down Expand Up @@ -942,10 +948,13 @@ def test_qr(device):
ids=[device.filter_string for device in valid_devices],
)
def test_svd(device):
tol = 1e-12
dtype = dpnp.default_float_type(device)
tol = 1e-06 if dtype == numpy.float32 else 1e-12
npolina4 marked this conversation as resolved.
Show resolved Hide resolved
shape = (2, 2)
numpy_data = numpy.arange(shape[0] * shape[1]).reshape(shape)
dpnp_data = dpnp.arange(shape[0] * shape[1], device=device).reshape(shape)
numpy_data = numpy.arange(shape[0] * shape[1], dtype=dtype).reshape(shape)
dpnp_data = dpnp.arange(
shape[0] * shape[1], dtype=dtype, device=device
).reshape(shape)
np_u, np_s, np_vt = numpy.linalg.svd(numpy_data)
dpnp_u, dpnp_s, dpnp_vt = dpnp.linalg.svd(dpnp_data)

Expand Down Expand Up @@ -1007,7 +1016,7 @@ def test_svd(device):
def test_to_device(device_from, device_to):
data = [1.0, 1.0, 1.0, 1.0, 1.0]

x = dpnp.array(data, device=device_from)
x = dpnp.array(data, dtype=dpnp.float32, device=device_from)
y = x.to_device(device_to)

assert y.get_array().sycl_device == device_to
Expand Down
37 changes: 20 additions & 17 deletions tests/third_party/cupy/creation_tests/test_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest

import dpnp as cupy
from tests.helper import has_support_aspect64
from tests.third_party.cupy import testing


Expand Down Expand Up @@ -60,7 +61,7 @@ def test_arange9(self):
def test_arange_no_dtype_int(self, xp):
return xp.arange(1, 11, 2)

@testing.numpy_cupy_array_equal()
@testing.numpy_cupy_allclose(rtol=1e-4, type_check=has_support_aspect64())
def test_arange_no_dtype_float(self, xp):
return xp.arange(1.0, 11.0, 2.0)

Expand Down Expand Up @@ -120,11 +121,11 @@ def test_linspace_with_retstep(self, xp, dtype):
self.assertEqual(step, 2.5)
return x

@testing.numpy_cupy_allclose()
@testing.numpy_cupy_allclose(rtol=1e-4, type_check=has_support_aspect64())
def test_linspace_no_dtype_int(self, xp):
return xp.linspace(0, 10, 50)

@testing.numpy_cupy_allclose()
@testing.numpy_cupy_allclose(rtol=1e-4, type_check=has_support_aspect64())
def test_linspace_no_dtype_float(self, xp):
return xp.linspace(0.0, 10.0, 50)

Expand All @@ -139,21 +140,23 @@ def test_linspace_neg_num(self):

@testing.numpy_cupy_allclose()
def test_linspace_float_overflow(self, xp):
return xp.linspace(0.0, sys.float_info.max / 5, 10, dtype=float)
dtype = cupy.default_float_type()
return xp.linspace(0.0, numpy.finfo(dtype).max / 5, 10, dtype=dtype)

@testing.numpy_cupy_array_equal()
@testing.numpy_cupy_allclose()
def test_linspace_float_underflow(self, xp):
# find minimum subnormal number
x = sys.float_info.min
dtype = cupy.default_float_type()
x = numpy.finfo(dtype).min
while x / 2 > 0:
x /= 2
return xp.linspace(0.0, x, 10, dtype=float)
return xp.linspace(0.0, x, 10, dtype=dtype)

@testing.with_requires("numpy>=1.16")
@testing.for_all_dtypes_combination(
names=("dtype_range", "dtype_out"), no_bool=True, no_complex=True
)
@testing.numpy_cupy_allclose()
@testing.numpy_cupy_allclose(rtol=1e-04)
def test_linspace_array_start_stop(self, xp, dtype_range, dtype_out):
start = xp.array([0, 120], dtype=dtype_range)
stop = xp.array([100, 0], dtype=dtype_range)
Expand All @@ -163,7 +166,7 @@ def test_linspace_array_start_stop(self, xp, dtype_range, dtype_out):
@testing.for_all_dtypes_combination(
names=("dtype_range", "dtype_out"), no_bool=True, no_complex=True
)
@testing.numpy_cupy_array_equal()
@testing.numpy_cupy_allclose(rtol=1e-04)
def test_linspace_mixed_start_stop(self, xp, dtype_range, dtype_out):
start = 0.0
if xp.dtype(dtype_range).kind in "u":
Expand All @@ -176,7 +179,7 @@ def test_linspace_mixed_start_stop(self, xp, dtype_range, dtype_out):
@testing.for_all_dtypes_combination(
names=("dtype_range", "dtype_out"), no_bool=True, no_complex=True
)
@testing.numpy_cupy_allclose()
@testing.numpy_cupy_allclose(rtol=1e-04)
def test_linspace_mixed_start_stop2(self, xp, dtype_range, dtype_out):
if xp.dtype(dtype_range).kind in "u":
start = xp.array([160, 120], dtype=dtype_range)
Expand Down Expand Up @@ -205,7 +208,7 @@ def test_linspace_complex_start_stop(self, xp, dtype):

@testing.with_requires("numpy>=1.16")
@testing.for_all_dtypes(no_bool=True)
@testing.numpy_cupy_array_equal()
@testing.numpy_cupy_allclose(rtol=1e-04)
def test_linspace_start_stop_list(self, xp, dtype):
start = [0, 0]
stop = [100, 16]
Expand Down Expand Up @@ -241,12 +244,12 @@ def test_logspace_no_endpoint(self, xp, dtype):
return xp.logspace(0, 2, 5, dtype=dtype, endpoint=False)

@pytest.mark.usefixtures("allow_fall_back_on_numpy")
@testing.numpy_cupy_allclose()
@testing.numpy_cupy_allclose(rtol=1e-4, type_check=has_support_aspect64())
def test_logspace_no_dtype_int(self, xp):
return xp.logspace(0, 2)

@pytest.mark.usefixtures("allow_fall_back_on_numpy")
@testing.numpy_cupy_allclose()
@testing.numpy_cupy_allclose(rtol=1e-4, type_check=has_support_aspect64())
def test_logspace_no_dtype_float(self, xp):
return xp.logspace(0.0, 2.0)

Expand All @@ -262,7 +265,7 @@ def test_logspace_neg_num(self):

@pytest.mark.usefixtures("allow_fall_back_on_numpy")
@testing.for_all_dtypes(no_bool=True)
@testing.numpy_cupy_allclose()
@testing.numpy_cupy_allclose(rtol=1e-04)
def test_logspace_base(self, xp, dtype):
return xp.logspace(0, 2, 5, base=2.0, dtype=dtype)

Expand Down Expand Up @@ -323,7 +326,7 @@ def test_mgrid0(self, xp):
def test_mgrid1(self, xp):
return xp.mgrid[-10:10]

@testing.numpy_cupy_array_equal()
@testing.numpy_cupy_allclose(rtol=1e-4, type_check=has_support_aspect64())
def test_mgrid2(self, xp):
return xp.mgrid[-10:10:10j]

Expand All @@ -333,7 +336,7 @@ def test_mgrid3(self, xp):
y = xp.ones(10)[:, None]
return xp.mgrid[x:y:10j]

@testing.numpy_cupy_array_equal()
@testing.numpy_cupy_allclose(rtol=1e-4, type_check=has_support_aspect64())
def test_mgrid4(self, xp):
# check len(keys) > 1
return xp.mgrid[-10:10:10j, -10:10:10j]
Expand All @@ -356,7 +359,7 @@ def test_ogrid0(self, xp):
def test_ogrid1(self, xp):
return xp.ogrid[-10:10]

@testing.numpy_cupy_array_equal()
@testing.numpy_cupy_allclose(rtol=1e-4, type_check=has_support_aspect64())
def test_ogrid2(self, xp):
return xp.ogrid[-10:10:10j]

Expand Down
4 changes: 4 additions & 0 deletions tests/third_party/cupy/fft_tests/test_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class TestFft2(unittest.TestCase):
atol=1e-7,
accept_error=ValueError,
type_check=has_support_aspect64(),
contiguous_check=False,
)
def test_fft2(self, xp, dtype):
a = testing.shaped_random(self.shape, xp, dtype)
Expand All @@ -98,6 +99,7 @@ def test_fft2(self, xp, dtype):
atol=1e-7,
accept_error=ValueError,
type_check=has_support_aspect64(),
contiguous_check=False,
)
def test_ifft2(self, xp, dtype):
a = testing.shaped_random(self.shape, xp, dtype)
Expand Down Expand Up @@ -141,6 +143,7 @@ class TestFftn(unittest.TestCase):
atol=1e-7,
accept_error=ValueError,
type_check=has_support_aspect64(),
contiguous_check=False,
)
def test_fftn(self, xp, dtype):
a = testing.shaped_random(self.shape, xp, dtype)
Expand All @@ -154,6 +157,7 @@ def test_fftn(self, xp, dtype):
atol=1e-7,
accept_error=ValueError,
type_check=has_support_aspect64(),
contiguous_check=False,
)
def test_ifftn(self, xp, dtype):
a = testing.shaped_random(self.shape, xp, dtype)
Expand Down
10 changes: 8 additions & 2 deletions tests/third_party/cupy/linalg_tests/test_eigenvalue.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest

import dpnp as cupy
from tests.helper import has_support_aspect64
from tests.third_party.cupy import testing


Expand All @@ -29,7 +30,12 @@ def _wrap_as_numpy_array(xp, a):
)
class TestEigenvalue(unittest.TestCase):
@testing.for_all_dtypes()
@testing.numpy_cupy_allclose(rtol=1e-3, atol=1e-4, contiguous_check=False)
@testing.numpy_cupy_allclose(
rtol=1e-3,
atol=1e-4,
type_check=has_support_aspect64(),
contiguous_check=False,
)
def test_eigh(self, xp, dtype):
if xp == numpy and dtype == numpy.float16:
# NumPy's eigh does not support float16
Expand Down Expand Up @@ -186,7 +192,7 @@ def test_eigvalsh_complex_batched(self, xp, dtype):
)
class TestEigenvalueEmpty(unittest.TestCase):
@testing.for_dtypes("ifdFD")
@testing.numpy_cupy_allclose()
@testing.numpy_cupy_allclose(type_check=has_support_aspect64())
def test_eigh(self, xp, dtype):
a = xp.empty(self.shape, dtype=dtype)
assert a.size == 0
Expand Down
5 changes: 4 additions & 1 deletion tests/third_party/cupy/linalg_tests/test_einsum.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

import dpnp as cupy
from tests.helper import has_support_aspect64
from tests.third_party.cupy import testing


Expand Down Expand Up @@ -310,7 +311,9 @@ def setUp(self):
self.operands = operands

@pytest.mark.usefixtures("allow_fall_back_on_numpy")
@testing.numpy_cupy_allclose(contiguous_check=False)
@testing.numpy_cupy_allclose(
type_check=has_support_aspect64(), contiguous_check=False
)
def test_einsum(self, xp):
# TODO(kataoka): support memory efficient cupy.einsum
with warnings.catch_warnings(record=True) as ws:
Expand Down
5 changes: 4 additions & 1 deletion tests/third_party/cupy/linalg_tests/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest

import dpnp as cupy
from tests.helper import has_support_aspect64
from tests.third_party.cupy import testing


Expand Down Expand Up @@ -101,7 +102,9 @@ def test_dot_with_out(self, xp, dtype_a, dtype_b, dtype_c):
class TestCrossProduct(unittest.TestCase):
@testing.for_all_dtypes_combination(["dtype_a", "dtype_b"])
# TODO: remove 'contiguous_check=False' once fixed in dpnp.cross()
@testing.numpy_cupy_allclose(contiguous_check=False)
@testing.numpy_cupy_allclose(
type_check=has_support_aspect64(), contiguous_check=False
)
def test_cross(self, xp, dtype_a, dtype_b):
if dtype_a == dtype_b == numpy.bool_:
# cross does not support bool-bool inputs.
Expand Down
4 changes: 2 additions & 2 deletions tests/third_party/cupy/sorting_tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,8 @@ def test_invalid_sorter(self):

def test_nonint_sorter(self):
for xp in (numpy, cupy):
x = testing.shaped_arange((12,), xp, xp.float64)
x = testing.shaped_arange((12,), xp, xp.float32)
bins = xp.array([10, 4, 2, 1, 8])
sorter = xp.array([], dtype=xp.float64)
sorter = xp.array([], dtype=xp.float32)
with pytest.raises(TypeError):
xp.searchsorted(bins, x, sorter=sorter)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from dpctl import select_default_device

import dpnp as cupy
from tests.helper import has_support_aspect64
from tests.third_party.cupy import testing


Expand Down Expand Up @@ -181,7 +182,7 @@ def test_correlate_large_non_contiguous(self, xp, dtype):
return xp.correlate(a[200::], b[10::700], mode=self.mode)

@testing.for_all_dtypes_combination(names=["dtype1", "dtype2"])
@testing.numpy_cupy_allclose(rtol=1e-2)
@testing.numpy_cupy_allclose(rtol=1e-2, type_check=has_support_aspect64())
def test_correlate_diff_types(self, xp, dtype1, dtype2):
a = testing.shaped_random((200,), xp, dtype1)
b = testing.shaped_random((100,), xp, dtype2)
Expand Down
Loading