From 3389a939f3f4bb8cd75c69de164ea32b89ce7880 Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Fri, 18 Sep 2026 22:57:39 -0700 Subject: [PATCH 1/2] Fix event dependencies and initial displacements The strided kernel of `full` was launched waiting only on the event which copies the packed shape and strides to the device, dropping dependent events passed to the binding removed unnecessary events added to `copy_for_reshape` `simplify_iteration_three_strides` and `simplify_iteration_four_strides` zeroed only `disp1` and `disp2`, which is not the case for other stride simplifications --- CHANGELOG.md | 3 +++ dpnp/tensor/libtensor/include/utils/strided_iters.hpp | 3 +++ dpnp/tensor/libtensor/source/copy_for_reshape.cpp | 5 +++-- dpnp/tensor/libtensor/source/full_ctor.cpp | 8 +++++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1715ec83273..4c8db12c1360 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -101,6 +101,9 @@ This release is compatible with NumPy 2.5. * Fixed `dpnp.einsum` returning a result whose memory layout differs from NumPy for the default `order="K"`, and ignoring `out` and `order` for a contraction over a size-0 dimension [#3058](https://github.com/IntelPython/dpnp/pull/3058) * Fixed operations on a boolean array whose bytes are not `0x00`/`0x01` [#3055](https://github.com/IntelPython/dpnp/pull/3055) * Fixed the `dpnp.ndarray` constructor returning a view at the wrong address [#3068](https://github.com/IntelPython/dpnp/pull/3068) +* Fixed the strided kernel of `dpnp.full` and `dpnp.tensor.full` not waiting on the events passed to the binding [#3073](https://github.com/IntelPython/dpnp/pull/3073) +* Fixed the list of events the copy kernel of `dpnp.reshape` and `dpnp.tensor.reshape` waits on being padded with default-constructed events [#3073](https://github.com/IntelPython/dpnp/pull/3073) +* Fixed `simplify_iteration_three_strides` and `simplify_iteration_four_strides` accumulating into their third and fourth output displacements without zeroing them first, which required the caller to initialize them [#3073](https://github.com/IntelPython/dpnp/pull/3073) ### Security diff --git a/dpnp/tensor/libtensor/include/utils/strided_iters.hpp b/dpnp/tensor/libtensor/include/utils/strided_iters.hpp index 29c17467cd78..2b3c3d706974 100644 --- a/dpnp/tensor/libtensor/include/utils/strided_iters.hpp +++ b/dpnp/tensor/libtensor/include/utils/strided_iters.hpp @@ -606,6 +606,7 @@ int simplify_iteration_three_strides(const int nd, { disp1 = StridesTy(0); disp2 = StridesTy(0); + disp3 = StridesTy(0); if (nd < 2) return nd; @@ -770,6 +771,8 @@ int simplify_iteration_four_strides(const int nd, { disp1 = StridesTy(0); disp2 = StridesTy(0); + disp3 = StridesTy(0); + disp4 = StridesTy(0); if (nd < 2) return nd; diff --git a/dpnp/tensor/libtensor/source/copy_for_reshape.cpp b/dpnp/tensor/libtensor/source/copy_for_reshape.cpp index f7c60d8cfa08..688a5763c551 100644 --- a/dpnp/tensor/libtensor/source/copy_for_reshape.cpp +++ b/dpnp/tensor/libtensor/source/copy_for_reshape.cpp @@ -152,9 +152,10 @@ std::pair const char *src_data = src.get_data(); char *dst_data = dst.get_data(); - std::vector all_deps(depends.size() + 1); - all_deps.push_back(copy_shape_ev); + std::vector all_deps; + all_deps.reserve(depends.size() + 1); all_deps.insert(std::end(all_deps), std::begin(depends), std::end(depends)); + all_deps.push_back(copy_shape_ev); sycl::event copy_for_reshape_event = fn(exec_q, src_nelems, src_nd, dst_nd, shape_strides, src_data, diff --git a/dpnp/tensor/libtensor/source/full_ctor.cpp b/dpnp/tensor/libtensor/source/full_ctor.cpp index 8345014f29b4..b2380057c5f0 100644 --- a/dpnp/tensor/libtensor/source/full_ctor.cpp +++ b/dpnp/tensor/libtensor/source/full_ctor.cpp @@ -278,9 +278,15 @@ std::pair const sycl::event ©_shape_ev = std::get<2>(ptr_size_event_tuple); py::ssize_t *shape_strides = shape_strides_owner.get(); + std::vector all_deps; + all_deps.reserve(depends.size() + 1); + all_deps.insert(std::end(all_deps), std::begin(depends), + std::end(depends)); + all_deps.push_back(copy_shape_ev); + const sycl::event &full_strided_ev = fn(exec_q, nd, dst_nelems, shape_strides, py_value, dst_data, - {copy_shape_ev}); + all_deps); // free shape_strides const auto &temporaries_cleanup_ev = From fe516a1dd5460b6a78ca9c475f0b3371ebebafa9 Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Fri, 25 Sep 2026 09:52:38 -0700 Subject: [PATCH 2/2] Fix padding the dependencies of copy_for_roll --- CHANGELOG.md | 2 +- dpnp/tensor/libtensor/source/copy_for_roll.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c8db12c1360..7136ebc7e53e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -102,7 +102,7 @@ This release is compatible with NumPy 2.5. * Fixed operations on a boolean array whose bytes are not `0x00`/`0x01` [#3055](https://github.com/IntelPython/dpnp/pull/3055) * Fixed the `dpnp.ndarray` constructor returning a view at the wrong address [#3068](https://github.com/IntelPython/dpnp/pull/3068) * Fixed the strided kernel of `dpnp.full` and `dpnp.tensor.full` not waiting on the events passed to the binding [#3073](https://github.com/IntelPython/dpnp/pull/3073) -* Fixed the list of events the copy kernel of `dpnp.reshape` and `dpnp.tensor.reshape` waits on being padded with default-constructed events [#3073](https://github.com/IntelPython/dpnp/pull/3073) +* Fixed the list of events the copy kernels of `dpnp.reshape`, `dpnp.tensor.reshape`, `dpnp.roll` and `dpnp.tensor.roll` wait on being padded with default-constructed events [#3073](https://github.com/IntelPython/dpnp/pull/3073) * Fixed `simplify_iteration_three_strides` and `simplify_iteration_four_strides` accumulating into their third and fourth output displacements without zeroing them first, which required the caller to initialize them [#3073](https://github.com/IntelPython/dpnp/pull/3073) ### Security diff --git a/dpnp/tensor/libtensor/source/copy_for_roll.cpp b/dpnp/tensor/libtensor/source/copy_for_roll.cpp index 662a0390e0be..4ff6cca14e48 100644 --- a/dpnp/tensor/libtensor/source/copy_for_roll.cpp +++ b/dpnp/tensor/libtensor/source/copy_for_roll.cpp @@ -233,9 +233,10 @@ std::pair sycl::event copy_shape_ev = std::get<2>(ptr_size_event_tuple); const py::ssize_t *shape_strides = shape_strides_owner.get(); - std::vector all_deps(depends.size() + 1); - all_deps.push_back(copy_shape_ev); + std::vector all_deps; + all_deps.reserve(depends.size() + 1); all_deps.insert(std::end(all_deps), std::begin(depends), std::end(depends)); + all_deps.push_back(copy_shape_ev); sycl::event copy_for_roll_event = fn(exec_q, offset, src_nelems, src_nd, shape_strides, src_data, @@ -357,9 +358,10 @@ std::pair sycl::event copy_shape_ev = std::get<2>(ptr_size_event_tuple); const py::ssize_t *shape_strides_shifts = shape_strides_shifts_owner.get(); - std::vector all_deps(depends.size() + 1); - all_deps.push_back(copy_shape_ev); + std::vector all_deps; + all_deps.reserve(depends.size() + 1); all_deps.insert(std::end(all_deps), std::begin(depends), std::end(depends)); + all_deps.push_back(copy_shape_ev); sycl::event copy_for_roll_event = fn(exec_q, src_nelems, src_nd, shape_strides_shifts, src_data,