Skip to content

Move usm_ndarray into dpctl_ext.tensor#2807

Open
vlad-perevezentsev wants to merge 264 commits intoinclude-dpctl-tensorfrom
move_usm_ndarray
Open

Move usm_ndarray into dpctl_ext.tensor#2807
vlad-perevezentsev wants to merge 264 commits intoinclude-dpctl-tensorfrom
move_usm_ndarray

Conversation

@vlad-perevezentsev
Copy link
Contributor

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

This PR proposes to migrate the tensor interface (usm_ndarray, dlpack, flags) into dpctl_ext/tensor making dpnp independent of dpctl's tensor module.

Updates:

  • Introduce dpctl_ext_capi.h
  • Implement a clean CMake interface library DpctlExtCAPI to properly propagate generated headers to consumers
  • Update remaining imports from dpctl.tensor to dpctl_ext.tensor
  • Link all backend extensions against DpctlExtCAPI to ensure consistent access to the C-API
  • 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 17, 2026 12:28
@@ -64,7 +64,7 @@
# Borrowed from DPCTL
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we have to remove the warning suppress, since it's the last PR removing migration of the source code

@ndgrigorian
Copy link
Collaborator

@antonwolfy @vlad-perevezentsev
A thought but should we consider flattening the directory structure? Since currently it's
dpnp -> dpctl_ext -> tensor (actual files...)

Maybe could we flatten to something like dpnp -> tensor (or dpctl_ext)

Base automatically changed from finalize_functional_migration to include-dpctl-tensor March 19, 2026 14:53
@antonwolfy
Copy link
Contributor

@antonwolfy @vlad-perevezentsev A thought but should we consider flattening the directory structure? Since currently it's dpnp -> dpctl_ext -> tensor (actual files...)

Maybe could we flatten to something like dpnp -> tensor (or dpctl_ext)

dpnp.tensor sounds reasonable as for me.

@antonwolfy
Copy link
Contributor

Based on warning report seems we still using import dpnp.tensor somewhere in code or tests.
Is it intentional?

pybind11_add_module(${python_module_name} MODULE ${_module_src})
add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_module_src})

target_link_libraries(${python_module_name} PRIVATE DpctlExtCAPI)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need that and how it worked previously without linking with dpctl lib?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously dpnp4pybind11.hpp included dpctl_capi.h from the external dpctl package which was found via ${Dpctl_INCLUDE_DIRS} set by find_package(Dpctl).

Now dpnp4pybind11.hpp includes dpctl_ext_capi.h which is an internal header,and without linking to DpctlExtCAPI I got an error

dpnp4pybind11.hpp:41:10: fatal error: 'dpctl_ext_capi.h' file not found
   41 | #include "dpctl_ext_capi.h"

Copy link
Contributor

Choose a reason for hiding this comment

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

But the error is about include, not about linkage.

endif()

add_subdirectory(dpnp)
# DpctlExtCAPI: Interface library for dpctl_ext C-API
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it a temporary approach, or do we need to define interface lib even when it will be exposed by dpctl when the migration is completed?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a design decision either way: dpctl exposed PyUSMArrayObject for numba-dpex's sake. So this way, usm_ndarray would be exposed to C-API and could be interacted with from C code conveniently.

It could be removed, in which case, the api methods like i.e., cdef api char* UsmNDArray_GetData could also be removed (barring causing any problems in the dpctl_ext).

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