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

Implementation of sort/argsort and set functions per array API spec #1483

Merged
merged 34 commits into from
Jan 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c2d21d0
Initial check in of sort/argsort per array API spec
oleksandr-pavlyk Dec 6, 2023
84437f1
Added docstrings
oleksandr-pavlyk Dec 6, 2023
8076adf
Added license header comments
oleksandr-pavlyk Dec 6, 2023
3cb7b15
Corrected variable name used in assertion
oleksandr-pavlyk Dec 6, 2023
d79962d
Ensure that we use no more SLM than is available
oleksandr-pavlyk Dec 7, 2023
aa1df8b
Implementation of set functions
oleksandr-pavlyk Dec 8, 2023
709ed1e
Exposed set functions to dpctl.tensor namespace
oleksandr-pavlyk Dec 8, 2023
5635d85
Added __all__ for _sorting.py
oleksandr-pavlyk Dec 8, 2023
88ad12f
Expand tests for sorting to improve coverage
oleksandr-pavlyk Dec 8, 2023
734cf77
Tests for set functions
oleksandr-pavlyk Dec 8, 2023
11344b1
Added license header for test file
oleksandr-pavlyk Dec 8, 2023
b1d1006
Do not use shorcut API for copy with dependency
oleksandr-pavlyk Dec 8, 2023
34b50af
Implement set functions using synchronizing ops
oleksandr-pavlyk Dec 8, 2023
1c7efc7
Renamed unused _set_functions.py and added it to omit list for coverage
oleksandr-pavlyk Dec 9, 2023
fad8470
Use sequential sorting for small arrays
oleksandr-pavlyk Dec 9, 2023
fa3d8fe
Do not use shorthand queue::copy
oleksandr-pavlyk Dec 11, 2023
abfc280
Do not use queue::fill convenience shortcut functions
oleksandr-pavlyk Dec 11, 2023
5e0e5eb
Accumulate implementations API acquired host_task_events argument
oleksandr-pavlyk Dec 11, 2023
6abb9fe
Changed inclusive sum implementation from recursive to iterative
oleksandr-pavlyk Dec 15, 2023
b149096
Use async implementation of set functions
oleksandr-pavlyk Dec 19, 2023
eeb30f6
Permit copying when flattening for `unique` funcs
ndgrigorian Dec 19, 2023
0035558
Fix typos in set functions
ndgrigorian Dec 19, 2023
a7e7625
Fixes to unique functions, adds tests
ndgrigorian Dec 19, 2023
2fe8620
Sorting, unique functions properly handle 0D arrays
ndgrigorian Dec 20, 2023
8a6581a
`unique_all` and `unique_inverse` inverse indices shape fixed
ndgrigorian Dec 20, 2023
82be69a
Set `stable` to True for sorting functions by default
ndgrigorian Dec 21, 2023
81610d6
Adds tests for 0D array cases for sorting
ndgrigorian Dec 21, 2023
b0cc135
Adds tests for `unique` functions on strided inputs
ndgrigorian Dec 21, 2023
8a6282f
Tests for strided 1D data input for `unique` functions
ndgrigorian Dec 21, 2023
dd71e4e
Changes to _set_functions_sync.py for test suite to pass
oleksandr-pavlyk Jan 8, 2024
b1b0af1
Removed sync implementation of set functions
oleksandr-pavlyk Jan 8, 2024
08e5dac
Renamed _set_functions_async -> _set_functions
oleksandr-pavlyk Jan 8, 2024
a3d0d08
Use extended comparison operators to define weak order on real/comple…
oleksandr-pavlyk Jan 9, 2024
5469832
Adding tests for sorting of FP arrays with NaNs
oleksandr-pavlyk Jan 9, 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
14 changes: 14 additions & 0 deletions dpctl/tensor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ set(_reduction_sources
set(_boolean_reduction_sources
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/boolean_reductions.cpp
)
set(_sorting_sources
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/sorting/sort.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/sorting/argsort.cpp
)
set(_tensor_impl_sources
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/tensor_ctors.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/simplify_iteration_space.cpp
Expand Down Expand Up @@ -148,6 +152,10 @@ set(_tensor_reductions_impl_sources
${_boolean_reduction_sources}
${_reduction_sources}
)
set(_tensor_sorting_impl_sources
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/tensor_sorting.cpp
${_sorting_sources}
)

set(_py_trgts)

Expand All @@ -166,6 +174,11 @@ pybind11_add_module(${python_module_name} MODULE ${_tensor_reductions_impl_sourc
add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_tensor_reductions_impl_sources})
list(APPEND _py_trgts ${python_module_name})

set(python_module_name _tensor_sorting_impl)
pybind11_add_module(${python_module_name} MODULE ${_tensor_sorting_impl_sources})
add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_tensor_sorting_impl_sources})
list(APPEND _py_trgts ${python_module_name})

set(_clang_prefix "")
if (WIN32)
set(_clang_prefix "/clang:")
Expand All @@ -179,6 +192,7 @@ set(_no_fast_math_sources
list(APPEND _no_fast_math_sources
${_elementwise_sources}
${_reduction_sources}
${_sorting_sources}
)

foreach(_src_fn ${_no_fast_math_sources})
Expand Down
13 changes: 13 additions & 0 deletions dpctl/tensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@
reduce_hypot,
sum,
)
from ._set_functions import (
unique_all,
unique_counts,
unique_inverse,
unique_values,
)
from ._sorting import argsort, sort
from ._testing import allclose
from ._type_utils import can_cast, finfo, iinfo, result_type

Expand Down Expand Up @@ -343,4 +350,10 @@
"__array_namespace_info__",
"reciprocal",
"angle",
"sort",
"argsort",
"unique_all",
"unique_counts",
"unique_inverse",
"unique_values",
]
Loading
Loading