Skip to content

Commit 1748358

Browse files
authored
replace direct dparray ctor with utils func (#750)
* replace direct dparray ctor with utils func * scalar handling
1 parent afbced4 commit 1748358

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

dpnp/dpnp_algo/dpnp_algo.pxd

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,6 @@ ctypedef void(*fptr_2in_1out_t)(void *, const void * , const size_t, const long
228228
ctypedef void(*fptr_blas_gemm_2in_1out_t)(void * , void * , void * , size_t, size_t, size_t)
229229
ctypedef void(*dpnp_reduction_c_t)(void * , const void * , const size_t*, const size_t, const long*, const size_t, const void * , const long*)
230230

231-
cdef dparray call_fptr_1out(DPNPFuncName fptr_name, result_shape, result_dtype)
232-
cdef dparray call_fptr_1in_1out(DPNPFuncName fptr_name, dparray x1, dparray_shape_type result_shape)
233-
234231
cpdef dparray dpnp_astype(dparray array1, dtype_target)
235232
cpdef dparray dpnp_flatten(dparray array1)
236233

dpnp/dpnp_algo/dpnp_algo.pyx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,18 +240,16 @@ cpdef dpnp_DPNPFuncType_to_dtype(size_t type):
240240
utils.checker_throw_type_error("dpnp_DPNPFuncType_to_dtype", type)
241241

242242

243-
cdef dparray call_fptr_1out(DPNPFuncName fptr_name, result_shape, result_dtype):
243+
cdef dparray call_fptr_1out(DPNPFuncName fptr_name, dparray_shape_type result_shape, result_dtype):
244244

245245
# Convert string type names (dparray.dtype) to C enum DPNPFuncType
246246
cdef DPNPFuncType dtype_in = dpnp_dtype_to_DPNPFuncType(result_dtype)
247247

248248
# get the FPTR data structure
249249
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(fptr_name, dtype_in, dtype_in)
250250

251-
result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
252-
253251
# Create result array with type given by FPTR data
254-
cdef dparray result = dparray(result_shape, dtype=result_type)
252+
cdef dparray result = utils.create_output_array(result_shape, kernel_data.return_type, None)
255253

256254
cdef fptr_1out_t func = <fptr_1out_t > kernel_data.ptr
257255
# Call FPTR function
@@ -268,9 +266,8 @@ cdef dparray call_fptr_1in_1out(DPNPFuncName fptr_name, dparray x1, dparray_shap
268266
""" get the FPTR data structure """
269267
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(fptr_name, param1_type, param1_type)
270268

271-
result_type = dpnp_DPNPFuncType_to_dtype( < size_t > kernel_data.return_type)
272269
""" Create result array with type given by FPTR data """
273-
cdef dparray result = dparray(result_shape, dtype=result_type)
270+
cdef dparray result = utils.create_output_array(result_shape, kernel_data.return_type, None)
274271

275272
cdef fptr_1in_1out_t func = <fptr_1in_1out_t > kernel_data.ptr
276273
""" Call FPTR function """

dpnp/dpnp_algo/dpnp_algo_arraycreation.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,11 @@ cpdef list dpnp_meshgrid(xi, copy, sparse, indexing):
259259

260260

261261
cpdef dparray dpnp_ones(result_shape, result_dtype):
262-
return call_fptr_1out(DPNP_FN_ONES, result_shape, result_dtype)
262+
return call_fptr_1out(DPNP_FN_ONES, utils._object_to_tuple(result_shape), result_dtype)
263263

264264

265265
cpdef dparray dpnp_ones_like(result_shape, result_dtype):
266-
return call_fptr_1out(DPNP_FN_ONES_LIKE, result_shape, result_dtype)
266+
return call_fptr_1out(DPNP_FN_ONES_LIKE, utils._object_to_tuple(result_shape), result_dtype)
267267

268268

269269
cpdef dparray dpnp_trace(arr, offset=0, axis1=0, axis2=1, dtype=None, out=None):
@@ -369,8 +369,8 @@ cpdef dparray dpnp_vander(dparray x1, int N, int increasing):
369369

370370

371371
cpdef dparray dpnp_zeros(result_shape, result_dtype):
372-
return call_fptr_1out(DPNP_FN_ZEROS, result_shape, result_dtype)
372+
return call_fptr_1out(DPNP_FN_ZEROS, utils._object_to_tuple(result_shape), result_dtype)
373373

374374

375375
cpdef dparray dpnp_zeros_like(result_shape, result_dtype):
376-
return call_fptr_1out(DPNP_FN_ZEROS_LIKE, result_shape, result_dtype)
376+
return call_fptr_1out(DPNP_FN_ZEROS_LIKE, utils._object_to_tuple(result_shape), result_dtype)

0 commit comments

Comments
 (0)