@@ -1025,10 +1025,14 @@ cdef class usm_ndarray:
1025
1025
cdef c_dpmem._Memory arr_buf
1026
1026
d = Device.create_device(target_device)
1027
1027
1028
- if (stream is None or not isinstance (stream, dpctl.SyclQueue) or
1029
- stream == self .sycl_queue):
1028
+ if (stream is None or stream == self .sycl_queue):
1030
1029
pass
1031
1030
else :
1031
+ if not isinstance (stream, dpctl.SyclQueue):
1032
+ raise TypeError (
1033
+ " stream argument type was expected to be dpctl.SyclQueue,"
1034
+ f" got {type(stream)} instead"
1035
+ )
1032
1036
ev = self .sycl_queue.submit_barrier()
1033
1037
stream.submit_barrier(dependent_events = [ev])
1034
1038
@@ -1203,10 +1207,15 @@ cdef class usm_ndarray:
1203
1207
# legacy path for DLManagedTensor
1204
1208
# copy kwarg ignored because copy flag can't be set
1205
1209
_caps = c_dlpack.to_dlpack_capsule(self )
1206
- if (stream is None or type (stream) is not dpctl.SyclQueue or
1207
- stream == self .sycl_queue):
1210
+ if (stream is None or stream == self .sycl_queue):
1208
1211
pass
1209
1212
else :
1213
+ if not isinstance (stream, dpctl.SyclQueue):
1214
+ raise TypeError (
1215
+ " stream keyword argument type is expected to "
1216
+ " be dpctl.SyclQueue, "
1217
+ f" got {type(stream)} instead"
1218
+ )
1210
1219
ev = self .sycl_queue.submit_barrier()
1211
1220
stream.submit_barrier(dependent_events = [ev])
1212
1221
return _caps
@@ -1555,17 +1564,17 @@ cdef class usm_ndarray:
1555
1564
def __array__ (self , dtype = None , /, *, copy = None ):
1556
1565
""" NumPy's array protocol method to disallow implicit conversion.
1557
1566
1558
- Without this definition, `numpy.asarray(usm_ar)` converts
1559
- usm_ndarray instance into NumPy array with data type `object`
1560
- and every element being 0d usm_ndarray.
1567
+ Without this definition, `numpy.asarray(usm_ar)` converts
1568
+ usm_ndarray instance into NumPy array with data type `object`
1569
+ and every element being 0d usm_ndarray.
1561
1570
1562
1571
https://github.com/IntelPython/dpctl/pull/1384#issuecomment-1707212972
1563
- """
1572
+ """
1564
1573
raise TypeError (
1565
1574
" Implicit conversion to a NumPy array is not allowed. "
1566
- " Use `dpctl.tensor.asnumpy` to copy data from this "
1567
- " `dpctl.tensor.usm_ndarray` instance to NumPy array"
1568
- )
1575
+ " Use `dpctl.tensor.asnumpy` to copy data from this "
1576
+ " `dpctl.tensor.usm_ndarray` instance to NumPy array"
1577
+ )
1569
1578
1570
1579
1571
1580
cdef usm_ndarray _real_view(usm_ndarray ary):
0 commit comments