Skip to content

Move dpctl_ext.tensor to dpnp.tensor#2829

Open
vlad-perevezentsev wants to merge 324 commits intoinclude-dpctl-tensorfrom
move_dpctl_ext_to_dpnp_tensor
Open

Move dpctl_ext.tensor to dpnp.tensor#2829
vlad-perevezentsev wants to merge 324 commits intoinclude-dpctl-tensorfrom
move_dpctl_ext_to_dpnp_tensor

Conversation

@vlad-perevezentsev
Copy link
Copy Markdown
Contributor

@vlad-perevezentsev vlad-perevezentsev commented Mar 25, 2026

This PR proposes a refactoring that migrates dpctl_ext.tensor module into dpnp package as dpnp.tensor

Changes:

  1. Moved dpctl_ext/tensor/ directory to dpnp/tensor/
  2. Updated all imports from dpctl_ext.tensor to dpnp.tensor across the codebase
  3. Consolidated build: removed dpctl_ext/CMakeLists.txt, added build_dpnp_tensor_ext() to dpnp/CMakeLists.txt
  4. Added DPNP_BUILD_COMPONENTS CMake option (ALL/TENSOR_ONLY/SKIP_TENSOR) for staged builds
  5. Split coverage workflow into two steps to avoid memory issues
  6. Updated include paths in all backend extension CMake files
  7. Removed dpctl_ext/ directory and cleaned up .gitignore
  • 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?

@vlad-perevezentsev vlad-perevezentsev marked this pull request as ready for review March 31, 2026 14:07
@vlad-perevezentsev vlad-perevezentsev force-pushed the move_dpctl_ext_to_dpnp_tensor branch from a621aaa to d819ae3 Compare April 1, 2026 12:35
@vlad-perevezentsev vlad-perevezentsev force-pushed the move_dpctl_ext_to_dpnp_tensor branch from 4497e9e to 1d9cabd Compare April 1, 2026 14:11
@vlad-perevezentsev vlad-perevezentsev force-pushed the move_dpctl_ext_to_dpnp_tensor branch from 1d9cabd to e023f2f Compare April 1, 2026 14:14
# when dpnp fully migrates dpctl/tensor
import dpctl_ext.tensor._type_utils as dtu
import dpnp
import dpnp.tensor._type_utils as dtu
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dpnp/dpnp_utils/dpnp_algo_utils.pyx still has code with dpctl.tensor usage:

    def get_array(self):
        if isinstance(self.origin_pyobj, dpctl.tensor.usm_ndarray):
            return self.origin_pyobj
        if isinstance(self.origin_pyobj, dpnp_array):
            return self.origin_pyobj.get_array()

        raise TypeError(
            "expected either dpctl.tensor.usm_ndarray or dpnp.dpnp_array.dpnp_array, got {}"
            "".format(type(self.origin_pyobj)))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done
Updates to error messages and comments will be included in the next PR which will update dpnp.tensor docs , error messages and comments
The current PR updated many files and addressing this kind of remarks would make the review more difficult

import dpctl_ext.tensor as dpt
import dpctl_ext.tensor._tensor_accumulation_impl as tai
import dpctl_ext.tensor._tensor_impl as ti
import dpnp.tensor as dpt
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

still have below:

    if not isinstance(x, dpt.usm_ndarray):
        raise TypeError(f"Expected dpctl.tensor.usm_ndarray, got {type(x)}")

import dpctl_ext.tensor as dpt
import dpctl_ext.tensor._tensor_elementwise_impl as tei
import dpctl_ext.tensor._tensor_impl as ti
import dpnp.tensor as dpt
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

needs to update below:

    if not isinstance(x, dpt.usm_ndarray):
        raise TypeError(
            "Expected `x` to be of dpctl.tensor.usm_ndarray type, got "
            f"{type(x)}"
        )

# when dpnp fully migrates dpctl/tensor
import dpctl_ext.tensor as dpt
import dpctl_ext.tensor._tensor_impl as ti
import dpnp.tensor as dpt
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

needs to update below:

    if not isinstance(ary, dpt.usm_ndarray):
        raise TypeError(f"Expected dpctl.tensor.usm_ndarray, got {type(ary)}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the same dpctl.tensor usage still in many other places below

import dpnp.backend.extensions.blas._blas_impl as bi
from dpctl_ext.tensor._numpy_helper import (

# pylint: disable=no-name-in-module
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

needs to update the code below:

        # so using dpctl.tensor.vecdot instead

ndgrigorian
ndgrigorian previously approved these changes Apr 2, 2026
Copy link
Copy Markdown
Collaborator

@ndgrigorian ndgrigorian left a comment

Choose a reason for hiding this comment

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

other than that minor curiosity and Anton's comments, LGTM

Base automatically changed from remove_c_api_tensor to include-dpctl-tensor April 7, 2026 12:58
@vlad-perevezentsev vlad-perevezentsev dismissed ndgrigorian’s stale review April 7, 2026 12:58

The base branch was changed.

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.

3 participants