-
Notifications
You must be signed in to change notification settings - Fork 23
Implement extension for dpnp.choose
#2201
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
Merged
antonwolfy
merged 45 commits into
IntelPython:master
from
ndgrigorian:dedicated-choose-kernel
Feb 4, 2025
Merged
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 5385707
Remove dead dpnp_choose code
ndgrigorian f3b68b4
unstack `choices` in `choose` when input is array
ndgrigorian 7ee525c
Always unstack choices array regardless of dimension
ndgrigorian 1a42b65
Do not allow choose tests to fallback to NumPy
ndgrigorian 6784d96
Skip `test_choose_wrap` from CuPy tests
ndgrigorian a372de8
Factor `out` keyword validation and kernel run out of `choose`
ndgrigorian 29067ed
pre-commit fixes
ndgrigorian 3158fbb
Use `dpctl::tensor` scope for `ssize_t`
ndgrigorian a3dfd57
Use std::equal and get_size instead of loop over shape
ndgrigorian a41e858
Move first iteration of indices validation into loop
ndgrigorian 15a921c
Use std::equal in loop over all choice arrays
ndgrigorian 26cc0e0
Use unique_ptrs for temporary device allocations in choose
ndgrigorian 28f4d10
Remove debug leftovers
ndgrigorian 17b230e
Remove DPNP_FN_CHOOSE_EXT and DPNP_FN_CHOOSE
ndgrigorian 1c311ac
Update choose docstring
ndgrigorian ec273dc
x -> a in choose
ndgrigorian 520d763
Using issubdtype in choose integral indices check
ndgrigorian b9fc780
Use get_usm_allocations in choose
ndgrigorian 8a32c37
choose method allows choices as keyword or positional argument
ndgrigorian eacf098
Remove unnecessary check_supported_arrays_type in choose
ndgrigorian 5ad0067
Remove redundant get_usm_ndarray
ndgrigorian 2b80aa6
Allow any Iterable object when building choices list
ndgrigorian 205b1b0
Set rpath in indexing extension cmake
ndgrigorian 0459c73
Add two examples to `choose`
ndgrigorian fcbcdd1
Make py_choose offsets constexpr
ndgrigorian bca0853
Adds new choose tests
ndgrigorian 3125fe0
Fixes a bug for 0d inputs to choose and adds a test
ndgrigorian 496d90c
Adds more tests for choose
ndgrigorian cbe923b
Remove unnecessary gws variable in choose kernel
ndgrigorian 4e70b2b
Simplify _build_choices_list
ndgrigorian d56a76a
Tweaks to choose docstring
ndgrigorian 00b9bb7
Add no_none=True to choose type matrix test
ndgrigorian bac8dac
Add take_along_axis to choose docstring and fix a typo
ndgrigorian 9913bd8
Reduce choose dispatching code duplication
ndgrigorian 338f0ae
Test choose with non-overlapping out and choose with invalid choice o…
ndgrigorian d4d72a0
Fix spacing in choose docstring
ndgrigorian 981c079
Changes to choose docstring
ndgrigorian feac756
Use smart pointer utilities from dpctl
ndgrigorian ca26fbd
Use ChooseFunctor as choose kernel name
ndgrigorian 92c6040
Break up _populate_choose_kernel_params
ndgrigorian 7c9a987
Add assertion that NthStrideOffsetUnpacked struct is device copyable
ndgrigorian 54676b9
Fix typos in choose docstring
ndgrigorian dd6e27e
Clarify choose method docstring
ndgrigorian 6609637
Remove choose tests from skipped CUDA tests
ndgrigorian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.