Skip to content

Implements accumulation functions in dpctl.tensor #1602

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
merged 36 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e45c68e
Use `shT` instead of `std::vector<py::ssize_t>` in `repeat`
ndgrigorian Mar 21, 2024
85ccecb
Add missing host task to `host_tasks_list` in _reduction.py
ndgrigorian Mar 21, 2024
80a77e0
Implements `dpt.cumulative_logsumexp`, `dpt.cumulative_prod`, and `dp…
ndgrigorian Mar 23, 2024
761ecd4
Adds the first tests for `dpt.cumulative_sum`
ndgrigorian Mar 23, 2024
346c4aa
Pass host task vector to accumulator kernel calls
ndgrigorian Mar 25, 2024
015079b
Implements `out` keyword for accumulators
ndgrigorian Mar 26, 2024
15ea9ae
Fixes cumulative_logsumexp when both an intermediate input and result…
ndgrigorian Mar 26, 2024
1b752e1
Only permute dims of allocated outputs if accumulated axis is not the…
ndgrigorian Mar 26, 2024
506a8eb
Enable scalar inputs to accumulation functions
ndgrigorian Mar 26, 2024
eaa4011
Adds test for scalar inputs to cumulative_sum
ndgrigorian Mar 26, 2024
7b3fd8f
Adds docstrings for cumulative_sum. cumulative_prod, and cumulative_l…
ndgrigorian Mar 26, 2024
dc9d37b
Merge branch 'master' into feature/tensor-accumulation
ndgrigorian Mar 26, 2024
5da1e66
Removed redundant dtype kind check in _default_accumulation_dtype
ndgrigorian Mar 26, 2024
bc3f5b1
Reduce repetition of code allocation out array in _accumulate_common
ndgrigorian Mar 26, 2024
f8e0a75
Adds tests for accumulation function identities, `include_initial` ke…
ndgrigorian Mar 27, 2024
216cc95
Merge branch 'master' into feature/tensor-accumulation
ndgrigorian Mar 27, 2024
e93e202
Adds more tests for cumulative_sum
ndgrigorian Mar 27, 2024
859c747
Correct typo in kernels/accumulators.hpp
ndgrigorian Mar 27, 2024
441e081
Increase work per work item in inclusive_scan_iter_1d update step
ndgrigorian Mar 27, 2024
64b83bb
Removes a dead branch from _accumulate_common
ndgrigorian Mar 28, 2024
1dbc65c
More accumulator tests
ndgrigorian Mar 28, 2024
53eabe6
Merge branch 'master' into feature/tensor-accumulation
ndgrigorian Mar 28, 2024
07013c3
Removes dead branch from _accumulators.py
ndgrigorian Mar 28, 2024
7b77e16
Adds tests for `cumulative_prod` and `cumulative_logsumexp`
ndgrigorian Mar 28, 2024
f972f88
Widen acceptable results of test_logcumsumexp
ndgrigorian Mar 28, 2024
d2fa2a2
Merge branch 'master' into feature/tensor-accumulation
ndgrigorian Mar 28, 2024
20ee0de
Use np.logaddexp.accumulate in hopes of better numerical accuracy of …
ndgrigorian Mar 28, 2024
6845028
Attempt to improve cumulative_logsumexp testing by computing running …
ndgrigorian Mar 28, 2024
d947ba8
Reduce size of array in test_logcumsumexp_basic
ndgrigorian Mar 28, 2024
6520b8b
Use const qualifiers to make compiler's job easier
oleksandr-pavlyk Mar 30, 2024
4bd02b4
Add test for cumulative_logsumexp for geometric series summation, tes…
oleksandr-pavlyk Mar 29, 2024
1b3ade0
Fix race condition in `custom_inclusive_scan_over_group`
ndgrigorian Mar 31, 2024
0d40493
Remove use of Numpy functions from test_tensor_accumulation and incre…
ndgrigorian Mar 31, 2024
b1016bf
Need barrier after call to custom inclusive scan to avoid race condit…
oleksandr-pavlyk Apr 1, 2024
f4cd66a
Docstring edits
oleksandr-pavlyk Apr 1, 2024
27eb063
Merge pull request #1625 from IntelPython/accumulators-doc-edits
oleksandr-pavlyk Apr 1, 2024
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
17 changes: 17 additions & 0 deletions dpctl/tensor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@ set(_tensor_linalg_impl_sources
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/simplify_iteration_space.cpp
${_linalg_sources}
)
set(_accumulator_sources
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/accumulators/accumulators_common.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/accumulators/cumulative_logsumexp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/accumulators/cumulative_prod.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/accumulators/cumulative_sum.cpp
)
set(_tensor_accumulation_impl_sources
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/tensor_accumulation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/simplify_iteration_space.cpp
${_accumulator_sources}
)

set(_py_trgts)

Expand Down Expand Up @@ -186,6 +197,11 @@ pybind11_add_module(${python_module_name} MODULE ${_tensor_linalg_impl_sources})
add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_tensor_linalg_impl_sources})
list(APPEND _py_trgts ${python_module_name})

set(python_module_name _tensor_accumulation_impl)
pybind11_add_module(${python_module_name} MODULE ${_tensor_accumulation_impl_sources})
add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_tensor_accumulation_impl_sources})
list(APPEND _py_trgts ${python_module_name})

set(_clang_prefix "")
if (WIN32)
set(_clang_prefix "/clang:")
Expand All @@ -203,6 +219,7 @@ list(APPEND _no_fast_math_sources
${_reduction_sources}
${_sorting_sources}
${_linalg_sources}
${_accumulator_sources}
)

foreach(_src_fn ${_no_fast_math_sources})
Expand Down
4 changes: 4 additions & 0 deletions dpctl/tensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
from dpctl.tensor._usmarray import usm_ndarray
from dpctl.tensor._utility_functions import all, any

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
Expand Down Expand Up @@ -367,4 +368,7 @@
"tensordot",
"vecdot",
"searchsorted",
"cumulative_logsumexp",
"cumulative_prod",
"cumulative_sum",
]
Loading