Skip to content

Commit 27f28c9

Browse files
committed
more mess
1 parent 5efebe6 commit 27f28c9

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

array_api_tests/test_dlpack.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class DLPackDeviceEnum(Enum):
2121
ONE_API = 14
2222

2323

24-
def _compatible_devices(devices):
24+
def _compatible_devices(devices, x):
2525
"""Given a list of devices, filter out dlpack-incompatible ones."""
2626
# XXX: there seems to be no better way than try-catch for __dlpack_device__()
2727

@@ -32,7 +32,7 @@ def _compatible_devices(devices):
3232
dtype_compatible = []
3333
for device in devices:
3434
compatible_ = []
35-
x = xp.empty(2, device=device)
35+
## x = xp.empty(2, device=device)
3636
try:
3737
x.__dlpack_device__()
3838
except:
@@ -43,7 +43,6 @@ def _compatible_devices(devices):
4343
# no exception => device is compatible
4444
compatible_.append(device)
4545

46-
4746
dtype_compatible_= [
4847
device for device in compatible_
4948
if x.dtype in xp.__array_namespace_info__().dtypes(device=device)
@@ -111,15 +110,20 @@ def test_from_dlpack(x, copy_kw, data):
111110
devices = [x.device]
112111
else:
113112
devices = xp.__array_namespace_info__().devices()
114-
devices = _compatible_devices(devices)
113+
devices = _compatible_devices(devices, x)
114+
115+
### return
116+
117+
if len(devices) == 0:
118+
return
115119

116120
tgt_device_kw = data.draw(
117121
hh.kwargs(device=st.sampled_from(devices) | st.none())
118122
)
119123
tgt_device = tgt_device_kw['device'] if tgt_device_kw else None
120124

121125
# the target device may or may not support x.dtype
122-
### assume(x.dtype in xp.__array_namespace_info__().dtypes(device=tgt_device))
126+
assume(x.dtype in xp.__array_namespace_info__().dtypes(device=tgt_device))
123127

124128
repro_snippet = ph.format_snippet(
125129
f"y = from_dlpack({x!r}, **tgt_device_kw, **copy_kw) with {tgt_device_kw=} and {copy_kw=}"

0 commit comments

Comments
 (0)