diff --git a/CHANGELOG.md b/CHANGELOG.md index 32bb55d37ce9..e22f568bda97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -* Added implementation of `dpnp.hamming` [#2341](https://github.com/IntelPython/dpnp/pull/2341) +* Added implementation of `dpnp.hamming` [#2341](https://github.com/IntelPython/dpnp/pull/2341), [#2357](https://github.com/IntelPython/dpnp/pull/2357) ### Changed diff --git a/doc/known_words.txt b/doc/known_words.txt index a663832ea165..f6f301907530 100644 --- a/doc/known_words.txt +++ b/doc/known_words.txt @@ -2,7 +2,9 @@ al ary backend bandlimited +bincount bitwise +Blackman boolean broadcastable broadcasted @@ -36,6 +38,7 @@ fs getter Golub Hadamard +Hanning histogrammed Hypergeometric kwargs @@ -49,9 +52,12 @@ Lanczos Lomax Mersenne meshgrid +minlength Mises multinomial multivalued +namespace +namedtuple NaN NaT nd @@ -69,6 +75,7 @@ Nyquist oneAPI ord orthonormal +radix Penrose Polyutils pre @@ -79,6 +86,7 @@ representable resampling runtimes scikit +se signbit signum sinc diff --git a/doc/reference/linalg.rst b/doc/reference/linalg.rst index 63f7413563ed..79b85ea81f1c 100644 --- a/doc/reference/linalg.rst +++ b/doc/reference/linalg.rst @@ -97,7 +97,7 @@ Other matrix operations dpnp.diagonal dpnp.linalg.diagonal (Array API compatible) - dpnp.linalg.matrix_tranpose (Array API compatible) + dpnp.linalg.matrix_transpose (Array API compatible) Exceptions ---------- diff --git a/doc/reference/logic.rst b/doc/reference/logic.rst index 2e5705e36fbd..85e12318d1db 100644 --- a/doc/reference/logic.rst +++ b/doc/reference/logic.rst @@ -44,7 +44,7 @@ Array type testing Logical operations ----------------- +------------------ .. autosummary:: :toctree: generated/ diff --git a/doc/reference/ndarray.rst b/doc/reference/ndarray.rst index d0589165713b..4f9aef8a9160 100644 --- a/doc/reference/ndarray.rst +++ b/doc/reference/ndarray.rst @@ -18,7 +18,7 @@ Constructing arrays ------------------- New arrays can be constructed using the routines detailed in -:ref:`Array Creation Routines `, and also by using the low-level +:ref:`Array Creation Routines `, and also by using the low-level :class:`dpnp.ndarray` constructor: .. autosummary:: diff --git a/dpnp/backend/extensions/blas/blas_py.cpp b/dpnp/backend/extensions/blas/blas_py.cpp index 217929120254..06f614818f7b 100644 --- a/dpnp/backend/extensions/blas/blas_py.cpp +++ b/dpnp/backend/extensions/blas/blas_py.cpp @@ -23,7 +23,7 @@ // THE POSSIBILITY OF SUCH DAMAGE. //***************************************************************************** // -// This file defines functions of dpnp.backend._lapack_impl extensions +// This file defines functions of dpnp.backend._blas_impl extensions // //***************************************************************************** diff --git a/dpnp/backend/extensions/window/CMakeLists.txt b/dpnp/backend/extensions/window/CMakeLists.txt index d4c392ef7d19..2744ceb027c8 100644 --- a/dpnp/backend/extensions/window/CMakeLists.txt +++ b/dpnp/backend/extensions/window/CMakeLists.txt @@ -26,7 +26,6 @@ set(python_module_name _window_impl) set(_module_src - ${CMAKE_CURRENT_SOURCE_DIR}/hamming.cpp ${CMAKE_CURRENT_SOURCE_DIR}/window_py.cpp ) diff --git a/dpnp/backend/extensions/window/hamming.cpp b/dpnp/backend/extensions/window/common.hpp similarity index 64% rename from dpnp/backend/extensions/window/hamming.cpp rename to dpnp/backend/extensions/window/common.hpp index 1e6fc5edf9cd..067eb4d50bf4 100644 --- a/dpnp/backend/extensions/window/hamming.cpp +++ b/dpnp/backend/extensions/window/common.hpp @@ -23,28 +23,56 @@ // THE POSSIBILITY OF SUCH DAMAGE. //***************************************************************************** +#pragma once + #include #include #include #include "dpctl4pybind11.hpp" -#include "hamming_kernel.hpp" #include "utils/output_validation.hpp" #include "utils/type_dispatch.hpp" +#include "utils/type_utils.hpp" namespace dpnp::extensions::window { namespace dpctl_td_ns = dpctl::tensor::type_dispatch; -static kernels::hamming_fn_ptr_t hamming_dispatch_table[dpctl_td_ns::num_types]; - namespace py = pybind11; +typedef sycl::event (*window_fn_ptr_t)(sycl::queue &, + char *, + const std::size_t, + const std::vector &); + +template class Functor> +sycl::event window_impl(sycl::queue &q, + char *result, + const std::size_t nelems, + const std::vector &depends) +{ + dpctl::tensor::type_utils::validate_type_for_device(q); + + T *res = reinterpret_cast(result); + + sycl::event window_ev = q.submit([&](sycl::handler &cgh) { + cgh.depends_on(depends); + + using WindowKernel = Functor; + cgh.parallel_for(sycl::range<1>(nelems), + WindowKernel(res, nelems)); + }); + + return window_ev; +} + +template std::pair - py_hamming(sycl::queue &exec_q, - const dpctl::tensor::usm_ndarray &result, - const std::vector &depends) + py_window(sycl::queue &exec_q, + const dpctl::tensor::usm_ndarray &result, + const std::vector &depends, + const dispatchT &window_dispatch_vector) { dpctl::tensor::validation::CheckWritable::throw_if_not_writable(result); @@ -71,52 +99,27 @@ std::pair int result_typenum = result.get_typenum(); auto array_types = dpctl_td_ns::usm_ndarray_types(); int result_type_id = array_types.typenum_to_lookup_id(result_typenum); - auto fn = hamming_dispatch_table[result_type_id]; + auto fn = window_dispatch_vector[result_type_id]; if (fn == nullptr) { throw std::runtime_error("Type of given array is not supported"); } char *result_typeless_ptr = result.get_data(); - sycl::event hamming_ev = fn(exec_q, result_typeless_ptr, nelems, depends); + sycl::event window_ev = fn(exec_q, result_typeless_ptr, nelems, depends); sycl::event args_ev = - dpctl::utils::keep_args_alive(exec_q, {result}, {hamming_ev}); + dpctl::utils::keep_args_alive(exec_q, {result}, {window_ev}); - return std::make_pair(args_ev, hamming_ev); + return std::make_pair(args_ev, window_ev); } -template -struct HammingFactory +template