Skip to content

Commit d35b7b8

Browse files
Do not try default_context on Windows yet
1 parent 55abcd0 commit d35b7b8

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

dpctl/tensor/_dlpack.pyx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,18 @@ from .._backend cimport (
3333
)
3434
from ._usmarray cimport usm_ndarray
3535

36+
from platform import system as sys_platform
37+
3638
import numpy as np
3739

3840
import dpctl
3941
import dpctl.memory as dpmem
4042

4143

44+
cdef bint _IS_LINUX = sys_platform() == "Linux"
45+
46+
del sys_platform
47+
4248
cdef extern from 'dlpack/dlpack.h' nogil:
4349
cdef int DLPACK_VERSION
4450

@@ -159,7 +165,10 @@ cpdef to_dlpack_capsule(usm_ndarray usm_ary) except+:
159165
ary_sycl_device = ary_sycl_queue.get_sycl_device()
160166

161167
try:
162-
default_context = ary_sycl_device.sycl_platform.default_context
168+
if _IS_LINUX:
169+
default_context = ary_sycl_device.sycl_platform.default_context
170+
else:
171+
default_context = None
163172
except RuntimeError:
164173
# RT does not support default_context, e.g. Windows
165174
default_context = None
@@ -328,7 +337,10 @@ cpdef usm_ndarray from_dlpack_capsule(object py_caps) except +:
328337
device_id = dlm_tensor.dl_tensor.device.device_id
329338
root_device = dpctl.SyclDevice(str(<int>device_id))
330339
try:
331-
default_context = root_device.sycl_platform.default_context
340+
if _IS_LINUX:
341+
default_context = root_device.sycl_platform.default_context
342+
else:
343+
default_context = None
332344
except RuntimeError:
333345
default_context = dpctl.SyclQueue(root_device).sycl_context
334346
if dlm_tensor.dl_tensor.data is NULL:

0 commit comments

Comments
 (0)