File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,22 @@ def _copy_from_numpy_into(dst, np_ary):
92
92
raise TypeError (f"Expected numpy.ndarray, got { type (np_ary )} " )
93
93
if not isinstance (dst , dpt .usm_ndarray ):
94
94
raise TypeError (f"Expected usm_ndarray, got { type (dst )} " )
95
- src_ary = np .broadcast_to (np_ary , dst .shape )
95
+ if np_ary .flags ["OWNDATA" ]:
96
+ Xnp = np_ary
97
+ else :
98
+ # Determine base of input array
99
+ base = np_ary .base
100
+ while isinstance (base , np .ndarray ):
101
+ base = base .base
102
+ if isinstance (base , dpm ._memory ._Memory ):
103
+ # we must perform a copy, since subsequent
104
+ # _copy_numpy_ndarray_into_usm_ndarray is implemented using
105
+ # sycl::buffer, and using USM-pointers with sycl::buffer
106
+ # results is undefined behavior
107
+ Xnp = np_ary .copy ()
108
+ else :
109
+ Xnp = np_ary
110
+ src_ary = np .broadcast_to (Xnp , dst .shape )
96
111
copy_q = dst .sycl_queue
97
112
if copy_q .sycl_device .has_aspect_fp64 is False :
98
113
src_ary_dt_c = src_ary .dtype .char
You can’t perform that action at this time.
0 commit comments