@@ -41,10 +41,8 @@ __all__ += [
41
41
" dpnp_diagonal" ,
42
42
" dpnp_fill_diagonal" ,
43
43
" dpnp_indices" ,
44
- " dpnp_put_along_axis" ,
45
44
" dpnp_putmask" ,
46
45
" dpnp_select" ,
47
- " dpnp_take_along_axis" ,
48
46
" dpnp_tril_indices" ,
49
47
" dpnp_tril_indices_from" ,
50
48
" dpnp_triu_indices" ,
@@ -69,16 +67,6 @@ ctypedef c_dpctl.DPCTLSyclEventRef(*custom_indexing_2in_1out_func_ptr_t_)(c_dpct
69
67
ctypedef c_dpctl.DPCTLSyclEventRef(* custom_indexing_2in_func_ptr_t)(c_dpctl.DPCTLSyclQueueRef,
70
68
void * , void * , shape_elem_type * , const size_t,
71
69
const c_dpctl.DPCTLEventVectorRef)
72
- ctypedef c_dpctl.DPCTLSyclEventRef(* custom_indexing_3in_with_axis_func_ptr_t)(c_dpctl.DPCTLSyclQueueRef,
73
- void * ,
74
- void * ,
75
- void * ,
76
- const size_t,
77
- shape_elem_type * ,
78
- const size_t,
79
- const size_t,
80
- const size_t,
81
- const c_dpctl.DPCTLEventVectorRef)
82
70
83
71
84
72
cpdef utils.dpnp_descriptor dpnp_choose(utils.dpnp_descriptor x1, list choices1):
@@ -283,35 +271,6 @@ cpdef object dpnp_indices(dimensions):
283
271
return dpnp_result
284
272
285
273
286
- cpdef dpnp_put_along_axis(dpnp_descriptor arr, dpnp_descriptor indices, dpnp_descriptor values, int axis):
287
- cdef shape_type_c arr_shape = arr.shape
288
- cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(arr.dtype)
289
-
290
- cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_PUT_ALONG_AXIS_EXT, param1_type, param1_type)
291
-
292
- utils.get_common_usm_allocation(arr, indices) # check USM allocation is common
293
- _, _, result_sycl_queue = utils.get_common_usm_allocation(arr, values)
294
-
295
- cdef c_dpctl.SyclQueue q = < c_dpctl.SyclQueue> result_sycl_queue
296
- cdef c_dpctl.DPCTLSyclQueueRef q_ref = q.get_queue_ref()
297
-
298
- cdef custom_indexing_3in_with_axis_func_ptr_t func = < custom_indexing_3in_with_axis_func_ptr_t > kernel_data.ptr
299
-
300
- cdef c_dpctl.DPCTLSyclEventRef event_ref = func(q_ref,
301
- arr.get_data(),
302
- indices.get_data(),
303
- values.get_data(),
304
- axis,
305
- arr_shape.data(),
306
- arr.ndim,
307
- indices.size,
308
- values.size,
309
- NULL ) # dep_events_ref
310
-
311
- with nogil: c_dpctl.DPCTLEvent_WaitAndThrow(event_ref)
312
- c_dpctl.DPCTLEvent_Delete(event_ref)
313
-
314
-
315
274
cpdef dpnp_putmask(utils.dpnp_descriptor arr, utils.dpnp_descriptor mask, utils.dpnp_descriptor values):
316
275
cdef int values_size = values.size
317
276
@@ -341,94 +300,6 @@ cpdef utils.dpnp_descriptor dpnp_select(list condlist, list choicelist, default)
341
300
return res_array
342
301
343
302
344
- cpdef object dpnp_take_along_axis(object arr, object indices, int axis):
345
- cdef long size_arr = arr.size
346
- cdef shape_type_c shape_arr = arr.shape
347
- cdef shape_type_c output_shape
348
- cdef long size_indices = indices.size
349
- res_type = arr.dtype
350
-
351
- if axis != arr.ndim - 1 :
352
- res_shape_list = list (shape_arr)
353
- res_shape_list[axis] = 1
354
- res_shape = tuple (res_shape_list)
355
-
356
- output_shape = (0 ,) * (len (shape_arr) - 1 )
357
- ind = 0
358
- for id , shape_axis in enumerate (shape_arr):
359
- if id != axis:
360
- output_shape[ind] = shape_axis
361
- ind += 1
362
-
363
- prod = 1
364
- for i in range (len (output_shape)):
365
- if output_shape[i] != 0 :
366
- prod *= output_shape[i]
367
-
368
- result_array = dpnp.empty((prod, ), dtype = res_type)
369
- ind_array = [None ] * prod
370
- arr_shape_offsets = [None ] * len (shape_arr)
371
- acc = 1
372
-
373
- for i in range (len (shape_arr)):
374
- ind = len (shape_arr) - 1 - i
375
- arr_shape_offsets[ind] = acc
376
- acc *= shape_arr[ind]
377
-
378
- output_shape_offsets = [None ] * len (shape_arr)
379
- acc = 1
380
-
381
- for i in range (len (output_shape)):
382
- ind = len (output_shape) - 1 - i
383
- output_shape_offsets[ind] = acc
384
- acc *= output_shape[ind]
385
- result_offsets = arr_shape_offsets[:] # need copy. not a reference
386
- result_offsets[axis] = 0
387
-
388
- for source_idx in range (size_arr):
389
-
390
- # reconstruct x,y,z from linear source_idx
391
- xyz = []
392
- remainder = source_idx
393
- for i in arr_shape_offsets:
394
- quotient, remainder = divmod (remainder, i)
395
- xyz.append(quotient)
396
-
397
- # extract result axis
398
- result_axis = []
399
- for idx, offset in enumerate (xyz):
400
- if idx != axis:
401
- result_axis.append(offset)
402
-
403
- # Construct result offset
404
- result_offset = 0
405
- for i, result_axis_val in enumerate (result_axis):
406
- result_offset += (output_shape_offsets[i] * result_axis_val)
407
-
408
- arr_elem = arr.item(source_idx)
409
- if ind_array[result_offset] is None :
410
- ind_array[result_offset] = 0
411
- else :
412
- ind_array[result_offset] += 1
413
-
414
- if ind_array[result_offset] % size_indices == indices.item(result_offset % size_indices):
415
- result_array[result_offset] = arr_elem
416
-
417
- dpnp_result_array = dpnp.reshape(result_array, res_shape)
418
- return dpnp_result_array
419
-
420
- else :
421
- result_array = utils_py.create_output_descriptor_py(shape_arr, res_type, None ).get_pyobj()
422
-
423
- result_array_flatiter = result_array.flat
424
-
425
- for i in range (size_arr):
426
- ind = size_indices * (i // size_indices) + indices.item(i % size_indices)
427
- result_array_flatiter[i] = arr.item(ind)
428
-
429
- return result_array
430
-
431
-
432
303
cpdef tuple dpnp_tril_indices(n, k = 0 , m = None ):
433
304
array1 = []
434
305
array2 = []
0 commit comments