Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cb03a49
Move data types to dpctl_ext.tensor
vlad-perevezentsev Mar 5, 2026
93510c0
Move class Device to dpctl_ext.tensor
vlad-perevezentsev Mar 5, 2026
8e11b23
Move constants to dpctl_ext.tensor
vlad-perevezentsev Mar 5, 2026
54fe331
Move array API utilities
vlad-perevezentsev Mar 5, 2026
60bba8f
Move print functions to dpctl_ext.tensor
vlad-perevezentsev Mar 5, 2026
b4fa023
Move include/dlpack to dpctl_ext.tensor
vlad-perevezentsev Mar 5, 2026
fb8b77e
Move _dlpack.pyx/pxd to dpctl_ext.tensor
vlad-perevezentsev Mar 5, 2026
5c9e183
Move _flags.pyx to dpctl_ext.tensor
vlad-perevezentsev Mar 5, 2026
8f44c37
Move cython helper files
vlad-perevezentsev Mar 6, 2026
e2441eb
Move dldevice_conversions functions
vlad-perevezentsev Mar 6, 2026
422e87e
Move usm_ndarray to dpctl_ext.tensor
vlad-perevezentsev Mar 6, 2026
e114808
Fix import _flags and _dlpack in _usmarray.pyx
vlad-perevezentsev Mar 6, 2026
39c0571
Update CMakes files to build usm_ndarray
vlad-perevezentsev Mar 6, 2026
3c428a6
Switch fully to dpctl_ext.tensor in dpctl_ext.tensor
vlad-perevezentsev Mar 6, 2026
3883a1c
Switch fully to dpctl_ext.tensor in dpnp
vlad-perevezentsev Mar 6, 2026
23164ac
Reorder _usmarray import in __init__.py
vlad-perevezentsev Mar 6, 2026
18c3d61
Add missing _place_impl() to _copy_utils.py
vlad-perevezentsev Mar 6, 2026
7f14dfc
Update _dlpack.pyx to use dpctl_ext.tensor
vlad-perevezentsev Mar 6, 2026
5e7123d
Update _usmarray.pyx to use dpctl_ext.tensor
vlad-perevezentsev Mar 6, 2026
f4da0de
Integrate dpctl_ext.tensor C-API to dpnp4pybind11.hpp
vlad-perevezentsev Mar 6, 2026
1e4902d
Add from_dlpack to API dpctl_ext.tensor
vlad-perevezentsev Mar 9, 2026
9a50f9f
Extend .gitignore for dpctl_ext/include
vlad-perevezentsev Mar 9, 2026
153a91b
Add DpctlExtCAPI interface target
vlad-perevezentsev Mar 9, 2026
95acc3d
Increase build time for public CI
vlad-perevezentsev Mar 9, 2026
f55507d
Update test_from_dlpack_with_dpt to use dpt.empty
vlad-perevezentsev Mar 10, 2026
9a7fae9
Merge finalize_functional_migration into move_usm_ndarray
vlad-perevezentsev Mar 11, 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
2 changes: 1 addition & 1 deletion .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
actions: write

runs-on: ${{ matrix.os }}
timeout-minutes: 60
timeout-minutes: 80

defaults:
run:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ core
# TODO: revert to `dpctl/`
# when dpnp fully migrates dpctl/tensor
dpctl_ext/**/*.cpython*.so
dpctl_ext/include/
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -344,5 +344,14 @@ if(DEFINED SKBUILD)
set(_ignore_me ${SKBUILD})
endif()

add_subdirectory(dpnp)
# TODO: Replace `${CMAKE_BINARY_DIR}` with a dedicated public include root
# for dpctl_ext C-API headers
# Unlike dpctl which exposes C-API from `dpctl/apis/include`,
# dpctl_ext currently relies on generated headers in the build tree.
# `${CMAKE_BINARY_DIR}` is a temporary workaround.

add_library(DpctlExtCAPI INTERFACE)
target_include_directories(DpctlExtCAPI INTERFACE ${CMAKE_BINARY_DIR})

add_subdirectory(dpctl_ext)
add_subdirectory(dpnp)
83 changes: 82 additions & 1 deletion dpctl_ext/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,89 @@ else()
endif()

# at build time create include/ directory and copy header files over
# set(DPCTL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(DPCTL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)

set(CMAKE_INSTALL_RPATH "$ORIGIN")

function(build_dpctl_ext _trgt _src _dest)
set(options SYCL)
cmake_parse_arguments(BUILD_DPCTL_EXT "${options}" "RELATIVE_PATH" "" ${ARGN})
add_cython_target(${_trgt} ${_src} CXX OUTPUT_VAR _generated_src)
set(_cythonize_trgt "${_trgt}_cythonize_pyx")
python_add_library(${_trgt} MODULE WITH_SOABI ${_generated_src})
if(BUILD_DPCTL_EXT_SYCL)
add_sycl_to_target(TARGET ${_trgt} SOURCES ${_generated_src})
target_compile_options(${_trgt} PRIVATE -fno-sycl-id-queries-fit-in-int)
target_link_options(${_trgt} PRIVATE -fsycl-device-code-split=per_kernel)
if(DPCTL_OFFLOAD_COMPRESS)
target_link_options(${_trgt} PRIVATE --offload-compress)
endif()
if(_dpctl_sycl_targets)
# make fat binary
target_compile_options(
${_trgt}
PRIVATE ${_dpctl_sycl_target_compile_options}
)
target_link_options(${_trgt} PRIVATE ${_dpctl_sycl_target_link_options})
endif()
endif()
target_link_libraries(${_trgt} PRIVATE Python::NumPy)
if(DPCTL_GENERATE_COVERAGE)
target_compile_definitions(${_trgt} PRIVATE CYTHON_TRACE=1 CYTHON_TRACE_NOGIL=1)
if(BUILD_DPCTL_EXT_SYCL)
target_compile_options(${_trgt} PRIVATE -fno-sycl-use-footer)
endif()
endif()
# Dpctl
target_include_directories(${_trgt} PRIVATE ${Dpctl_INCLUDE_DIR})
target_link_directories(${_trgt} PRIVATE ${Dpctl_INCLUDE_DIR}/..)
target_link_libraries(${_trgt} PRIVATE DPCTLSyclInterface)
set(_linker_options "LINKER:${DPCTL_LDFLAGS}")
target_link_options(${_trgt} PRIVATE ${_linker_options})
get_filename_component(_name_wle ${_generated_src} NAME_WLE)
get_filename_component(_generated_src_dir ${_generated_src} DIRECTORY)
set(_generated_public_h "${_generated_src_dir}/${_name_wle}.h")
set(_generated_api_h "${_generated_src_dir}/${_name_wle}_api.h")

# TODO: create separate folder inside build folder that contains only
# headers related to this target and appropriate folder structure to
# eliminate shadow dependencies
get_filename_component(_generated_src_dir_dir ${_generated_src_dir} DIRECTORY)
# TODO: do not set directory if we did not generate header
target_include_directories(${_trgt} INTERFACE ${_generated_src_dir_dir})
set(_rpath_value "$ORIGIN")
if(BUILD_DPCTL_EXT_RELATIVE_PATH)
set(_rpath_value "${_rpath_value}/${BUILD_DPCTL_EXT_RELATIVE_PATH}")
endif()
if(DPCTL_WITH_REDIST)
set(_rpath_value "${_rpath_value}:${_rpath_value}/../../..")
endif()
set_target_properties(${_trgt} PROPERTIES INSTALL_RPATH ${_rpath_value})

install(TARGETS ${_trgt} LIBRARY DESTINATION ${_dest})
install(
FILES ${_generated_api_h}
DESTINATION ${CMAKE_INSTALL_PREFIX}/dpctl_ext/include/${_dest}
OPTIONAL
)
install(
FILES ${_generated_public_h}
DESTINATION ${CMAKE_INSTALL_PREFIX}/dpctl_ext/include/${_dest}
OPTIONAL
)
if(DPCTL_GENERATE_COVERAGE)
get_filename_component(_original_src_dir ${_src} DIRECTORY)
file(RELATIVE_PATH _rel_dir ${CMAKE_SOURCE_DIR} ${_original_src_dir})
install(FILES ${_generated_src} DESTINATION ${CMAKE_INSTALL_PREFIX}/${_rel_dir})
endif()

# Create target with headers only, because python is managing all the
# library imports at runtime
set(_trgt_headers ${_trgt}_headers)
add_library(${_trgt_headers} INTERFACE)
add_dependencies(${_trgt_headers} ${_trgt})
get_target_property(_trgt_headers_dir ${_trgt} INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${_trgt_headers} INTERFACE ${_trgt_headers_dir})
endfunction()

add_subdirectory(tensor)
10 changes: 10 additions & 0 deletions dpctl_ext/tensor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@

find_package(Python COMPONENTS Development.Module)

file(GLOB _cython_sources *.pyx)
foreach(_cy_file ${_cython_sources})
get_filename_component(_trgt ${_cy_file} NAME_WLE)
build_dpctl_ext(${_trgt} ${_cy_file} "dpctl_ext/tensor" RELATIVE_PATH "..")
target_include_directories(${_trgt} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
# target_link_libraries(DpctlCAPI INTERFACE ${_trgt}_headers)
target_link_libraries(DpctlExtCAPI INTERFACE ${_trgt}_headers)
endforeach()

if(WIN32)
if(${CMAKE_VERSION} VERSION_LESS "3.27")
# this is a work-around for target_link_options inserting option after -link option, cause
Expand Down Expand Up @@ -338,6 +347,7 @@ foreach(python_module_name ${_py_trgts})
# dpctl4pybind11.hpp. It will allow to simplify dependency tree
# NOTE: dpctl C-API is resolved at runtime via Python
# target_link_libraries(${python_module_name} PRIVATE DpctlCAPI)
target_link_libraries(${python_module_name} PRIVATE DpctlExtCAPI)
if(DPNP_WITH_REDIST)
set_target_properties(
${python_module_name}
Expand Down
36 changes: 36 additions & 0 deletions dpctl_ext/tensor/__init__.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# *****************************************************************************
# Copyright (c) 2026, Intel Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# - Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# - Neither the name of the copyright holder nor the names of its contributors
# 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"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
# *****************************************************************************

""" This file declares the extension types and functions for the Cython API
implemented in _usmarray.pyx file.
"""

# distutils: language = c++
# cython: language_level=3

from ._usmarray cimport *
74 changes: 74 additions & 0 deletions dpctl_ext/tensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@


from ._accumulation import cumulative_logsumexp, cumulative_prod, cumulative_sum
from ._array_api import __array_api_version__, __array_namespace_info__
from ._clip import clip
from ._constants import e, inf, nan, newaxis, pi
from ._copy_utils import (
asnumpy,
astype,
Expand All @@ -53,6 +55,29 @@
zeros,
zeros_like,
)
from ._data_types import (
bool,
complex64,
complex128,
dtype,
float16,
float32,
float64,
int8,
int16,
int32,
int64,
uint8,
uint16,
uint32,
uint64,
)
from ._device import Device
from ._dldevice_conversions import (
dldevice_to_sycl_device,
sycl_device_to_dldevice,
)
from ._dlpack import from_dlpack
from ._elementwise_funcs import (
abs,
acos,
Expand Down Expand Up @@ -157,6 +182,13 @@
tile,
unstack,
)
from ._print import (
get_print_options,
print_options,
set_print_options,
usm_ndarray_repr,
usm_ndarray_str,
)
from ._reduction import (
argmax,
argmin,
Expand All @@ -168,6 +200,12 @@
reduce_hypot,
sum,
)

# isort: off
# placed here to avoid circular import
from ._usmarray import DLDeviceType, usm_ndarray

# isort: on
from ._reshape import reshape
from ._search_functions import where
from ._searchsorted import searchsorted
Expand All @@ -185,6 +223,32 @@
from ._utility_functions import all, any, diff

__all__ = [
"Device",
"DLDeviceType",
"usm_ndarray",
# data types
"bool",
"dtype",
"int8",
"uint8",
"int16",
"uint16",
"int32",
"uint32",
"int64",
"uint64",
"float16",
"float32",
"float64",
"complex64",
"complex128",
# constants
"e",
"inf",
"nan",
"newaxis",
"pi",
# functions
"abs",
"acos",
"acosh",
Expand Down Expand Up @@ -229,6 +293,7 @@
"cumulative_sum",
"diff",
"divide",
"dldevice_to_sycl_device",
"empty",
"empty_like",
"equal",
Expand All @@ -242,9 +307,11 @@
"flip",
"floor",
"floor_divide",
"from_dlpack",
"from_numpy",
"full",
"full_like",
"get_print_options",
"greater",
"greater_equal",
"hypot",
Expand Down Expand Up @@ -288,6 +355,7 @@
"place",
"positive",
"pow",
"print_options",
"prod",
"proj",
"put",
Expand All @@ -303,6 +371,7 @@
"round",
"rsqrt",
"searchsorted",
"set_print_options",
"sign",
"signbit",
"sin",
Expand All @@ -316,6 +385,7 @@
"subtract",
"sum",
"swapaxes",
"sycl_device_to_dldevice",
"take",
"take_along_axis",
"tan",
Expand All @@ -332,9 +402,13 @@
"unique_inverse",
"unique_values",
"unstack",
"usm_ndarray_repr",
"usm_ndarray_str",
"var",
"vecdot",
"where",
"zeros",
"zeros_like",
"__array_api_version__",
"__array_namespace_info__",
]
Loading
Loading