Skip to content

Commit ffccc2e

Browse files
authored
Merge pull request #2935 from IntelPython/technical-debt-tensor-indexing
Clean up technical debt in integer indexing Python bindings
2 parents af51b25 + 899068e commit ffccc2e

9 files changed

Lines changed: 443 additions & 421 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This release is compatible with NumPy 2.4.5.
2121
* Updated tests to align with NumPy 2.4.5 compatibility [gh-2920](https://github.com/IntelPython/dpnp/pull/2920)
2222
* Replaced `.pxi` includes in `dpnp.tensor` with modular `.pxd`/`.pyx` Cython imports [#2913](https://github.com/IntelPython/dpnp/pull/2913)
2323
* Reimplemented `dpnp.eye` and `dpnp.tensor.eye` with a branchless kernel [gh-2937](https://github.com/IntelPython/dpnp/pull/2937)
24+
* Cleaned up Python bindings for indexing functions, renaming `usm_ndarray_take` and `usm_ndarray_put` to `py_take` and `py_put` and refactoring validation [gh-2935](https://github.com/IntelPython/dpnp/pull/2935)
2425

2526
### Deprecated
2627

dpnp/dpnp_iface_indexing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ def _take_index(x, inds, axis, q, usm_type, out=None, mode=0):
312312
ind=(inds,),
313313
dst=out,
314314
axis_start=axis,
315+
axis_end=axis_end,
315316
mode=mode,
316317
sycl_queue=q,
317318
depends=dep_evs,

dpnp/tensor/_copy_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ def _put_multi_index(ary, inds, p, vals, mode=0):
475475
ind=inds,
476476
val=rhs,
477477
axis_start=p,
478+
axis_end=p_end,
478479
mode=mode,
479480
sycl_queue=exec_q,
480481
depends=dep_ev,
@@ -527,6 +528,7 @@ def _take_multi_index(ary, inds, p, mode=0):
527528
ind=inds,
528529
dst=res,
529530
axis_start=p,
531+
axis_end=p_end,
530532
mode=mode,
531533
sycl_queue=exec_q,
532534
depends=dep_ev,

dpnp/tensor/_indexing_functions.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,14 @@ def put_vec_duplicates(vec, ind, vals):
342342
_manager = SequentialOrderManager[exec_q]
343343
deps_ev = _manager.submitted_events
344344
hev, put_ev = ti._put(
345-
x, (indices,), rhs, axis, mode, sycl_queue=exec_q, depends=deps_ev
345+
x,
346+
(indices,),
347+
rhs,
348+
axis,
349+
axis + 1,
350+
mode,
351+
sycl_queue=exec_q,
352+
depends=deps_ev,
346353
)
347354
_manager.add_event_pair(hev, put_ev)
348355

@@ -543,7 +550,14 @@ def take(x, indices, /, *, axis=None, out=None, mode="wrap"):
543550
_manager = SequentialOrderManager[exec_q]
544551
deps_ev = _manager.submitted_events
545552
hev, take_ev = ti._take(
546-
x, (indices,), out, axis, mode, sycl_queue=exec_q, depends=deps_ev
553+
x,
554+
(indices,),
555+
out,
556+
axis,
557+
axis + 1,
558+
mode,
559+
sycl_queue=exec_q,
560+
depends=deps_ev,
547561
)
548562
_manager.add_event_pair(hev, take_ev)
549563

dpnp/tensor/_searchsorted.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def searchsorted(
160160
ind,
161161
res,
162162
axis,
163+
axis + 1,
163164
wrap_out_of_bound_indices_mode,
164165
sycl_queue=q,
165166
depends=dep_evs,

dpnp/tensor/_set_functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ def unique_inverse(x):
383383
ind=(sorting_ids,),
384384
dst=s,
385385
axis_start=0,
386+
axis_end=1,
386387
mode=0,
387388
sycl_queue=exec_q,
388389
depends=[sort_ev],
@@ -558,6 +559,7 @@ def unique_all(x: dpt.usm_ndarray) -> UniqueAllResult:
558559
ind=(sorting_ids,),
559560
dst=s,
560561
axis_start=0,
562+
axis_end=1,
561563
mode=0,
562564
sycl_queue=exec_q,
563565
depends=[sort_ev],

0 commit comments

Comments
 (0)