File tree Expand file tree Collapse file tree 1 file changed +1
-20
lines changed Expand file tree Collapse file tree 1 file changed +1
-20
lines changed Original file line number Diff line number Diff line change 41
41
def _copy_to_numpy (ary ):
42
42
if not isinstance (ary , dpt .usm_ndarray ):
43
43
raise TypeError (f"Expected dpctl.tensor.usm_ndarray, got { type (ary )} " )
44
- if ary .size == 0 :
45
- # no data needs to be copied for zero sized array
46
- return np .ndarray (ary .shape , dtype = ary .dtype )
47
- nb = ary .usm_data .nbytes
48
- q = ary .sycl_queue
49
- hh = dpm .MemoryUSMHost (nb , queue = q )
50
- h = np .ndarray (nb , dtype = "u1" , buffer = hh ).view (ary .dtype )
51
- itsz = ary .itemsize
52
- strides_bytes = tuple (si * itsz for si in ary .strides )
53
- offset = ary ._element_offset * itsz
54
- # ensure that content of ary.usm_data is final
55
- q .wait ()
56
- hh .copy_from_device (ary .usm_data )
57
- return np .ndarray (
58
- ary .shape ,
59
- dtype = ary .dtype ,
60
- buffer = h ,
61
- strides = strides_bytes ,
62
- offset = offset ,
63
- )
44
+ return ary .__array__ ()
64
45
65
46
66
47
def _copy_from_numpy (np_ary , usm_type = "device" , sycl_queue = None ):
You can’t perform that action at this time.
0 commit comments