@@ -73,7 +73,7 @@ cpdef dparray dpnp_choose(input, choices):
73
73
74
74
75
75
cpdef tuple dpnp_diag_indices(n, ndim):
76
- cdef dparray res_item = dpnp.arange(n, dtype = dpnp.int64)
76
+ res_item = dpnp.arange(n, dtype = dpnp.int64)
77
77
78
78
# yes, all are the same item
79
79
result = []
@@ -123,8 +123,8 @@ cpdef utils.dpnp_descriptor dpnp_diagonal(dpnp_descriptor input, offset=0):
123
123
124
124
cpdef dpnp_fill_diagonal(dpnp_descriptor input , val):
125
125
cdef shape_type_c input_shape = input .shape
126
- val_arr = dparray( 1 , dtype = input .dtype)
127
- val_arr[0 ] = val
126
+ cdef utils.dpnp_descriptor val_arr = utils_py.create_output_descriptor_py(( 1 ,), input .dtype, None )
127
+ val_arr.get_pyobj() [0 ] = val
128
128
129
129
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(input .dtype)
130
130
@@ -135,7 +135,7 @@ cpdef dpnp_fill_diagonal(dpnp_descriptor input, val):
135
135
func(input .get_data(), val_arr.get_data(), < size_t * > input_shape.data(), input .ndim)
136
136
137
137
138
- cpdef dparray dpnp_indices(dimensions):
138
+ cpdef object dpnp_indices(dimensions):
139
139
len_dimensions = len (dimensions)
140
140
res_shape = []
141
141
res_shape.append(len_dimensions)
@@ -196,12 +196,12 @@ cpdef tuple dpnp_nonzero(dparray in_array1):
196
196
197
197
198
198
cpdef dpnp_place(dpnp_descriptor arr, object mask, dpnp_descriptor vals):
199
- mask_ = dparray( mask.size, dtype = dpnp.int64)
199
+ cdef utils.dpnp_descriptor mask_ = utils_py.create_output_descriptor_py(( mask.size,), dpnp.int64, None )
200
200
for i in range (mask.size):
201
201
if mask[i]:
202
- mask_[i] = 1
202
+ mask_.get_pyobj() [i] = 1
203
203
else :
204
- mask_[i] = 0
204
+ mask_.get_pyobj() [i] = 0
205
205
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(arr.dtype)
206
206
207
207
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_PLACE, param1_type, param1_type)
@@ -218,23 +218,23 @@ cpdef dpnp_put(dpnp_descriptor input, object ind, v):
218
218
ind_size = 1
219
219
else :
220
220
ind_size = len (ind)
221
- ind_array = dparray( ind_size, dtype = dpnp.int64)
221
+ cdef utils.dpnp_descriptor ind_array = utils_py.create_output_descriptor_py(( ind_size,), dpnp.int64, None )
222
222
if dpnp.isscalar(ind):
223
- ind_array[0 ] = ind
223
+ ind_array.get_pyobj() [0 ] = ind
224
224
else :
225
225
for i in range (ind_size):
226
- ind_array[i] = ind[i]
226
+ ind_array.get_pyobj() [i] = ind[i]
227
227
228
228
if dpnp.isscalar(v):
229
229
v_size = 1
230
230
else :
231
231
v_size = len (v)
232
- v_array = dparray( v_size, dtype = input .dtype)
232
+ cdef utils.dpnp_descriptor v_array = utils_py.create_output_descriptor_py(( v_size,), input .dtype, None )
233
233
if dpnp.isscalar(v):
234
- v_array[0 ] = v
234
+ v_array.get_pyobj() [0 ] = v
235
235
else :
236
236
for i in range (v_size):
237
- v_array[i] = v[i]
237
+ v_array.get_pyobj() [i] = v[i]
238
238
239
239
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(input .dtype)
240
240
@@ -263,7 +263,7 @@ cpdef dpnp_putmask(object arr, object mask, object values):
263
263
arr[i] = values[i % values_size]
264
264
265
265
266
- cpdef dparray dpnp_select(condlist, choicelist, default):
266
+ cpdef object dpnp_select(condlist, choicelist, default):
267
267
size_ = condlist[0 ].size
268
268
res_array = dparray(size_, dtype = choicelist[0 ].dtype)
269
269
pass_val = {a: default for a in range (size_)}
@@ -279,13 +279,12 @@ cpdef dparray dpnp_select(condlist, choicelist, default):
279
279
return res_array.reshape(condlist[0 ].shape)
280
280
281
281
282
- cpdef dparray dpnp_take(dpnp_descriptor input , dpnp_descriptor indices):
282
+ cpdef utils.dpnp_descriptor dpnp_take(utils. dpnp_descriptor input , utils. dpnp_descriptor indices):
283
283
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(input .dtype)
284
284
285
285
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_TAKE, param1_type, param1_type)
286
286
287
- result_type = dpnp_DPNPFuncType_to_dtype( < size_t > kernel_data.return_type)
288
- cdef dparray result = dparray(indices.shape, dtype = result_type)
287
+ cdef utils.dpnp_descriptor result = utils.create_output_descriptor(indices.shape, kernel_data.return_type, None )
289
288
290
289
cdef custom_indexing_2in_1out_func_ptr_t func = < custom_indexing_2in_1out_func_ptr_t > kernel_data.ptr
291
290
@@ -294,9 +293,10 @@ cpdef dparray dpnp_take(dpnp_descriptor input, dpnp_descriptor indices):
294
293
return result
295
294
296
295
297
- cpdef dparray dpnp_take_along_axis(object arr, object indices, int axis):
296
+ cpdef object dpnp_take_along_axis(object arr, object indices, int axis):
298
297
cdef long size_arr = arr.size
299
298
cdef shape_type_c shape_arr = arr.shape
299
+ cdef shape_type_c output_shape
300
300
cdef long size_indices = indices.size
301
301
res_type = arr.dtype
302
302
@@ -305,7 +305,7 @@ cpdef dparray dpnp_take_along_axis(object arr, object indices, int axis):
305
305
res_shape_list[axis] = 1
306
306
res_shape = tuple (res_shape_list)
307
307
308
- output_shape = dparray( len (shape_arr) - 1 , dtype = numpy.int64 )
308
+ output_shape = ( 0 ,) * ( len (shape_arr) - 1 )
309
309
ind = 0
310
310
for id , shape_axis in enumerate (shape_arr):
311
311
if id != axis:
@@ -396,9 +396,9 @@ cpdef tuple dpnp_tril_indices(n, k=0, m=None):
396
396
array1.append(i)
397
397
array2.append(j)
398
398
399
- dparray1 = dpnp.array(array1, dtype = dpnp.int64)
400
- dparray2 = dpnp.array(array2, dtype = dpnp.int64)
401
- return (dparray1, dparray2 )
399
+ array1 = dpnp.array(array1, dtype = dpnp.int64)
400
+ array2 = dpnp.array(array2, dtype = dpnp.int64)
401
+ return (array1, array2 )
402
402
403
403
404
404
cpdef tuple dpnp_tril_indices_from(dpnp_descriptor arr, k = 0 ):
@@ -421,9 +421,9 @@ cpdef tuple dpnp_tril_indices_from(dpnp_descriptor arr, k=0):
421
421
array1.append(i)
422
422
array2.append(j)
423
423
424
- dparray1 = dpnp.array(array1, dtype = dpnp.int64)
425
- dparray2 = dpnp.array(array2, dtype = dpnp.int64)
426
- return (dparray1, dparray2 )
424
+ array1 = dpnp.array(array1, dtype = dpnp.int64)
425
+ array2 = dpnp.array(array2, dtype = dpnp.int64)
426
+ return (array1, array2 )
427
427
428
428
429
429
cpdef tuple dpnp_triu_indices(n, k = 0 , m = None ):
@@ -440,9 +440,9 @@ cpdef tuple dpnp_triu_indices(n, k=0, m=None):
440
440
array1.append(i)
441
441
array2.append(j)
442
442
443
- dparray1 = dpnp.array(array1, dtype = dpnp.int64)
444
- dparray2 = dpnp.array(array2, dtype = dpnp.int64)
445
- return (dparray1, dparray2 )
443
+ array1 = dpnp.array(array1, dtype = dpnp.int64)
444
+ array2 = dpnp.array(array2, dtype = dpnp.int64)
445
+ return (array1, array2 )
446
446
447
447
448
448
cpdef tuple dpnp_triu_indices_from(dpnp_descriptor arr, k = 0 ):
@@ -461,6 +461,6 @@ cpdef tuple dpnp_triu_indices_from(dpnp_descriptor arr, k=0):
461
461
array1.append(i)
462
462
array2.append(j)
463
463
464
- dparray1 = dpnp.array(array1, dtype = dpnp.int64)
465
- dparray2 = dpnp.array(array2, dtype = dpnp.int64)
466
- return (dparray1, dparray2 )
464
+ array1 = dpnp.array(array1, dtype = dpnp.int64)
465
+ array2 = dpnp.array(array2, dtype = dpnp.int64)
466
+ return (array1, array2 )
0 commit comments