Skip to content

Refactor dpnp includes and add extension example#2941

Draft
ndgrigorian wants to merge 5 commits into
masterfrom
add-libtensor-pybind11-example
Draft

Refactor dpnp includes and add extension example#2941
ndgrigorian wants to merge 5 commits into
masterfrom
add-libtensor-pybind11-example

Conversation

@ndgrigorian
Copy link
Copy Markdown
Collaborator

This PR proposes a refactor of dpnp's includes and the introduction of an example extension, to be tested to make sure examples using dpnp and dpnp.tensor can be written.

The usm_ndarray_constants.h header and dpnp4pybind11.hpp are moved to dpnp/include, removing a relative include and aligning with previous dpctl behavior.

Also introduces dpnp-config.cmake, which enables find_package(Dpnp) out of the box, which is installed with dpnp, and --cmakedir command line option, which leads to the CMake config.

  • 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?

Enables find_package(Dpnp) out of the box
move dpnp4pybind11.hpp and usm_ndarray_constants.h into a top-level include directory, similar to original dpctl layout
serves to test dpnp cmake integration
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

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

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Jun 5, 2026

Coverage Status

coverage: 78.236% (-0.01%) from 78.248% — add-libtensor-pybind11-example into master

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

Array API standard conformance tests for dpnp=0.21.0dev0=py313h509198e_71 ran successfully.
Passed: 1357
Failed: 3
Skipped: 16

@ndgrigorian ndgrigorian force-pushed the add-libtensor-pybind11-example branch from 622aa32 to c735f53 Compare June 5, 2026 08:30
@@ -0,0 +1,77 @@
# *****************************************************************************
# Copyright (c) 2016, Intel Corporation
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.

Suggested change
# Copyright (c) 2016, Intel Corporation
# Copyright (c) 2026, Intel Corporation

@@ -0,0 +1,49 @@
# *****************************************************************************
# Copyright (c) 2016, Intel Corporation
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.

Suggested change
# Copyright (c) 2016, Intel Corporation
# Copyright (c) 2026, Intel Corporation

@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-
# *****************************************************************************
# Copyright (c) 2023, Intel Corporation
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.

Suggested change
# Copyright (c) 2023, Intel Corporation
# Copyright (c) 2026, Intel Corporation

@@ -0,0 +1,38 @@
# *****************************************************************************
# Copyright (c) 2016, Intel Corporation
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.

Suggested change
# Copyright (c) 2016, Intel Corporation
# Copyright (c) 2026, Intel Corporation

# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"ad
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.

Suggested change
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"ad
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

Comment thread dpnp/__main__.py
parser.add_argument(
"--cmakedir",
action="store_true",
help="CMake module directory, ideal for setting -DDPCTL_ROOT in CMake.",
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.

This looks like a direct copy from dpctl without any changes

Comment thread cmake/dpnp-config.cmake
Comment on lines +51 to +52
kernels
utils
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.

find_path() uses OR semantics for multiple names so this check will succeed if either kernels or utils is present and it does not guarantee that both directories exist

Comment on lines +39 to +41
set(SYCL_MODULE_PATH "${CMAKE_SOURCE_DIR}/../../../dpnp/backend/cmake/Modules")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SYCL_MODULE_PATH})
find_package(IntelSYCL REQUIRED PATHS ${SYCL_MODULE_PATH} NO_DEFAULT_PATH)
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.

Since dpctl already ships IntelSYCLConfig.cmake could this be replaced with
find_package(IntelSYCL REQUIRED PATHS "${Dpctl_DIR}" NO_DEFAULT_PATH) after find_package(Dpctl REQUIRED)?
Or does it make sense to install IntelSYCLConfig.cmake into dpnp/resources/cmake/ and use "${Dpnp_DIR}" instead?

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