Skip to content

Commit b5764e2

Browse files
authored
Updated tests to run on Iris Xe. (#1548)
* Updated tests to run on Iris Xe * Update sycl_queue tests for run on Iris Xe
1 parent 239cca7 commit b5764e2

File tree

11 files changed

+93
-492
lines changed

11 files changed

+93
-492
lines changed

dpnp/dpnp_algo/dpnp_algo_mathematical.pxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ cpdef utils.dpnp_descriptor dpnp_gradient(utils.dpnp_descriptor y1, int dx=1):
261261
# ceate result array with type given by FPTR data
262262
cdef shape_type_c result_shape = utils._object_to_tuple(size)
263263
cdef utils.dpnp_descriptor result = utils_py.create_output_descriptor_py(result_shape,
264-
dpnp.float64,
264+
dpnp.default_float_type(y1_obj.sycl_queue),
265265
None,
266266
device=y1_obj.sycl_device,
267267
usm_type=y1_obj.usm_type,

tests/skipped_tests_gpu_no_fp64.tbl

Lines changed: 1 addition & 418 deletions
Large diffs are not rendered by default.

tests/test_sycl_queue.py

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ def vvsort(val, vec, size, xp):
9494
ids=[device.filter_string for device in valid_devices],
9595
)
9696
def test_array_creation(func, arg, kwargs, device):
97-
numpy_array = getattr(numpy, func)(*arg, **kwargs)
98-
9997
dpnp_kwargs = dict(kwargs)
10098
dpnp_kwargs["device"] = device
10199
dpnp_array = getattr(dpnp, func)(*arg, **dpnp_kwargs)
102100

103-
assert_allclose(numpy_array, dpnp_array)
101+
numpy_array = getattr(numpy, func)(*arg, dtype=dpnp_array.dtype, **kwargs)
102+
103+
assert_dtype_allclose(dpnp_array, numpy_array)
104104
assert dpnp_array.sycl_device == device
105105

106106

@@ -766,11 +766,12 @@ def test_eig(device):
766766
)
767767

768768
size = 4
769-
a = numpy.arange(size * size, dtype="float64").reshape((size, size))
769+
dtype = dpnp.default_float_type(device)
770+
a = numpy.arange(size * size, dtype=dtype).reshape((size, size))
770771
symm_orig = (
771772
numpy.tril(a)
772773
+ numpy.tril(a, -1).T
773-
+ numpy.diag(numpy.full((size,), size * size, dtype="float64"))
774+
+ numpy.diag(numpy.full((size,), size * size, dtype=dtype))
774775
)
775776
numpy_data = symm_orig
776777
dpnp_symm_orig = dpnp.array(numpy_data, device=device)
@@ -815,11 +816,12 @@ def test_eig(device):
815816
)
816817
def test_eigh(device):
817818
size = 4
818-
a = numpy.arange(size * size, dtype=numpy.float64).reshape((size, size))
819+
dtype = dpnp.default_float_type(device)
820+
a = numpy.arange(size * size, dtype=dtype).reshape((size, size))
819821
symm_orig = (
820822
numpy.tril(a)
821823
+ numpy.tril(a, -1).T
822-
+ numpy.diag(numpy.full((size,), size * size, dtype=numpy.float64))
824+
+ numpy.diag(numpy.full((size,), size * size, dtype=dtype))
823825
)
824826
numpy_data = symm_orig
825827
dpnp_symm_orig = dpnp.array(numpy_data, device=device)
@@ -911,10 +913,9 @@ def test_matrix_rank(device):
911913
ids=[device.filter_string for device in valid_devices],
912914
)
913915
def test_qr(device):
914-
tol = 1e-11
915-
data = [[1, 2, 3], [1, 2, 3]]
916-
numpy_data = numpy.array(data)
916+
data = [[1.0, 2.0, 3.0], [1.0, 2.0, 3.0]]
917917
dpnp_data = dpnp.array(data, device=device)
918+
numpy_data = numpy.array(data, dtype=dpnp_data.dtype)
918919

919920
np_q, np_r = numpy.linalg.qr(numpy_data, "reduced")
920921
dpnp_q, dpnp_r = dpnp.linalg.qr(dpnp_data, "reduced")
@@ -924,8 +925,8 @@ def test_qr(device):
924925
assert dpnp_q.shape == np_q.shape
925926
assert dpnp_r.shape == np_r.shape
926927

927-
assert_allclose(dpnp_q, np_q, rtol=tol, atol=tol)
928-
assert_allclose(dpnp_r, np_r, rtol=tol, atol=tol)
928+
assert_dtype_allclose(dpnp_q, np_q)
929+
assert_dtype_allclose(dpnp_r, np_r)
929930

930931
expected_queue = dpnp_data.get_array().sycl_queue
931932
dpnp_q_queue = dpnp_q.get_array().sycl_queue
@@ -942,10 +943,13 @@ def test_qr(device):
942943
ids=[device.filter_string for device in valid_devices],
943944
)
944945
def test_svd(device):
945-
tol = 1e-12
946946
shape = (2, 2)
947-
numpy_data = numpy.arange(shape[0] * shape[1]).reshape(shape)
948-
dpnp_data = dpnp.arange(shape[0] * shape[1], device=device).reshape(shape)
947+
dtype = dpnp.default_float_type(device)
948+
numpy_data = numpy.arange(shape[0] * shape[1], dtype=dtype).reshape(shape)
949+
dpnp_data = dpnp.arange(
950+
shape[0] * shape[1], dtype=dtype, device=device
951+
).reshape(shape)
952+
949953
np_u, np_s, np_vt = numpy.linalg.svd(numpy_data)
950954
dpnp_u, dpnp_s, dpnp_vt = dpnp.linalg.svd(dpnp_data)
951955

@@ -962,11 +966,8 @@ def test_svd(device):
962966
dpnp_diag_s[i, i] = dpnp_s[i]
963967

964968
# check decomposition
965-
assert_allclose(
966-
dpnp_data,
967-
dpnp.dot(dpnp_u, dpnp.dot(dpnp_diag_s, dpnp_vt)),
968-
rtol=tol,
969-
atol=tol,
969+
assert_dtype_allclose(
970+
dpnp_data, dpnp.dot(dpnp_u, dpnp.dot(dpnp_diag_s, dpnp_vt))
970971
)
971972

972973
for i in range(min(shape[0], shape[1])):
@@ -975,13 +976,9 @@ def test_svd(device):
975976
np_vt[i, :] = -np_vt[i, :]
976977

977978
# compare vectors for non-zero values
978-
for i in range(numpy.count_nonzero(np_s > tol)):
979-
assert_allclose(
980-
dpnp.asnumpy(dpnp_u)[:, i], np_u[:, i], rtol=tol, atol=tol
981-
)
982-
assert_allclose(
983-
dpnp.asnumpy(dpnp_vt)[i, :], np_vt[i, :], rtol=tol, atol=tol
984-
)
979+
for i in range(numpy.count_nonzero(np_s)):
980+
assert_dtype_allclose(dpnp_u[:, i], np_u[:, i])
981+
assert_dtype_allclose(dpnp_vt[i, :], np_vt[i, :])
985982

986983
expected_queue = dpnp_data.get_array().sycl_queue
987984
dpnp_u_queue = dpnp_u.get_array().sycl_queue
@@ -1007,7 +1004,7 @@ def test_svd(device):
10071004
def test_to_device(device_from, device_to):
10081005
data = [1.0, 1.0, 1.0, 1.0, 1.0]
10091006

1010-
x = dpnp.array(data, device=device_from)
1007+
x = dpnp.array(data, dtype=dpnp.float32, device=device_from)
10111008
y = x.to_device(device_to)
10121009

10131010
assert y.get_array().sycl_device == device_to

tests/third_party/cupy/creation_tests/test_ranges.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pytest
77

88
import dpnp as cupy
9+
from tests.helper import has_support_aspect64
910
from tests.third_party.cupy import testing
1011

1112

@@ -60,7 +61,7 @@ def test_arange9(self):
6061
def test_arange_no_dtype_int(self, xp):
6162
return xp.arange(1, 11, 2)
6263

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

@@ -120,11 +121,11 @@ def test_linspace_with_retstep(self, xp, dtype):
120121
self.assertEqual(step, 2.5)
121122
return x
122123

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

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

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

140141
@testing.numpy_cupy_allclose()
141142
def test_linspace_float_overflow(self, xp):
142-
return xp.linspace(0.0, sys.float_info.max / 5, 10, dtype=float)
143+
dtype = cupy.default_float_type()
144+
return xp.linspace(0.0, numpy.finfo(dtype).max / 5, 10, dtype=dtype)
143145

144-
@testing.numpy_cupy_array_equal()
146+
@testing.numpy_cupy_allclose()
145147
def test_linspace_float_underflow(self, xp):
146148
# find minimum subnormal number
147-
x = sys.float_info.min
149+
dtype = cupy.default_float_type()
150+
x = numpy.finfo(dtype).min
148151
while x / 2 > 0:
149152
x /= 2
150-
return xp.linspace(0.0, x, 10, dtype=float)
153+
return xp.linspace(0.0, x, 10, dtype=dtype)
151154

152155
@testing.with_requires("numpy>=1.16")
153156
@testing.for_all_dtypes_combination(
154157
names=("dtype_range", "dtype_out"), no_bool=True, no_complex=True
155158
)
156-
@testing.numpy_cupy_allclose()
159+
@testing.numpy_cupy_allclose(rtol=1e-04)
157160
def test_linspace_array_start_stop(self, xp, dtype_range, dtype_out):
158161
start = xp.array([0, 120], dtype=dtype_range)
159162
stop = xp.array([100, 0], dtype=dtype_range)
@@ -163,7 +166,7 @@ def test_linspace_array_start_stop(self, xp, dtype_range, dtype_out):
163166
@testing.for_all_dtypes_combination(
164167
names=("dtype_range", "dtype_out"), no_bool=True, no_complex=True
165168
)
166-
@testing.numpy_cupy_array_equal()
169+
@testing.numpy_cupy_allclose(rtol=1e-04)
167170
def test_linspace_mixed_start_stop(self, xp, dtype_range, dtype_out):
168171
start = 0.0
169172
if xp.dtype(dtype_range).kind in "u":
@@ -176,7 +179,7 @@ def test_linspace_mixed_start_stop(self, xp, dtype_range, dtype_out):
176179
@testing.for_all_dtypes_combination(
177180
names=("dtype_range", "dtype_out"), no_bool=True, no_complex=True
178181
)
179-
@testing.numpy_cupy_allclose()
182+
@testing.numpy_cupy_allclose(rtol=1e-04)
180183
def test_linspace_mixed_start_stop2(self, xp, dtype_range, dtype_out):
181184
if xp.dtype(dtype_range).kind in "u":
182185
start = xp.array([160, 120], dtype=dtype_range)
@@ -205,7 +208,7 @@ def test_linspace_complex_start_stop(self, xp, dtype):
205208

206209
@testing.with_requires("numpy>=1.16")
207210
@testing.for_all_dtypes(no_bool=True)
208-
@testing.numpy_cupy_array_equal()
211+
@testing.numpy_cupy_allclose(rtol=1e-04)
209212
def test_linspace_start_stop_list(self, xp, dtype):
210213
start = [0, 0]
211214
stop = [100, 16]
@@ -241,12 +244,12 @@ def test_logspace_no_endpoint(self, xp, dtype):
241244
return xp.logspace(0, 2, 5, dtype=dtype, endpoint=False)
242245

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

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

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

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

@@ -323,7 +326,7 @@ def test_mgrid0(self, xp):
323326
def test_mgrid1(self, xp):
324327
return xp.mgrid[-10:10]
325328

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

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

336-
@testing.numpy_cupy_array_equal()
339+
@testing.numpy_cupy_allclose(rtol=1e-4, type_check=has_support_aspect64())
337340
def test_mgrid4(self, xp):
338341
# check len(keys) > 1
339342
return xp.mgrid[-10:10:10j, -10:10:10j]
@@ -356,7 +359,7 @@ def test_ogrid0(self, xp):
356359
def test_ogrid1(self, xp):
357360
return xp.ogrid[-10:10]
358361

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

tests/third_party/cupy/fft_tests/test_fft.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class TestFft2(unittest.TestCase):
8585
atol=1e-7,
8686
accept_error=ValueError,
8787
type_check=has_support_aspect64(),
88+
contiguous_check=False,
8889
)
8990
def test_fft2(self, xp, dtype):
9091
a = testing.shaped_random(self.shape, xp, dtype)
@@ -98,6 +99,7 @@ def test_fft2(self, xp, dtype):
9899
atol=1e-7,
99100
accept_error=ValueError,
100101
type_check=has_support_aspect64(),
102+
contiguous_check=False,
101103
)
102104
def test_ifft2(self, xp, dtype):
103105
a = testing.shaped_random(self.shape, xp, dtype)
@@ -141,6 +143,7 @@ class TestFftn(unittest.TestCase):
141143
atol=1e-7,
142144
accept_error=ValueError,
143145
type_check=has_support_aspect64(),
146+
contiguous_check=False,
144147
)
145148
def test_fftn(self, xp, dtype):
146149
a = testing.shaped_random(self.shape, xp, dtype)
@@ -154,6 +157,7 @@ def test_fftn(self, xp, dtype):
154157
atol=1e-7,
155158
accept_error=ValueError,
156159
type_check=has_support_aspect64(),
160+
contiguous_check=False,
157161
)
158162
def test_ifftn(self, xp, dtype):
159163
a = testing.shaped_random(self.shape, xp, dtype)

tests/third_party/cupy/linalg_tests/test_eigenvalue.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pytest
55

66
import dpnp as cupy
7+
from tests.helper import has_support_aspect64
78
from tests.third_party.cupy import testing
89

910

@@ -29,7 +30,12 @@ def _wrap_as_numpy_array(xp, a):
2930
)
3031
class TestEigenvalue(unittest.TestCase):
3132
@testing.for_all_dtypes()
32-
@testing.numpy_cupy_allclose(rtol=1e-3, atol=1e-4, contiguous_check=False)
33+
@testing.numpy_cupy_allclose(
34+
rtol=1e-3,
35+
atol=1e-4,
36+
type_check=has_support_aspect64(),
37+
contiguous_check=False,
38+
)
3339
def test_eigh(self, xp, dtype):
3440
if xp == numpy and dtype == numpy.float16:
3541
# NumPy's eigh does not support float16
@@ -186,7 +192,7 @@ def test_eigvalsh_complex_batched(self, xp, dtype):
186192
)
187193
class TestEigenvalueEmpty(unittest.TestCase):
188194
@testing.for_dtypes("ifdFD")
189-
@testing.numpy_cupy_allclose()
195+
@testing.numpy_cupy_allclose(type_check=has_support_aspect64())
190196
def test_eigh(self, xp, dtype):
191197
a = xp.empty(self.shape, dtype=dtype)
192198
assert a.size == 0

tests/third_party/cupy/linalg_tests/test_einsum.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66

77
import dpnp as cupy
8+
from tests.helper import has_support_aspect64
89
from tests.third_party.cupy import testing
910

1011

@@ -310,7 +311,9 @@ def setUp(self):
310311
self.operands = operands
311312

312313
@pytest.mark.usefixtures("allow_fall_back_on_numpy")
313-
@testing.numpy_cupy_allclose(contiguous_check=False)
314+
@testing.numpy_cupy_allclose(
315+
type_check=has_support_aspect64(), contiguous_check=False
316+
)
314317
def test_einsum(self, xp):
315318
# TODO(kataoka): support memory efficient cupy.einsum
316319
with warnings.catch_warnings(record=True) as ws:

tests/third_party/cupy/linalg_tests/test_product.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pytest
55

66
import dpnp as cupy
7+
from tests.helper import has_support_aspect64
78
from tests.third_party.cupy import testing
89

910

@@ -101,7 +102,9 @@ def test_dot_with_out(self, xp, dtype_a, dtype_b, dtype_c):
101102
class TestCrossProduct(unittest.TestCase):
102103
@testing.for_all_dtypes_combination(["dtype_a", "dtype_b"])
103104
# TODO: remove 'contiguous_check=False' once fixed in dpnp.cross()
104-
@testing.numpy_cupy_allclose(contiguous_check=False)
105+
@testing.numpy_cupy_allclose(
106+
type_check=has_support_aspect64(), contiguous_check=False
107+
)
105108
def test_cross(self, xp, dtype_a, dtype_b):
106109
if dtype_a == dtype_b == numpy.bool_:
107110
# cross does not support bool-bool inputs.

tests/third_party/cupy/sorting_tests/test_search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,8 @@ def test_invalid_sorter(self):
694694

695695
def test_nonint_sorter(self):
696696
for xp in (numpy, cupy):
697-
x = testing.shaped_arange((12,), xp, xp.float64)
697+
x = testing.shaped_arange((12,), xp, xp.float32)
698698
bins = xp.array([10, 4, 2, 1, 8])
699-
sorter = xp.array([], dtype=xp.float64)
699+
sorter = xp.array([], dtype=xp.float32)
700700
with pytest.raises(TypeError):
701701
xp.searchsorted(bins, x, sorter=sorter)

0 commit comments

Comments
 (0)