From bca07d7062dd3814568cb99b5625f6c6331f3f6b Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Wed, 12 Aug 2026 11:47:05 +0200 Subject: [PATCH 1/2] Guard empty extents in boolean masked place/extract py_place and py_extract computed the orthogonal and masked element counts and dispatched to the strided kernels without checking for zero. When a boolean index produces an empty selection - e.g. a leading scalar `False` that injects a length-0 axis - ortho_nelems becomes 0, and the some-slices kernel builds sycl::nd_range<2> with GlobalSize[0] == 0 and a non-zero local size. That is a degenerate launch: it is a silent no-op on runtimes built with NDEBUG, but aborts on an assertions-enabled SYCL runtime (adjustNDRangePerKernel asserts NDR.LocalSize[0] == 0 when GlobalSize is 0). Return early with empty events when ortho_nelems or the masked element count is zero, so no kernel is submitted for an empty selection. --- .../libtensor/source/boolean_advanced_indexing.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dpnp/tensor/libtensor/source/boolean_advanced_indexing.cpp b/dpnp/tensor/libtensor/source/boolean_advanced_indexing.cpp index 49471e03028e..9ddc7e25de35 100644 --- a/dpnp/tensor/libtensor/source/boolean_advanced_indexing.cpp +++ b/dpnp/tensor/libtensor/source/boolean_advanced_indexing.cpp @@ -217,6 +217,11 @@ std::pair throw py::value_error("Inconsistent array dimensions"); } + if (ortho_nelems == 0 || masked_src_nelems == 0) { + // nothing to do + return std::make_pair(sycl::event(), sycl::event()); + } + dpnp::tensor::validation::AmpleMemory::throw_if_not_ample( dst, ortho_nelems * masked_dst_nelems); @@ -542,6 +547,11 @@ std::pair throw py::value_error("Inconsistent array dimensions"); } + if (ortho_nelems == 0 || masked_dst_nelems == 0) { + // nothing to do + return std::make_pair(sycl::event(), sycl::event()); + } + dpnp::tensor::validation::AmpleMemory::throw_if_not_ample( dst, ortho_nelems * masked_dst_nelems); From e18cbc067f850ee0b9ec1d4203b78e2f96ccad0f Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Wed, 12 Aug 2026 11:51:36 +0200 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d01978e60df..de9341ea3a7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,7 @@ This release is compatible with NumPy 2.5. * Fixed `dpnp.interp` returning `nan` when querying at an exact knot point whose adjacent `fp` value is `inf` [#2986](https://github.com/IntelPython/dpnp/pull/2986) * Fixed missing strides validation in `dpnp.tensor.usm_ndarray` constructor when allocating new memory [#2927](https://github.com/IntelPython/dpnp/pull/2927) * Fixed `dpnp.bincount` raising a `ValueError` on an empty input array instead of returning an empty `intp` array [#3018](https://github.com/IntelPython/dpnp/pull/3018) +* Fixed a crash in boolean-mask advanced indexing (`dpnp.ndarray` get/set item) when the selection is empty (e.g. a scalar `False` index that injects a length-0 axis) [#3019](https://github.com/IntelPython/dpnp/pull/3019) ### Security