Skip to content

Move _tensor_reductions_impl extension and use it for dpnp#2794

Open
vlad-perevezentsev wants to merge 14 commits intomove_tensor_sorting_implfrom
move_tensor_reductions_impl_ext
Open

Move _tensor_reductions_impl extension and use it for dpnp#2794
vlad-perevezentsev wants to merge 14 commits intomove_tensor_sorting_implfrom
move_tensor_reductions_impl_ext

Conversation

@vlad-perevezentsev
Copy link
Contributor

This PR completely moves _tensor_reductions_impl pybind11 extension into dpctl_ext.tensor and extends dpctl_ext.tensor Python API with the functions:

all
any
diff
argmax
argmin
count_nonzero
logsumexp
max
min
prod
reduce_hypot
sum

reusing them in dpnp

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

View rendered docs @ https://intelpython.github.io/dpnp/pull/2794/index.html

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Array API standard conformance tests for dpnp=0.20.0dev3=py313h509198e_153 ran successfully.
Passed: 1356
Failed: 1
Skipped: 16

@vlad-perevezentsev vlad-perevezentsev marked this pull request as ready for review March 4, 2026 12:39
#include <complex>
#include <cstddef>
#include <cstdint>
#include <stdexcept>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <stdexcept>

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

#include "kernels/reductions.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing include:

Suggested change
#include "kernels/reductions.hpp"
#include "kernels/reductions.hpp"
#include "utils/sycl_utils.hpp"


#include "reductions/reduction_common.hpp"

namespace py = pybind11;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems never used

Suggested change
namespace py = pybind11;


#include <algorithm>
#include <cstddef>
#include <cstdint>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used

Suggested change
#include <cstdint>

//===---------------------------------------------------------------------===//

#pragma once
#include <complex>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used

Suggested change
#include <complex>

auto argmin_pyapi = [&](const arrayT &src, int trailing_dims_to_reduce,
const arrayT &dst, sycl::queue &exec_q,
const event_vecT &depends = {}) {
using dpctl::tensor::py_internal::py_search_over_axis;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using dpctl::tensor::py_internal::py_search_over_axis;

int trailing_dims_to_reduce,
const arrayT &dst, sycl::queue &exec_q,
const event_vecT &depends = {}) {
using dpctl::tensor::py_internal::py_tree_reduction_over_axis;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using dpctl::tensor::py_internal::py_tree_reduction_over_axis;


auto logsumexp_dtype_supported = [&](const py::dtype &input_dtype,
const py::dtype &output_dtype) {
using dpctl::tensor::py_internal::py_tree_reduction_dtype_supported;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using dpctl::tensor::py_internal::py_tree_reduction_dtype_supported;

auto max_pyapi = [&](const arrayT &src, int trailing_dims_to_reduce,
const arrayT &dst, sycl::queue &exec_q,
const event_vecT &depends = {}) {
using dpctl::tensor::py_internal::py_reduction_over_axis;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using dpctl::tensor::py_internal::py_reduction_over_axis;

auto min_pyapi = [&](const arrayT &src, int trailing_dims_to_reduce,
const arrayT &dst, sycl::queue &exec_q,
const event_vecT &depends = {}) {
using dpctl::tensor::py_internal::py_reduction_over_axis;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using dpctl::tensor::py_internal::py_reduction_over_axis;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants