Skip to content

Commit e57df0e

Browse files
densmirnoleksandr-pavlyk
authored andcommitted
Revert fallback to numpy
1 parent 92c2fae commit e57df0e

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed

dpnp/dpnp_utils/dpnp_algo_utils.pyx

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -97,27 +97,8 @@ def convert_list_args(input_list):
9797

9898
return result_list
9999

100-
def copy_from_origin(src, device=None, usm_type="device", sycl_queue=None):
101-
"""Copy result from origin."""
102-
if not isinstance(src, numpy.ndarray):
103-
return src
104-
105-
if src.size == 0:
106-
return dpnp_container.empty(src.shape,
107-
dtype=src.dtype,
108-
device=device,
109-
usm_type=usm_type,
110-
sycl_queue=sycl_queue)
111-
112-
array_obj = dpctl.tensor._copy_utils.from_numpy(src,
113-
device=device,
114-
usm_type=usm_type,
115-
sycl_queue=sycl_queue)
116100

117-
return dpnp.dpnp_array.dpnp_array(src.shape, buffer=array_obj)
118-
119-
120-
def copy_from_origin_into(dst, src):
101+
def copy_from_origin(dst, src):
121102
"""Copy origin result to output result."""
122103
if config.__DPNP_OUTPUT_DPCTL__ and hasattr(dst, "__sycl_usm_array_interface__"):
123104
if src.size:
@@ -164,7 +145,7 @@ def call_origin(function, *args, **kwargs):
164145
if args and args_new:
165146
arg, arg_new = args[0], args_new[0]
166147
if isinstance(arg_new, numpy.ndarray):
167-
copy_from_origin_into(arg, arg_new)
148+
copy_from_origin(arg, arg_new)
168149
elif isinstance(arg_new, list):
169150
for i, val in enumerate(arg_new):
170151
arg[i] = val
@@ -176,18 +157,20 @@ def call_origin(function, *args, **kwargs):
176157
if (kwargs_dtype is not None):
177158
result_dtype = kwargs_dtype
178159

179-
result = copy_from_origin(result_origin)
160+
result = dpnp_container.empty(result_origin.shape, dtype=result_dtype)
180161
else:
181162
result = kwargs_out
182-
copy_from_origin_into(result, result_origin)
163+
164+
copy_from_origin(result, result_origin)
183165

184166
elif isinstance(result, tuple):
185167
# convert tuple(fallback_array) to tuple(result_array)
186168
result_list = []
187169
for res_origin in result:
188170
res = res_origin
189171
if isinstance(res_origin, numpy.ndarray):
190-
res = copy_from_origin(res_origin)
172+
res = dpnp_container.empty(res_origin.shape, dtype=res_origin.dtype)
173+
copy_from_origin(res, res_origin)
191174
result_list.append(res)
192175

193176
result = tuple(result_list)

0 commit comments

Comments
 (0)