Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 24 additions & 1 deletion dpctl_ext/tensor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ set(_accumulator_sources
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/accumulators/cumulative_prod.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/accumulators/cumulative_sum.cpp
)
set(_reduction_sources
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/reductions/reduction_common.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/reductions/all.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/reductions/any.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/reductions/argmax.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/reductions/argmin.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/reductions/logsumexp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/reductions/max.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/reductions/min.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/reductions/prod.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/reductions/reduce_hypot.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/reductions/sum.cpp
)
set(_sorting_sources
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/sorting/isin.cpp
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/sorting/merge_sort.cpp
Expand All @@ -82,6 +95,10 @@ set(_tensor_accumulation_impl_sources
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/tensor_accumulation.cpp
${_accumulator_sources}
)
set(_tensor_reductions_impl_sources
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/tensor_reductions.cpp
${_reduction_sources}
)
set(_tensor_sorting_impl_sources
${CMAKE_CURRENT_SOURCE_DIR}/libtensor/source/tensor_sorting.cpp
${_sorting_sources}
Expand Down Expand Up @@ -114,6 +131,12 @@ add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_tensor_accumulation_i
target_link_libraries(${python_module_name} PRIVATE ${_static_lib_trgt})
list(APPEND _py_trgts ${python_module_name})

set(python_module_name _tensor_reductions_impl)
pybind11_add_module(${python_module_name} MODULE ${_tensor_reductions_impl_sources})
add_sycl_to_target(TARGET ${python_module_name} SOURCES ${_tensor_reductions_impl_sources})
target_link_libraries(${python_module_name} PRIVATE ${_static_lib_trgt})
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})
Expand All @@ -135,7 +158,7 @@ set(_no_fast_math_sources
list(
APPEND _no_fast_math_sources
# ${_elementwise_sources}
# ${_reduction_sources}
${_reduction_sources}
${_sorting_sources}
# ${_linalg_sources}
${_accumulator_sources}
Expand Down
24 changes: 24 additions & 0 deletions dpctl_ext/tensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@
tile,
unstack,
)
from ._reduction import (
argmax,
argmin,
count_nonzero,
logsumexp,
max,
min,
prod,
reduce_hypot,
sum,
)
from ._reshape import reshape
from ._search_functions import where
from ._searchsorted import searchsorted
Expand All @@ -90,9 +101,14 @@
)
from ._sorting import argsort, sort, top_k
from ._type_utils import can_cast, finfo, iinfo, isdtype, result_type
from ._utility_functions import all, any, diff

__all__ = [
"all",
"any",
"arange",
"argmax",
"argmin",
"argsort",
"asarray",
"asnumpy",
Expand All @@ -102,10 +118,12 @@
"can_cast",
"concat",
"copy",
"count_nonzero",
"clip",
"cumulative_logsumexp",
"cumulative_prod",
"cumulative_sum",
"diff",
"empty",
"empty_like",
"extract",
Expand All @@ -120,15 +138,20 @@
"isdtype",
"isin",
"linspace",
"logsumexp",
"max",
"meshgrid",
"min",
"moveaxis",
"permute_dims",
"nonzero",
"ones",
"ones_like",
"place",
"prod",
"put",
"put_along_axis",
"reduce_hypot",
"repeat",
"reshape",
"result_type",
Expand All @@ -137,6 +160,7 @@
"sort",
"squeeze",
"stack",
"sum",
"swapaxes",
"take",
"take_along_axis",
Expand Down
4 changes: 2 additions & 2 deletions dpctl_ext/tensor/_manipulation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def repeat(x, repeats, /, *, axis=None):
"'repeats' array must be broadcastable to the size of "
"the repeated axis"
)
if not dpt.all(repeats >= 0):
if not dpt_ext.all(repeats >= 0):
raise ValueError("'repeats' elements must be positive")

elif isinstance(repeats, (tuple, list, range)):
Expand All @@ -646,7 +646,7 @@ def repeat(x, repeats, /, *, axis=None):
repeats = dpt_ext.asarray(
repeats, dtype=dpt.int64, usm_type=usm_type, sycl_queue=exec_q
)
if not dpt.all(repeats >= 0):
if not dpt_ext.all(repeats >= 0):
raise ValueError("`repeats` elements must be positive")
else:
raise TypeError(
Expand Down
Loading
Loading