@@ -171,12 +171,13 @@ cpdef object dpnp_indices(dimensions):
171
171
return dpnp_result
172
172
173
173
174
- cpdef tuple dpnp_nonzero(dparray in_array1):
174
+ cpdef tuple dpnp_nonzero(utils.dpnp_descriptor in_array1):
175
175
cdef shape_type_c shape_arr = in_array1.shape
176
176
res_count = in_array1.ndim
177
177
178
178
# have to go through array one extra time to count size of result arrays
179
- res_size = dpnp.count_nonzero(in_array1)
179
+ res_size_obj = dpnp_count_nonzero(in_array1)
180
+ cdef size_t res_size = dpnp.convert_single_elem_array_to_scalar(res_size_obj.get_pyobj())
180
181
181
182
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(in_array1.dtype)
182
183
@@ -185,12 +186,15 @@ cpdef tuple dpnp_nonzero(dparray in_array1):
185
186
cdef fptr_dpnp_nonzero_t func = < fptr_dpnp_nonzero_t > kernel_data.ptr
186
187
187
188
res_list = []
189
+ cdef utils.dpnp_descriptor res_arr
190
+ cdef shape_type_c result_shape
188
191
for j in range (res_count):
189
- res_arr = dparray((res_size, ), dtype = dpnp.int64)
192
+ result_shape = utils._object_to_tuple(res_size)
193
+ res_arr = utils_py.create_output_descriptor_py(result_shape, dpnp.int64, None )
190
194
191
195
func(in_array1.get_data(), res_arr.get_data(), < size_t * > shape_arr.data(), in_array1.ndim, j)
192
196
193
- res_list.append(res_arr)
197
+ res_list.append(res_arr.get_pyobj() )
194
198
195
199
result = utils._object_to_tuple(res_list)
196
200
@@ -266,19 +270,20 @@ cpdef dpnp_putmask(object arr, object mask, object values):
266
270
267
271
268
272
cpdef object dpnp_select(condlist, choicelist, default):
269
- size_ = condlist[0 ].size
270
- res_array = dparray(size_, dtype = choicelist[0 ].dtype)
273
+ cdef size_t size_ = condlist[0 ].size
274
+ cdef utils.dpnp_descriptor res_array = utils_py.create_output_descriptor_py(condlist[0 ].shape, choicelist[0 ].dtype, None )
275
+
271
276
pass_val = {a: default for a in range (size_)}
272
277
for i in range (len (condlist)):
273
278
for j in range (size_):
274
279
if (condlist[i])[j]:
275
- res_array[j] = (choicelist[i])[j]
280
+ res_array.get_pyobj() [j] = (choicelist[i])[j]
276
281
pass_val.pop(j)
277
282
278
283
for ind, val in pass_val.items():
279
- res_array[ind] = val
284
+ res_array.get_pyobj() [ind] = val
280
285
281
- return res_array.reshape(condlist[ 0 ].shape)
286
+ return res_array
282
287
283
288
284
289
cpdef utils.dpnp_descriptor dpnp_take(utils.dpnp_descriptor input , utils.dpnp_descriptor indices):
@@ -373,7 +378,7 @@ cpdef object dpnp_take_along_axis(object arr, object indices, int axis):
373
378
return dpnp_result_array
374
379
375
380
else :
376
- result_array = dparray (shape_arr, dtype = res_type)
381
+ result_array = utils_py.create_output_descriptor_py (shape_arr, res_type, None ).get_pyobj( )
377
382
for i in range (size_arr):
378
383
ind = size_indices * (i // size_indices) + indices[i % size_indices]
379
384
result_array[i] = arr[ind]
0 commit comments