|
43 | 43 | from .utils import ( |
44 | 44 | _all_dtypes, |
45 | 45 | _compare_dtypes, |
46 | | - _usm_types, |
47 | 46 | ) |
48 | 47 |
|
49 | 48 |
|
@@ -89,21 +88,6 @@ def test_add_dtype_matrix(op1_dtype, op2_dtype): |
89 | 88 | assert (dpt.asnumpy(r2) == np.full(r2.shape, 2, dtype=r2.dtype)).all() |
90 | 89 |
|
91 | 90 |
|
92 | | -@pytest.mark.parametrize("op1_usm_type", _usm_types) |
93 | | -@pytest.mark.parametrize("op2_usm_type", _usm_types) |
94 | | -def test_add_usm_type_matrix(op1_usm_type, op2_usm_type): |
95 | | - get_queue_or_skip() |
96 | | - |
97 | | - sz = 128 |
98 | | - ar1 = dpt.ones(sz, dtype="i4", usm_type=op1_usm_type) |
99 | | - ar2 = dpt.ones_like(ar1, dtype="i4", usm_type=op2_usm_type) |
100 | | - |
101 | | - r = dpt.add(ar1, ar2) |
102 | | - assert isinstance(r, dpt.usm_ndarray) |
103 | | - expected_usm_type = dpt.get_coerced_usm_type((op1_usm_type, op2_usm_type)) |
104 | | - assert r.usm_type == expected_usm_type |
105 | | - |
106 | | - |
107 | 91 | def test_add_order(): |
108 | 92 | get_queue_or_skip() |
109 | 93 |
|
@@ -283,23 +267,17 @@ def test_add_types_property(): |
283 | 267 |
|
284 | 268 |
|
285 | 269 | def test_add_errors(): |
286 | | - get_queue_or_skip() |
287 | | - try: |
288 | | - gpu_queue = dpctl.SyclQueue("gpu") |
289 | | - except dpctl.SyclQueueCreationError: |
290 | | - pytest.skip("SyclQueue('gpu') failed, skipping") |
291 | | - try: |
292 | | - cpu_queue = dpctl.SyclQueue("cpu") |
293 | | - except dpctl.SyclQueueCreationError: |
294 | | - pytest.skip("SyclQueue('cpu') failed, skipping") |
295 | | - |
296 | | - ar1 = dpt.ones(2, dtype="float32", sycl_queue=gpu_queue) |
297 | | - ar2 = dpt.ones_like(ar1, sycl_queue=gpu_queue) |
298 | | - y = dpt.empty_like(ar1, sycl_queue=cpu_queue) |
| 270 | + q1 = get_queue_or_skip() |
| 271 | + q2 = dpctl.SyclQueue() |
| 272 | + |
| 273 | + ar1 = dpt.ones(2, dtype="float32", sycl_queue=q1) |
| 274 | + ar2 = dpt.ones_like(ar1, dtype="float32", sycl_queue=q2) |
| 275 | + y = dpt.empty_like(ar1, sycl_queue=q2) |
299 | 276 | with pytest.raises(dpt.ExecutionPlacementError) as excinfo: |
300 | 277 | dpt.add(ar1, ar2, out=y) |
301 | | - assert "Input and output allocation queues are not compatible" in str( |
302 | | - excinfo.value |
| 278 | + assert re.match( |
| 279 | + "Execution placement can not be unambiguously inferred.*", |
| 280 | + str(excinfo.value), |
303 | 281 | ) |
304 | 282 |
|
305 | 283 | ar1 = dpt.ones(2, dtype="float32") |
@@ -327,17 +305,8 @@ def test_add_errors(): |
327 | 305 | dpt.add(ar1, ar2, out=y) |
328 | 306 | assert "output array must be of usm_ndarray type" in str(excinfo.value) |
329 | 307 |
|
330 | | - |
331 | | -@pytest.mark.parametrize("dtype", _all_dtypes) |
332 | | -def test_add_dtype_error( |
333 | | - dtype, |
334 | | -): |
335 | | - q = get_queue_or_skip() |
336 | | - skip_if_dtype_not_supported(dtype, q) |
337 | | - |
338 | | - ar1 = dpt.ones(5, dtype=dtype) |
| 308 | + ar1 = dpt.ones(5, dtype="f4") |
339 | 309 | ar2 = dpt.ones_like(ar1, dtype="f4") |
340 | | - |
341 | 310 | y = dpt.zeros_like(ar1, dtype="int8") |
342 | 311 | with pytest.raises(ValueError) as excinfo: |
343 | 312 | dpt.add(ar1, ar2, out=y) |
@@ -469,39 +438,12 @@ def test_add_inplace_operator_mutual_broadcast(): |
469 | 438 |
|
470 | 439 |
|
471 | 440 | def test_add_inplace_errors(): |
472 | | - get_queue_or_skip() |
473 | | - try: |
474 | | - gpu_queue = dpctl.SyclQueue("gpu") |
475 | | - except dpctl.SyclQueueCreationError: |
476 | | - pytest.skip("SyclQueue('gpu') failed, skipping") |
477 | | - try: |
478 | | - cpu_queue = dpctl.SyclQueue("cpu") |
479 | | - except dpctl.SyclQueueCreationError: |
480 | | - pytest.skip("SyclQueue('cpu') failed, skipping") |
481 | | - |
482 | | - ar1 = dpt.ones(2, dtype="float32", sycl_queue=gpu_queue) |
483 | | - ar2 = dpt.ones_like(ar1, sycl_queue=cpu_queue) |
484 | | - with pytest.raises(dpt.ExecutionPlacementError): |
485 | | - dpt.add(ar1, ar2, out=ar1) |
486 | | - |
487 | | - ar1 = dpt.ones(2, dtype="float32") |
488 | | - ar2 = dpt.ones(3, dtype="float32") |
489 | | - with pytest.raises(ValueError): |
490 | | - dpt.add(ar1, ar2, out=ar1) |
491 | | - |
492 | | - ar1 = np.ones(2, dtype="float32") |
493 | | - ar2 = dpt.ones(2, dtype="float32") |
494 | | - with pytest.raises(TypeError): |
495 | | - dpt.add(ar1, ar2, out=ar1) |
496 | | - |
497 | | - ar1 = dpt.ones(2, dtype="float32") |
498 | | - ar2 = {} |
499 | | - with pytest.raises(ValueError): |
500 | | - dpt.add(ar1, ar2, out=ar1) |
| 441 | + q1 = get_queue_or_skip() |
| 442 | + q2 = dpctl.SyclQueue() |
501 | 443 |
|
502 | | - ar1 = dpt.ones((2, 1), dtype="float32") |
503 | | - ar2 = dpt.ones((1, 2), dtype="float32") |
504 | | - with pytest.raises(ValueError): |
| 444 | + ar1 = dpt.ones(2, dtype="float32", sycl_queue=q1) |
| 445 | + ar2 = dpt.ones_like(ar1, sycl_queue=q2) |
| 446 | + with pytest.raises(dpt.ExecutionPlacementError): |
505 | 447 | dpt.add(ar1, ar2, out=ar1) |
506 | 448 |
|
507 | 449 |
|
|
0 commit comments