Skip to content

Commit 7ba5c31

Browse files
committed
Add comments explaining logic behind various stages of test_add_inplace_dtype_matrix
1 parent 0297fbe commit 7ba5c31

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

dpctl/tests/elementwise/test_add.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ def test_add_inplace_dtype_matrix(op1_dtype, op2_dtype):
358358
dev = q.sycl_device
359359
_fp16 = dev.has_aspect_fp16
360360
_fp64 = dev.has_aspect_fp64
361+
# operators use a different Python implementation which permits
362+
# same kind style casting
361363
if _can_cast(ar2.dtype, ar1.dtype, _fp16, _fp64, casting="same_kind"):
362364
ar1 += ar2
363365
assert (
@@ -374,6 +376,9 @@ def test_add_inplace_dtype_matrix(op1_dtype, op2_dtype):
374376
with pytest.raises(ValueError):
375377
ar1 += ar2
376378

379+
# here, test the special case where out is the first argument
380+
# so an in-place kernel is used for efficiency
381+
# this covers a specific branch in the BinaryElementwiseFunc logic
377382
ar1 = dpt.ones(sz, dtype=op1_dtype)
378383
ar2 = dpt.ones_like(ar1, dtype=op2_dtype)
379384
if _can_cast(ar2.dtype, ar1.dtype, _fp16, _fp64):

0 commit comments

Comments
 (0)