@@ -57,18 +57,18 @@ ctypedef void(*fptr_custom_std_var_1in_1out_t)(void *, void * , size_t * , size_
57
57
ctypedef void (* custom_statistic_1in_1out_func_ptr_t)(void * , void * , size_t * , size_t, size_t * , size_t)
58
58
59
59
60
- cdef dparray call_fptr_custom_std_var_1in_1out(DPNPFuncName fptr_name, utils.dpnp_descriptor x1, ddof):
60
+ cdef utils.dpnp_descriptor call_fptr_custom_std_var_1in_1out(DPNPFuncName fptr_name, utils.dpnp_descriptor x1, ddof):
61
61
cdef shape_type_c x1_shape = x1.shape
62
62
63
- """ Convert string type names (dparray .dtype) to C enum DPNPFuncType """
63
+ """ Convert string type names (array .dtype) to C enum DPNPFuncType """
64
64
cdef DPNPFuncType param_type = dpnp_dtype_to_DPNPFuncType(x1.dtype)
65
65
66
66
""" get the FPTR data structure """
67
67
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(fptr_name, param_type, DPNP_FT_NONE)
68
68
69
- result_type = dpnp_DPNPFuncType_to_dtype( < size_t > kernel_data.return_type)
70
- """ Create result array with type given by FPTR data """
71
- cdef dparray result = dparray(( 1 ,), dtype = result_type )
69
+ # ceate result array with type given by FPTR data
70
+ cdef shape_type_c result_shape = ( 1 ,)
71
+ cdef utils.dpnp_descriptor result = utils.create_output_descriptor(result_shape, kernel_data.return_type, None )
72
72
73
73
cdef fptr_custom_std_var_1in_1out_t func = < fptr_custom_std_var_1in_1out_t > kernel_data.ptr
74
74
@@ -92,7 +92,7 @@ cpdef dpnp_average(utils.dpnp_descriptor x1):
92
92
return (return_type(array_sum / x1.size))
93
93
94
94
95
- cpdef dparray dpnp_correlate(utils.dpnp_descriptor x1, utils.dpnp_descriptor x2):
95
+ cpdef utils.dpnp_descriptor dpnp_correlate(utils.dpnp_descriptor x1, utils.dpnp_descriptor x2):
96
96
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(x1.dtype)
97
97
cdef DPNPFuncType param2_type = dpnp_dtype_to_DPNPFuncType(x2.dtype)
98
98
@@ -101,9 +101,9 @@ cpdef dparray dpnp_correlate(utils.dpnp_descriptor x1, utils.dpnp_descriptor x2)
101
101
102
102
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_CORRELATE, param1_type, param2_type)
103
103
104
- result_type = dpnp_DPNPFuncType_to_dtype( < size_t > kernel_data.return_type)
105
-
106
- cdef dparray result = dparray( 1 , dtype = result_type )
104
+ # ceate result array with type given by FPTR data
105
+ cdef shape_type_c result_shape = ( 1 ,)
106
+ cdef utils.dpnp_descriptor result = utils.create_output_descriptor(result_shape, kernel_data.return_type, None )
107
107
108
108
cdef fptr_2in_1out_t func = < fptr_2in_1out_t > kernel_data.ptr
109
109
@@ -120,7 +120,7 @@ cpdef utils.dpnp_descriptor dpnp_cov(utils.dpnp_descriptor array1):
120
120
if array1.ndim == 1 :
121
121
input_shape.insert(input_shape.begin(), 1 )
122
122
123
- # convert string type names (dparray .dtype) to C enum DPNPFuncType
123
+ # convert string type names (array .dtype) to C enum DPNPFuncType
124
124
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(array1.dtype)
125
125
126
126
# get the FPTR data structure
@@ -137,14 +137,14 @@ cpdef utils.dpnp_descriptor dpnp_cov(utils.dpnp_descriptor array1):
137
137
return result
138
138
139
139
140
- cpdef dparray _dpnp_max(dparray input , _axis_, output_shape ):
140
+ cdef utils.dpnp_descriptor _dpnp_max(utils.dpnp_descriptor input , _axis_, shape_type_c result_shape ):
141
141
cdef shape_type_c input_shape = input .shape
142
142
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(input .dtype)
143
143
144
144
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_MAX, param1_type, param1_type)
145
145
146
- result_type = dpnp_DPNPFuncType_to_dtype( < size_t > kernel_data.return_type)
147
- cdef dparray result = dparray(output_shape, dtype = result_type )
146
+ # ceate result array with type given by FPTR data
147
+ cdef utils.dpnp_descriptor result = utils.create_output_descriptor(result_shape, kernel_data.return_type, None )
148
148
149
149
cdef custom_statistic_1in_1out_func_ptr_t func = < custom_statistic_1in_1out_func_ptr_t > kernel_data.ptr
150
150
cdef shape_type_c axis
@@ -160,16 +160,16 @@ cpdef dparray _dpnp_max(dparray input, _axis_, output_shape):
160
160
161
161
func(input .get_data(), result.get_data(), < size_t * > input_shape.data(), input .ndim, < size_t * > axis_.data(), axis_size)
162
162
163
- dpnp_array = dpnp.array(result, dtype = input .dtype)
164
- dpnp_result_array = dpnp_array.reshape(output_shape)
165
- return dpnp_result_array
163
+ return result
166
164
167
165
168
- cpdef dparray dpnp_max(dparray input , axis):
166
+ cpdef utils.dpnp_descriptor dpnp_max(utils.dpnp_descriptor input , axis):
169
167
cdef shape_type_c shape_input = input .shape
168
+ cdef shape_type_c output_shape
169
+
170
170
if axis is None :
171
171
axis_ = axis
172
- output_shape = 1
172
+ output_shape.push_back( 1 )
173
173
else :
174
174
if isinstance (axis, int ):
175
175
if axis < 0 :
@@ -185,12 +185,13 @@ cpdef dparray dpnp_max(dparray input, axis):
185
185
_axis_.append(axis[i])
186
186
axis_ = tuple (_axis_)
187
187
188
- output_shape = dparray (len (shape_input) - len (axis_), dtype = numpy.int64 )
188
+ output_shape.resize (len (shape_input) - len (axis_), 0 )
189
189
ind = 0
190
190
for id , shape_axis in enumerate (shape_input):
191
191
if id not in axis_:
192
192
output_shape[ind] = shape_axis
193
193
ind += 1
194
+
194
195
return _dpnp_max(input , axis_, output_shape)
195
196
196
197
@@ -407,29 +408,29 @@ cpdef utils.dpnp_descriptor dpnp_min(utils.dpnp_descriptor input, axis):
407
408
return _dpnp_min(input , axis_, shape_output)
408
409
409
410
410
- cpdef dparray dpnp_nanvar(utils.dpnp_descriptor arr, ddof):
411
- cdef dparray mask_arr = dpnp.isnan (arr)
412
- n = sum (mask_arr)
411
+ cpdef utils.dpnp_descriptor dpnp_nanvar(utils.dpnp_descriptor arr, ddof):
412
+ cdef utils.dpnp_descriptor mask_arr = dpnp_isnan (arr)
413
+ n = sum (mask_arr.get_pyobj() )
413
414
res_size = arr.size - n
414
415
415
416
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(arr.dtype)
416
417
417
418
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_NANVAR, param1_type, param1_type)
418
419
419
- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
420
- cdef dparray without_nan_arr = dparray((res_size, ), dtype = result_type)
420
+ # ceate result array with type given by FPTR data
421
+ cdef shape_type_c result_shape = utils._object_to_tuple(res_size)
422
+ cdef utils.dpnp_descriptor result = utils.create_output_descriptor(result_shape, kernel_data.return_type, None )
421
423
422
424
cdef fptr_custom_nanvar_t func = < fptr_custom_nanvar_t > kernel_data.ptr
423
425
424
- func(arr.get_data(), mask_arr.get_data(), without_nan_arr .get_data(), arr.size)
426
+ func(arr.get_data(), mask_arr.get_data(), result .get_data(), arr.size)
425
427
426
- without_nan_arr_desc = dpnp.get_dpnp_descriptor(without_nan_arr)
427
- return call_fptr_custom_std_var_1in_1out(DPNP_FN_VAR, without_nan_arr_desc, ddof)
428
+ return call_fptr_custom_std_var_1in_1out(DPNP_FN_VAR, result, ddof)
428
429
429
430
430
- cpdef dparray dpnp_std(utils.dpnp_descriptor a, size_t ddof):
431
+ cpdef utils.dpnp_descriptor dpnp_std(utils.dpnp_descriptor a, size_t ddof):
431
432
return call_fptr_custom_std_var_1in_1out(DPNP_FN_STD, a, ddof)
432
433
433
434
434
- cpdef dparray dpnp_var(utils.dpnp_descriptor a, size_t ddof):
435
+ cpdef utils.dpnp_descriptor dpnp_var(utils.dpnp_descriptor a, size_t ddof):
435
436
return call_fptr_custom_std_var_1in_1out(DPNP_FN_VAR, a, ddof)
0 commit comments