@@ -194,29 +194,35 @@ cpdef dparray dpnp_max(dparray input, axis):
194
194
return _dpnp_max(input , axis_, output_shape)
195
195
196
196
197
- cpdef dparray _dpnp_mean(dparray input ):
197
+ cpdef utils.dpnp_descriptor _dpnp_mean(utils.dpnp_descriptor input ):
198
198
cdef shape_type_c input_shape = input .shape
199
199
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(input .dtype)
200
200
201
201
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_MEAN, param1_type, param1_type)
202
202
203
- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
204
- cdef dparray result = dparray((1 ,), dtype = result_type)
203
+ cdef utils.dpnp_descriptor result = utils.create_output_descriptor((1 ,), kernel_data.return_type, None )
205
204
206
205
cdef custom_statistic_1in_1out_func_ptr_t func = < custom_statistic_1in_1out_func_ptr_t > kernel_data.ptr
207
206
208
207
# stub for interface support
209
208
cdef shape_type_c axis
210
209
cdef Py_ssize_t axis_size = 0
211
210
212
- func(input .get_data(), result.get_data(), < size_t * > input_shape.data(), input .ndim, < size_t * > axis.data(), axis_size)
211
+ func(input .get_data(),
212
+ result.get_data(),
213
+ < size_t * > input_shape.data(),
214
+ input .ndim,
215
+ < size_t * > axis.data(),
216
+ axis_size)
213
217
214
218
return result
215
219
216
220
217
- cpdef dparray dpnp_mean(dparray input , axis):
221
+ cpdef object dpnp_mean(utils.dpnp_descriptor input , axis):
222
+ cdef shape_type_c output_shape
223
+
218
224
if axis is None :
219
- return _dpnp_mean(input )
225
+ return _dpnp_mean(input ).get_pyobj()
220
226
221
227
cdef long size_input = input .size
222
228
cdef shape_type_c shape_input = input .shape
@@ -235,10 +241,9 @@ cpdef dparray dpnp_mean(dparray input, axis):
235
241
axis_ = axis
236
242
237
243
if axis_ is None :
238
- output_shape = dparray(1 , dtype = dpnp.int64)
239
- output_shape[0 ] = 1
244
+ output_shape.push_back(1 )
240
245
else :
241
- output_shape = dparray( len (shape_input) - len (axis_), dtype = dpnp.int64 )
246
+ output_shape = ( 0 , ) * ( len (shape_input) - len (axis_))
242
247
ind = 0
243
248
for id , shape_axis in enumerate (shape_input):
244
249
if id not in axis_:
@@ -295,7 +300,7 @@ cpdef dparray dpnp_mean(dparray input, axis):
295
300
for i, result_axis_val in enumerate (result_axis):
296
301
result_offset += (output_shape_offsets[i] * result_axis_val)
297
302
298
- input_elem = input .item(source_idx)
303
+ input_elem = input .get_pyobj(). item(source_idx)
299
304
if axis_ is None :
300
305
if result_array[0 ] is None :
301
306
result_array[0 ] = input_elem
@@ -317,22 +322,26 @@ cpdef dparray dpnp_mean(dparray input, axis):
317
322
return dpnp_result_array / del_
318
323
319
324
320
- cpdef dparray dpnp_median(utils.dpnp_descriptor array1):
325
+ cpdef utils.dpnp_descriptor dpnp_median(utils.dpnp_descriptor array1):
321
326
cdef shape_type_c x1_shape = array1.shape
322
327
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(array1.dtype)
323
328
324
329
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_MEDIAN, param1_type, param1_type)
325
330
326
- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
327
- cdef dparray result = dparray((1 ,), dtype = result_type)
331
+ cdef utils.dpnp_descriptor result = utils.create_output_descriptor((1 ,), kernel_data.return_type, None )
328
332
329
333
cdef custom_statistic_1in_1out_func_ptr_t func = < custom_statistic_1in_1out_func_ptr_t > kernel_data.ptr
330
334
331
335
# stub for interface support
332
336
cdef shape_type_c axis
333
337
cdef Py_ssize_t axis_size = 0
334
338
335
- func(array1.get_data(), result.get_data(), < size_t * > x1_shape.data(), array1.ndim, < size_t * > axis.data(), axis_size)
339
+ func(array1.get_data(),
340
+ result.get_data(),
341
+ < size_t * > x1_shape.data(),
342
+ array1.ndim,
343
+ < size_t * > axis.data(),
344
+ axis_size)
336
345
337
346
return result
338
347
0 commit comments