Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
82a59d1
Add and install dpnp-config.cmake
ndgrigorian Jun 5, 2026
1547e62
refactor dpnp includes
ndgrigorian Jun 5, 2026
22fe46e
add dpnp4pybind11.hpp where transiently included
ndgrigorian Jun 5, 2026
82d90b9
add pybind11 extension
ndgrigorian Jun 5, 2026
c735f53
run pybind11 example in CI
ndgrigorian Jun 5, 2026
5ce4ee9
pin compiler in example test run
ndgrigorian Jun 5, 2026
a84e5fc
address review feedback
ndgrigorian Jun 5, 2026
4c05f49
fix stray copyright date in use_dpnp_array setup.py
ndgrigorian Jun 5, 2026
020e5ea
use two find_path calls in dpnp-config.cmake
ndgrigorian Jun 5, 2026
f162a9d
address PR review
ndgrigorian Jun 9, 2026
4a4e5d2
Merge branch 'master' into add-libtensor-pybind11-example
vlad-perevezentsev Jun 10, 2026
d0127f3
Merge branch 'master' into add-libtensor-pybind11-example
ndgrigorian Jun 11, 2026
cded248
apply review comments
ndgrigorian Jun 18, 2026
9b70628
Merge branch 'master' into add-libtensor-pybind11-example
ndgrigorian Jun 18, 2026
6ac4c8b
pre-commit fix
ndgrigorian Jun 18, 2026
8730fa6
examples environment fixes
ndgrigorian Jun 18, 2026
4cd26db
Merge branch 'master' into add-libtensor-pybind11-example
ndgrigorian Jun 18, 2026
4fb12d0
fix examples.yml formatting
ndgrigorian Jun 18, 2026
fc060a9
Merge branch 'master' into add-libtensor-pybind11-example
ndgrigorian Jun 18, 2026
8066951
add NO_DEFAULT_PATH to dpnp-config
ndgrigorian Jun 18, 2026
7304e4b
Merge branch 'master' into add-libtensor-pybind11-example
ndgrigorian Jun 18, 2026
f3148d1
pre-commit fix
ndgrigorian Jun 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 108 additions & 1 deletion .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,113 @@ jobs:

python -m pytest -n auto -ra --pyargs dpnp.tests.tensor

test_examples_linux:
name: Test examples

needs: build

runs-on: ubuntu-latest
timeout-minutes: 60

defaults:
run:
shell: bash -el {0}

strategy:
matrix:
python: ['3.14']

env:
dpnp-repo-path: '${{ github.workspace }}/source/'
examples-conda-pkg-env: 'source/environments/examples.yml'
channel-path: '${{ github.workspace }}/channel/'
pkg-path-in-channel: '${{ github.workspace }}/channel/linux-64/'
ver-json-path: '${{ github.workspace }}/version.json'
examples-env-name: 'examples_test'

steps:
- name: Checkout DPNP repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: ${{ env.fetch-depth }}
path: ${{ env.dpnp-repo-path }}

- name: Download artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ env.package-name }} ${{ runner.os }} Python ${{ matrix.python }}
path: ${{ env.pkg-path-in-channel }}

- name: Setup miniconda
id: setup_miniconda
continue-on-error: true
uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
with:
miniforge-version: latest
use-mamba: 'true'
conda-remove-defaults: 'true'
environment-file: ${{ env.examples-conda-pkg-env }}
activate-environment: ${{ env.examples-env-name }}

- name: ReSetup miniconda
if: steps.setup_miniconda.outcome == 'failure'
uses: conda-incubator/setup-miniconda@8ee1f361103df19b6f8c8655fd3967a8ecb162d5 # v4.0.1
with:
miniforge-version: latest
use-mamba: 'true'
conda-remove-defaults: 'true'
environment-file: ${{ env.examples-conda-pkg-env }}
activate-environment: ${{ env.examples-env-name }}

- name: Create conda channel
run: |
python -m conda_index ${{ env.channel-path }}

- name: Test conda channel
run: |
conda search ${{ env.package-name }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
cat ${{ env.ver-json-path }}

- name: Get package version
run: |
PACKAGE_VERSION=$(python -c "${{ env.ver-script-part1 }} ${{ env.ver-script-part2 }}")
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> "$GITHUB_ENV"

- name: Install dpnp
id: install_dpnp
continue-on-error: true
run: |
mamba install ${{ env.package-name }}=${{ env.PACKAGE_VERSION }} python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
env:
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.channels-list }}'

- name: ReInstall dpnp
if: steps.install_dpnp.outcome == 'failure'
run: |
mamba install ${{ env.package-name }}=${{ env.PACKAGE_VERSION }} python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
env:
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.channels-list }}'

- name: List installed packages
run: mamba list

- name: Smoke test
run: |
python -c "import dpctl; dpctl.lsplatform()"
python -c "import dpnp; print(dpnp.__version__)"

- name: Build and run pybind11 examples
run: |
cd ${{ env.dpnp-repo-path }}/examples/pybind11
for d in */; do
pushd "$d" > /dev/null
CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja || exit 1
if [ -d tests ]; then
python -m pytest tests || exit 1
fi
popd > /dev/null
done

test_windows:
name: Test

Expand Down Expand Up @@ -451,7 +558,7 @@ jobs:
upload:
name: Upload

needs: [test_linux, test_windows]
needs: [test_linux, test_windows, test_examples_linux]

strategy:
fail-fast: false
Expand Down
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
_skbuild
build_cython
cython_debug
dpnp.egg-info
*.egg-info

# Byte-compiled / optimized / DLL files
__pycache__/
Expand All @@ -27,9 +27,12 @@ dpnp_pytest.*
# Build examples
example3

# moved cmake scripts
dpnp/resources/cmake

*dpnp_backend*
dpnp/include/dpnp/tensor/*.h
dpnp/**/*.cpython*.so
dpnp/**/*.pyd
*~
core
*.so
Comment thread
ndgrigorian marked this conversation as resolved.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,19 @@ else()
message(FATAL_ERROR "Unsupported system.")
endif()

# install dpnp-config.cmake for find_package() support
foreach(_dest IN ITEMS dpnp/resources/cmake lib/cmake/dpnp)
install(FILES ${CMAKE_SOURCE_DIR}/cmake/dpnp-config.cmake DESTINATION ${_dest})
endforeach()

# install dpnp4pybind11.hpp and usm_ndarray_constants.h into include folder
install(
FILES
${CMAKE_SOURCE_DIR}/dpnp/include/dpnp4pybind11.hpp
${CMAKE_SOURCE_DIR}/dpnp/include/usm_ndarray_constants.h
DESTINATION dpnp/include
)

# Define flags for CMAKE_BUILD_TYPE=Coverage
set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_DEBUG} -O1 -g1 -DDEBUG")
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG} -O1 -g1 -DDEBUG")
Expand Down
69 changes: 69 additions & 0 deletions cmake/dpnp-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#.rst:
#
# Find the include directory for ``dpnp4pybind11.hpp`` and dpnp tensor kernels.
#
# This module sets the following variables:
#
# ``Dpnp_FOUND``
# True if DPNP was found.
# ``Dpnp_INCLUDE_DIR``
# The include directory needed to use dpnp.
# ``Dpnp_TENSOR_INCLUDE_DIR``
# The include directory for tensor kernels implementation.
# ``Dpnp_VERSION``
# The version of dpnp found.
#
# The module will also explicitly define two cache variables:
#
# ``Dpnp_INCLUDE_DIR``
# ``Dpnp_TENSOR_INCLUDE_DIR``
#

if(NOT Dpnp_FOUND)
find_package(Python 3.10 REQUIRED COMPONENTS Interpreter Development.Module)
Comment thread
ndgrigorian marked this conversation as resolved.

if(Python_EXECUTABLE)
execute_process(
COMMAND "${Python_EXECUTABLE}" -m dpnp --include-dir
OUTPUT_VARIABLE _dpnp_include_dir
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
execute_process(
COMMAND "${Python_EXECUTABLE}" -c "import dpnp; print(dpnp.__version__)"
OUTPUT_VARIABLE Dpnp_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
endif()
endif()

find_path(
Dpnp_INCLUDE_DIR
dpnp4pybind11.hpp
PATHS "${_dpnp_include_dir}" "${Python_INCLUDE_DIRS}"
PATH_SUFFIXES dpnp/include
Comment thread
ndgrigorian marked this conversation as resolved.
NO_DEFAULT_PATH
)
get_filename_component(_dpnp_dir "${Dpnp_INCLUDE_DIR}" DIRECTORY)

find_path(
Dpnp_TENSOR_INCLUDE_DIR
kernels
PATHS "${_dpnp_dir}/tensor/libtensor/include"
NO_DEFAULT_PATH
)

set(Dpnp_INCLUDE_DIRS ${Dpnp_INCLUDE_DIR})

# handle the QUIETLY and REQUIRED arguments and set Dpnp_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Dpnp
REQUIRED_VARS Dpnp_INCLUDE_DIR Dpnp_TENSOR_INCLUDE_DIR
VERSION_VAR Dpnp_VERSION
)

mark_as_advanced(Dpnp_INCLUDE_DIR)
mark_as_advanced(Dpnp_TENSOR_INCLUDE_DIR)
16 changes: 15 additions & 1 deletion dpnp/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _dpnp_dir() -> str:

def get_include_dir() -> str:
"""Returns path to dpnp include directory containing dpnp4pybind11.hpp"""
return os.path.join(_dpnp_dir(), "backend", "include")
return os.path.join(_dpnp_dir(), "include")


def print_include_flags() -> None:
Expand All @@ -61,6 +61,13 @@ def print_tensor_include_flags() -> None:
print("-I " + libtensor_dir)


def print_cmake_dir() -> None:
"""Prints directory with dpnp-config.cmake"""
dpnp_dir = _dpnp_dir()
cmake_dir = os.path.join(dpnp_dir, "resources", "cmake")
print(cmake_dir)


def main() -> None:
"""Main entry-point."""
parser = argparse.ArgumentParser()
Expand All @@ -84,6 +91,11 @@ def main() -> None:
action="store_true",
help="Path to dpnp libtensor include directory.",
)
parser.add_argument(
"--cmakedir",

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.

Would it make sense to test --cmakedir / Dpnp_ROOT in the example also?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

not sure how you mean, find_package effectively tests already Dpnp_ROOT. If the example runs, Dpnp_ROOT should be set.

action="store_true",
help="CMake module directory, ideal for setting -DDpnp_ROOT in CMake.",
)
args = parser.parse_args()
if not sys.argv[1:]:
parser.print_help()
Expand All @@ -95,6 +107,8 @@ def main() -> None:
print_tensor_include_flags()
if args.tensor_include_dir:
print(get_tensor_include_dir())
if args.cmakedir:
print_cmake_dir()


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/blas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ target_include_directories(
${python_module_name}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../common
${CMAKE_SOURCE_DIR}/dpnp/backend/include
${CMAKE_SOURCE_DIR}/dpnp/include
${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include
)

Expand Down
2 changes: 2 additions & 0 deletions dpnp/backend/extensions/blas/dot_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

#include <pybind11/pybind11.h>

#include "dpnp4pybind11.hpp"

// dpnp tensor headers
#include "utils/memory_overlap.hpp"
#include "utils/output_validation.hpp"
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/fft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ set_target_properties(
target_include_directories(
${python_module_name}
PRIVATE
${CMAKE_SOURCE_DIR}/dpnp/backend/include
${CMAKE_SOURCE_DIR}/dpnp/include
${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include
)

Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/indexing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ target_include_directories(
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../../
${CMAKE_CURRENT_SOURCE_DIR}/../common
${CMAKE_SOURCE_DIR}/dpnp/backend/include
${CMAKE_SOURCE_DIR}/dpnp/include
${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include
)

Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/lapack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ target_include_directories(
${python_module_name}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../common
${CMAKE_SOURCE_DIR}/dpnp/backend/include
${CMAKE_SOURCE_DIR}/dpnp/include
${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include
)

Expand Down
2 changes: 2 additions & 0 deletions dpnp/backend/extensions/lapack/evd_batch_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <oneapi/mkl.hpp>
#include <pybind11/pybind11.h>

#include "dpnp4pybind11.hpp"

// dpnp tensor headers
#include "utils/type_dispatch.hpp"

Expand Down
2 changes: 2 additions & 0 deletions dpnp/backend/extensions/lapack/evd_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <oneapi/mkl.hpp>
#include <pybind11/pybind11.h>

#include "dpnp4pybind11.hpp"

// dpnp tensor headers
#include "utils/type_dispatch.hpp"

Expand Down
2 changes: 2 additions & 0 deletions dpnp/backend/extensions/lapack/evd_common_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#include <pybind11/pybind11.h>

#include "dpnp4pybind11.hpp"

// dpnp tensor headers
#include "utils/memory_overlap.hpp"
#include "utils/output_validation.hpp"
Expand Down
2 changes: 2 additions & 0 deletions dpnp/backend/extensions/lapack/gesv_common_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#include <pybind11/pybind11.h>

#include "dpnp4pybind11.hpp"

// dpnp tensor headers
#include "utils/memory_overlap.hpp"
#include "utils/output_validation.hpp"
Expand Down
2 changes: 2 additions & 0 deletions dpnp/backend/extensions/lapack/gesvd_common_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <oneapi/mkl.hpp>
#include <pybind11/pybind11.h>

#include "dpnp4pybind11.hpp"

// dpnp tensor headers
#include "utils/memory_overlap.hpp"
#include "utils/output_validation.hpp"
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/statistics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ target_include_directories(
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../../
${CMAKE_CURRENT_SOURCE_DIR}/../common
${CMAKE_SOURCE_DIR}/dpnp/backend/include
${CMAKE_SOURCE_DIR}/dpnp/include
${CMAKE_SOURCE_DIR}/dpnp/tensor/libtensor/include
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@

#pragma once

#include "ext/dispatch_table.hpp"
#include <pybind11/pybind11.h>
#include <sycl/sycl.hpp>

#include "dpnp4pybind11.hpp"

#include "ext/dispatch_table.hpp"

namespace statistics::sliding_window1d
{
struct SlidingDotProduct1d
Expand Down
Loading
Loading