Skip to content

Commit a4dc839

Browse files
committed
filter out the torch "meta" device
1 parent 502a2d9 commit a4dc839

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

array_api_tests/test_dlpack.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ class DLPackDeviceEnum(Enum):
2121
ONE_API = 14
2222

2323

24+
def filter_meta(devices):
25+
# hack: filter out torch.device(type="meta")
26+
try:
27+
import torch
28+
return [x for x in devices if x != torch.device(type="meta")]
29+
except Exception:
30+
return devices
31+
32+
2433
@given(dtype=hh.all_dtypes, data=st.data())
2534
def test_dlpack_device(dtype, data):
2635
"""Test the array object __dlpack_device__ method."""
@@ -39,6 +48,7 @@ def test_dlpack_device(dtype, data):
3948
)
4049
def test_from_dlpack(x, copy_kw, data):
4150
devices = xp.__array_namespace_info__().devices()
51+
devices = filter_meta(devices)
4252
tgt_device_kw = data.draw(
4353
hh.kwargs(device=st.sampled_from(devices) | st.none())
4454
)

0 commit comments

Comments
 (0)