Skip to content

Commit 15f2794

Browse files
committed
MAINT: safer copy=False handling (no device transfers)
1 parent a4dc839 commit 15f2794

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

array_api_tests/test_dlpack.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,20 @@ def test_dlpack_device(dtype, data):
4747
data=st.data()
4848
)
4949
def test_from_dlpack(x, copy_kw, data):
50-
devices = xp.__array_namespace_info__().devices()
51-
devices = filter_meta(devices)
50+
copy = copy_kw["copy"] if copy_kw else None
51+
# TODO: 1. test copy; 2. generate inputs on non-default devices;
52+
# 3. test for copy=False cross-device transfers
53+
if copy is False:
54+
devices = [x.device]
55+
else:
56+
devices = xp.__array_namespace_info__().devices()
57+
devices = filter_meta(devices)
58+
5259
tgt_device_kw = data.draw(
5360
hh.kwargs(device=st.sampled_from(devices) | st.none())
5461
)
55-
# TODO: 1. test copy; 2. generate inputs on non-default devices
5662
tgt_device = tgt_device_kw['device'] if tgt_device_kw else None
5763

58-
5964
repro_snippet = ph.format_snippet(
6065
f"y = from_dlpack({x!r}, **tgt_device_kw, **copy_kw) with {tgt_device_kw=} and {copy_kw=}"
6166
)

0 commit comments

Comments
 (0)