Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement extension for dpnp.choose #2201

Merged
merged 45 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
aef8ca7
Implement extension for dpnp.choose
ndgrigorian Nov 26, 2024
5385707
Remove dead dpnp_choose code
ndgrigorian Nov 26, 2024
f3b68b4
unstack `choices` in `choose` when input is array
ndgrigorian Nov 26, 2024
7ee525c
Always unstack choices array regardless of dimension
ndgrigorian Nov 26, 2024
1a42b65
Do not allow choose tests to fallback to NumPy
ndgrigorian Nov 26, 2024
6784d96
Skip `test_choose_wrap` from CuPy tests
ndgrigorian Nov 26, 2024
a372de8
Factor `out` keyword validation and kernel run out of `choose`
ndgrigorian Nov 26, 2024
29067ed
pre-commit fixes
ndgrigorian Nov 26, 2024
3158fbb
Use `dpctl::tensor` scope for `ssize_t`
ndgrigorian Nov 26, 2024
a3dfd57
Use std::equal and get_size instead of loop over shape
ndgrigorian Dec 9, 2024
a41e858
Move first iteration of indices validation into loop
ndgrigorian Dec 9, 2024
15a921c
Use std::equal in loop over all choice arrays
ndgrigorian Dec 9, 2024
26cc0e0
Use unique_ptrs for temporary device allocations in choose
ndgrigorian Dec 9, 2024
28f4d10
Remove debug leftovers
ndgrigorian Dec 10, 2024
17b230e
Remove DPNP_FN_CHOOSE_EXT and DPNP_FN_CHOOSE
ndgrigorian Dec 10, 2024
1c311ac
Update choose docstring
ndgrigorian Dec 10, 2024
ec273dc
x -> a in choose
ndgrigorian Dec 10, 2024
520d763
Using issubdtype in choose integral indices check
ndgrigorian Dec 10, 2024
b9fc780
Use get_usm_allocations in choose
ndgrigorian Dec 10, 2024
8a32c37
choose method allows choices as keyword or positional argument
ndgrigorian Dec 10, 2024
eacf098
Remove unnecessary check_supported_arrays_type in choose
ndgrigorian Dec 10, 2024
5ad0067
Remove redundant get_usm_ndarray
ndgrigorian Dec 10, 2024
2b80aa6
Allow any Iterable object when building choices list
ndgrigorian Dec 10, 2024
205b1b0
Set rpath in indexing extension cmake
ndgrigorian Dec 10, 2024
0459c73
Add two examples to `choose`
ndgrigorian Dec 10, 2024
fcbcdd1
Make py_choose offsets constexpr
ndgrigorian Dec 10, 2024
bca0853
Adds new choose tests
ndgrigorian Dec 10, 2024
3125fe0
Fixes a bug for 0d inputs to choose and adds a test
ndgrigorian Dec 11, 2024
496d90c
Adds more tests for choose
ndgrigorian Dec 11, 2024
cbe923b
Remove unnecessary gws variable in choose kernel
ndgrigorian Dec 11, 2024
4e70b2b
Simplify _build_choices_list
ndgrigorian Dec 11, 2024
d56a76a
Tweaks to choose docstring
ndgrigorian Dec 11, 2024
00b9bb7
Add no_none=True to choose type matrix test
ndgrigorian Dec 11, 2024
bac8dac
Add take_along_axis to choose docstring and fix a typo
ndgrigorian Dec 11, 2024
9913bd8
Reduce choose dispatching code duplication
ndgrigorian Dec 11, 2024
338f0ae
Test choose with non-overlapping out and choose with invalid choice o…
ndgrigorian Dec 11, 2024
d4d72a0
Fix spacing in choose docstring
ndgrigorian Dec 12, 2024
981c079
Changes to choose docstring
ndgrigorian Dec 13, 2024
feac756
Use smart pointer utilities from dpctl
ndgrigorian Jan 8, 2025
ca26fbd
Use ChooseFunctor as choose kernel name
ndgrigorian Jan 8, 2025
92c6040
Break up _populate_choose_kernel_params
ndgrigorian Jan 28, 2025
7c9a987
Add assertion that NthStrideOffsetUnpacked struct is device copyable
ndgrigorian Feb 3, 2025
54676b9
Fix typos in choose docstring
ndgrigorian Feb 3, 2025
dd6e27e
Clarify choose method docstring
ndgrigorian Feb 3, 2025
6609637
Remove choose tests from skipped CUDA tests
ndgrigorian Feb 3, 2025
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
1 change: 1 addition & 0 deletions dpnp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ add_subdirectory(backend/extensions/lapack)
add_subdirectory(backend/extensions/vm)
add_subdirectory(backend/extensions/ufunc)
add_subdirectory(backend/extensions/statistics)
add_subdirectory(backend/extensions/indexing)

add_subdirectory(dpnp_algo)
add_subdirectory(dpnp_utils)
Expand Down
1 change: 0 additions & 1 deletion dpnp/backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ set(DPNP_SRC
kernels/dpnp_krnl_arraycreation.cpp
kernels/dpnp_krnl_common.cpp
kernels/dpnp_krnl_elemwise.cpp
kernels/dpnp_krnl_indexing.cpp
kernels/dpnp_krnl_mathematical.cpp
kernels/dpnp_krnl_random.cpp
kernels/dpnp_krnl_sorting.cpp
Expand Down
90 changes: 90 additions & 0 deletions dpnp/backend/extensions/indexing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# *****************************************************************************
# Copyright (c) 2016-2024, 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.
#
# 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.
# *****************************************************************************


set(python_module_name _indexing_impl)
set(_module_src
${CMAKE_CURRENT_SOURCE_DIR}/choose.cpp
${CMAKE_CURRENT_SOURCE_DIR}/indexing_py.cpp
)

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

if(_dpnp_sycl_targets)
# make fat binary
target_compile_options(
${python_module_name}
PRIVATE
-fsycl-targets=${_dpnp_sycl_targets}
)
target_link_options(
${python_module_name}
PRIVATE
-fsycl-targets=${_dpnp_sycl_targets}
)
endif()

if (WIN32)
if (${CMAKE_VERSION} VERSION_LESS "3.27")
# this is a work-around for target_link_options inserting option after -link option, cause
# linker to ignore it.
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -fsycl-device-code-split=per_kernel")
endif()
endif()

set_target_properties(${python_module_name} PROPERTIES CMAKE_POSITION_INDEPENDENT_CODE ON)

target_include_directories(${python_module_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include)
target_include_directories(${python_module_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../src)

target_include_directories(${python_module_name} PUBLIC ${Dpctl_INCLUDE_DIR})
target_include_directories(${python_module_name} PUBLIC ${Dpctl_TENSOR_INCLUDE_DIR})

if (WIN32)
target_compile_options(${python_module_name} PRIVATE
/clang:-fno-approx-func
/clang:-fno-finite-math-only
)
else()
target_compile_options(${python_module_name} PRIVATE
-fno-approx-func
-fno-finite-math-only
)
endif()

target_link_options(${python_module_name} PUBLIC -fsycl-device-code-split=per_kernel)

if (DPNP_GENERATE_COVERAGE)
target_link_options(${python_module_name} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
endif()

if (DPNP_WITH_REDIST)
set_target_properties(${python_module_name} PROPERTIES INSTALL_RPATH "$ORIGIN/../../../../../../")
endif()

install(TARGETS ${python_module_name}
DESTINATION "dpnp/backend/extensions/indexing"
)
Loading
Loading