From 0e10a078b470201e8e866e4d8290644b9e6e5ef8 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Mon, 5 Aug 2024 21:34:45 +0200 Subject: [PATCH 1/3] Implement dpnp.fix() --- dpnp/backend/extensions/ufunc/CMakeLists.txt | 1 + .../ufunc/elementwise_functions/common.cpp | 2 + .../ufunc/elementwise_functions/fix.cpp | 125 ++++++++++++++++++ .../ufunc/elementwise_functions/fix.hpp | 35 +++++ .../kernels/elementwise_functions/fix.hpp | 49 +++++++ dpnp/dpnp_iface_mathematical.py | 68 ++++++++++ 6 files changed, 280 insertions(+) create mode 100644 dpnp/backend/extensions/ufunc/elementwise_functions/fix.cpp create mode 100644 dpnp/backend/extensions/ufunc/elementwise_functions/fix.hpp create mode 100644 dpnp/backend/kernels/elementwise_functions/fix.hpp diff --git a/dpnp/backend/extensions/ufunc/CMakeLists.txt b/dpnp/backend/extensions/ufunc/CMakeLists.txt index 04ceb157246..b1964b246b1 100644 --- a/dpnp/backend/extensions/ufunc/CMakeLists.txt +++ b/dpnp/backend/extensions/ufunc/CMakeLists.txt @@ -27,6 +27,7 @@ set(_elementwise_sources ${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/common.cpp ${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/degrees.cpp ${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/fabs.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/fix.cpp ${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/fmax.cpp ${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/fmin.cpp ${CMAKE_CURRENT_SOURCE_DIR}/elementwise_functions/fmod.cpp diff --git a/dpnp/backend/extensions/ufunc/elementwise_functions/common.cpp b/dpnp/backend/extensions/ufunc/elementwise_functions/common.cpp index c00d790d194..136367abf23 100644 --- a/dpnp/backend/extensions/ufunc/elementwise_functions/common.cpp +++ b/dpnp/backend/extensions/ufunc/elementwise_functions/common.cpp @@ -27,6 +27,7 @@ #include "degrees.hpp" #include "fabs.hpp" +#include "fix.hpp" #include "fmax.hpp" #include "fmin.hpp" #include "fmod.hpp" @@ -44,6 +45,7 @@ void init_elementwise_functions(py::module_ m) { init_degrees(m); init_fabs(m); + init_fix(m); init_fmax(m); init_fmin(m); init_fmod(m); diff --git a/dpnp/backend/extensions/ufunc/elementwise_functions/fix.cpp b/dpnp/backend/extensions/ufunc/elementwise_functions/fix.cpp new file mode 100644 index 00000000000..fbef5f08ffa --- /dev/null +++ b/dpnp/backend/extensions/ufunc/elementwise_functions/fix.cpp @@ -0,0 +1,125 @@ +//***************************************************************************** +// Copyright (c) 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. +//***************************************************************************** + +#include + +#include "dpctl4pybind11.hpp" + +#include "fix.hpp" +#include "kernels/elementwise_functions/fix.hpp" +#include "populate.hpp" + +// include a local copy of elementwise common header from dpctl tensor: +// dpctl/tensor/libtensor/source/elementwise_functions/elementwise_functions.hpp +// TODO: replace by including dpctl header once available +#include "../../elementwise_functions/elementwise_functions.hpp" + +// dpctl tensor headers +#include "kernels/elementwise_functions/common.hpp" +#include "utils/type_dispatch.hpp" + +namespace dpnp::extensions::ufunc +{ +namespace py = pybind11; +namespace py_int = dpnp::extensions::py_internal; + +namespace impl +{ +namespace ew_cmn_ns = dpctl::tensor::kernels::elementwise_common; +namespace td_ns = dpctl::tensor::type_dispatch; + +/** + * @brief A factory to define pairs of supported types for which + * sycl::fix function is available. + * + * @tparam T Type of input vector `a` and of result vector `y`. + */ +template +struct OutputType +{ + using value_type = + typename std::disjunction, + td_ns::TypeMapResultEntry, + td_ns::TypeMapResultEntry, + td_ns::DefaultResultEntry>::result_type; +}; + +using dpnp::kernels::fix::FixFunctor; + +template +using ContigFunctor = ew_cmn_ns::UnaryContigFunctor, + vec_sz, + n_vecs, + enable_sg_loadstore>; + +template +using StridedFunctor = ew_cmn_ns:: + UnaryStridedFunctor>; + +using ew_cmn_ns::unary_contig_impl_fn_ptr_t; +using ew_cmn_ns::unary_strided_impl_fn_ptr_t; + +static unary_contig_impl_fn_ptr_t fix_contig_dispatch_vector[td_ns::num_types]; +static int fix_output_typeid_vector[td_ns::num_types]; +static unary_strided_impl_fn_ptr_t + fix_strided_dispatch_vector[td_ns::num_types]; + +MACRO_POPULATE_DISPATCH_VECTORS(fix); +} // namespace impl + +void init_fix(py::module_ m) +{ + using arrayT = dpctl::tensor::usm_ndarray; + using event_vecT = std::vector; + { + impl::populate_fix_dispatch_vectors(); + using impl::fix_contig_dispatch_vector; + using impl::fix_output_typeid_vector; + using impl::fix_strided_dispatch_vector; + + auto fix_pyapi = [&](const arrayT &src, const arrayT &dst, + sycl::queue &exec_q, + const event_vecT &depends = {}) { + return py_int::py_unary_ufunc( + src, dst, exec_q, depends, fix_output_typeid_vector, + fix_contig_dispatch_vector, fix_strided_dispatch_vector); + }; + m.def("_fix", fix_pyapi, "", py::arg("src"), py::arg("dst"), + py::arg("sycl_queue"), py::arg("depends") = py::list()); + + auto fix_result_type_pyapi = [&](const py::dtype &dtype) { + return py_int::py_unary_ufunc_result_type(dtype, + fix_output_typeid_vector); + }; + m.def("_fix_result_type", fix_result_type_pyapi); + } +} +} // namespace dpnp::extensions::ufunc diff --git a/dpnp/backend/extensions/ufunc/elementwise_functions/fix.hpp b/dpnp/backend/extensions/ufunc/elementwise_functions/fix.hpp new file mode 100644 index 00000000000..761bc21f161 --- /dev/null +++ b/dpnp/backend/extensions/ufunc/elementwise_functions/fix.hpp @@ -0,0 +1,35 @@ +//***************************************************************************** +// Copyright (c) 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. +//***************************************************************************** + +#pragma once + +#include + +namespace py = pybind11; + +namespace dpnp::extensions::ufunc +{ +void init_fix(py::module_ m); +} // namespace dpnp::extensions::ufunc diff --git a/dpnp/backend/kernels/elementwise_functions/fix.hpp b/dpnp/backend/kernels/elementwise_functions/fix.hpp new file mode 100644 index 00000000000..30e60d40fad --- /dev/null +++ b/dpnp/backend/kernels/elementwise_functions/fix.hpp @@ -0,0 +1,49 @@ +//***************************************************************************** +// Copyright (c) 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. +//***************************************************************************** + +#pragma once + +#include + +namespace dpnp::kernels::fix +{ +template +struct FixFunctor +{ + // is function constant for given argT + using is_constant = typename std::false_type; + // constant value, if constant + // constexpr resT constant_value = resT{}; + // is function defined for sycl::vec + using supports_vec = typename std::false_type; + // do both argT and resT support subgroup store/load operation + using supports_sg_loadstore = typename std::true_type; + + resT operator()(const argT &x) const + { + return (x >= 0.0) ? sycl::floor(x) : sycl::ceil(x); + } +}; +} // namespace dpnp::kernels::fix diff --git a/dpnp/dpnp_iface_mathematical.py b/dpnp/dpnp_iface_mathematical.py index 48ae754b462..593163bdfa0 100644 --- a/dpnp/dpnp_iface_mathematical.py +++ b/dpnp/dpnp_iface_mathematical.py @@ -98,6 +98,7 @@ "divide", "ediff1d", "fabs", + "fix", "floor", "floor_divide", "fmax", @@ -526,6 +527,7 @@ def around(x, /, decimals=0, out=None): :obj:`dpnp.round` : Equivalent function; see for details. :obj:`dpnp.ndarray.round` : Equivalent function. :obj:`dpnp.rint` : Round elements of the array to the nearest integer. + :obj:`dpnp.fix` : Round to nearest integer towards zero, element-wise. :obj:`dpnp.ceil` : Compute the ceiling of the input, element-wise. :obj:`dpnp.floor` : Return the floor of the input, element-wise. :obj:`dpnp.trunc` : Return the truncated value of the input, element-wise. @@ -571,6 +573,8 @@ def around(x, /, decimals=0, out=None): -------- :obj:`dpnp.floor` : Return the floor of the input, element-wise. :obj:`dpnp.trunc` : Return the truncated value of the input, element-wise. +:obj:`dpnp.rint` : Round elements of the array to the nearest integer. +:obj:`dpnp.fix` : Round to nearest integer towards zero, element-wise. Examples -------- @@ -1364,6 +1368,64 @@ def ediff1d(x1, to_end=None, to_begin=None): ) +_FIX_DOCSTRING = """ +Round to nearest integer towards zero. + +Round an array of floats element-wise to nearest integer towards zero. +The rounded values are returned as floats. + +For full documentation refer to :obj:`numpy.fix`. + +Parameters +---------- +x : {dpnp.ndarray, usm_ndarray} + The array of numbers for which the absolute values are required. +out : {None, dpnp.ndarray, usm_ndarray}, optional + Output array to populate. + Array must have the correct shape and the expected data type. + Default: ``None``. +order : {"C", "F", "A", "K"}, optional + Memory layout of the newly output array, if parameter `out` is ``None``. + Default: ``"K"``. + +Returns +------- +out : dpnp.ndarray + An array with the rounded values and with the same dimensions as the input. + The returned array will have the default floating point data type for the + device where `a` is allocated. + If `out` is ``None`` then a float array is returned with the rounded values. + Otherwise the result is stored there and the return value `out` is + a reference to that array. + +See Also +-------- +:obj:`dpnp.round` : Round to given number of decimals. +:obj:`dpnp.rint` : Round elements of the array to the nearest integer. +:obj:`dpnp.trunc` : Return the truncated value of the input, element-wise. +:obj:`dpnp.floor` : Return the floor of the input, element-wise. +:obj:`dpnp.ceil` : Return the ceiling of the input, element-wise. + +Examples +-------- +>>> import dpnp as np +>>> np.fix(np.array(3.14)) +array(3.) +>>> np.fix(np.array(3)) +array(3.) +>>> a = np.array([2.1, 2.9, -2.1, -2.9]) +>>> np.fix(a) +array([ 2., 2., -2., -2.]) +""" + +fix = DPNPUnaryFunc( + "fix", + ufi._fix_result_type, + ufi._fix, + _FIX_DOCSTRING, +) + + _FLOOR_DOCSTRING = """ Returns the floor for each element `x_i` for input array `x`. @@ -1398,6 +1460,8 @@ def ediff1d(x1, to_end=None, to_begin=None): -------- :obj:`dpnp.ceil` : Compute the ceiling of the input, element-wise. :obj:`dpnp.trunc` : Return the truncated value of the input, element-wise. +:obj:`dpnp.rint` : Round elements of the array to the nearest integer. +:obj:`dpnp.fix` : Round to nearest integer towards zero, element-wise. Notes ----- @@ -2806,6 +2870,7 @@ def prod( See Also -------- :obj:`dpnp.round` : Evenly round to the given number of decimals. +:obj:`dpnp.fix` : Round to nearest integer towards zero, element-wise. :obj:`dpnp.ceil` : Compute the ceiling of the input, element-wise. :obj:`dpnp.floor` : Return the floor of the input, element-wise. :obj:`dpnp.trunc` : Return the truncated value of the input, element-wise. @@ -2861,6 +2926,7 @@ def prod( :obj:`dpnp.ndarray.round` : Equivalent function. :obj:`dpnp.rint` : Round elements of the array to the nearest integer. :obj:`dpnp.ceil` : Compute the ceiling of the input, element-wise. +:obj:`dpnp.fix` : Round to nearest integer towards zero, element-wise. :obj:`dpnp.floor` : Return the floor of the input, element-wise. :obj:`dpnp.trunc` : Return the truncated value of the input, element-wise. @@ -3294,6 +3360,8 @@ def trapz(y1, x1=None, dx=1.0, axis=-1): -------- :obj:`dpnp.floor` : Round a number to the nearest integer toward minus infinity. :obj:`dpnp.ceil` : Round a number to the nearest integer toward infinity. +:obj:`dpnp.rint` : Round elements of the array to the nearest integer. +:obj:`dpnp.fix` : Round to nearest integer towards zero, element-wise. Examples -------- From 54795cd258db37c85a5c70899f0f6b8e4195fddf Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Mon, 5 Aug 2024 22:14:22 +0200 Subject: [PATCH 2/3] Add tests to cover function --- tests/skipped_tests.tbl | 2 -- tests/skipped_tests_gpu.tbl | 2 -- tests/test_mathematical.py | 67 +++++++++++++++++++++++++++++++++++++ tests/test_sycl_queue.py | 1 + tests/test_usm_type.py | 1 + 5 files changed, 69 insertions(+), 4 deletions(-) diff --git a/tests/skipped_tests.tbl b/tests/skipped_tests.tbl index 52b55443480..a7ad05dd7a7 100644 --- a/tests/skipped_tests.tbl +++ b/tests/skipped_tests.tbl @@ -245,8 +245,6 @@ tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_interp_inf_to_nan tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_heaviside tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_heaviside_nan_inf -tests/third_party/cupy/math_tests/test_rounding.py::TestRounding::test_fix - tests/third_party/cupy/random_tests/test_distributions.py::TestDistributionsBeta_param_0_{a_shape=(), b_shape=(), shape=(4, 3, 2)}::test_beta tests/third_party/cupy/random_tests/test_distributions.py::TestDistributionsBeta_param_1_{a_shape=(), b_shape=(), shape=(3, 2)}::test_beta tests/third_party/cupy/random_tests/test_distributions.py::TestDistributionsBeta_param_2_{a_shape=(), b_shape=(3, 2), shape=(4, 3, 2)}::test_beta diff --git a/tests/skipped_tests_gpu.tbl b/tests/skipped_tests_gpu.tbl index ad820d0bd1e..b1be48affbc 100644 --- a/tests/skipped_tests_gpu.tbl +++ b/tests/skipped_tests_gpu.tbl @@ -299,8 +299,6 @@ tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_interp_inf_to_nan tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_heaviside tests/third_party/cupy/math_tests/test_misc.py::TestMisc::test_heaviside_nan_inf -tests/third_party/cupy/math_tests/test_rounding.py::TestRounding::test_fix - tests/third_party/cupy/random_tests/test_distributions.py::TestDistributionsBeta_param_0_{a_shape=(), b_shape=(), shape=(4, 3, 2)}::test_beta tests/third_party/cupy/random_tests/test_distributions.py::TestDistributionsBeta_param_1_{a_shape=(), b_shape=(), shape=(3, 2)}::test_beta tests/third_party/cupy/random_tests/test_distributions.py::TestDistributionsBeta_param_2_{a_shape=(), b_shape=(3, 2), shape=(4, 3, 2)}::test_beta diff --git a/tests/test_mathematical.py b/tests/test_mathematical.py index 8b91e1876d3..bd9d3aa184f 100644 --- a/tests/test_mathematical.py +++ b/tests/test_mathematical.py @@ -615,6 +615,73 @@ def test_prepend_append_axis_error(self, xp): assert_raises(AxisError, xp.diff, a, axis=3, append=0) +class TestFix: + @pytest.mark.parametrize( + "dt", get_all_dtypes(no_none=True, no_complex=True) + ) + def test_basic(self, dt): + a = numpy.array( + [[1.0, 1.1, 1.5, 1.8], [-1.0, -1.1, -1.5, -1.8]], dtype=dt + ) + ia = dpnp.array(a) + + result = dpnp.fix(ia) + expected = numpy.fix(a) + assert_array_equal(result, expected) + + @pytest.mark.parametrize("xp", [numpy, dpnp]) + @pytest.mark.parametrize("dt", get_complex_dtypes()) + def test_complex(self, xp, dt): + a = xp.array([1.1, -1.1], dtype=dt) + with pytest.raises((ValueError, TypeError)): + xp.fix(a) + + @pytest.mark.parametrize( + "a_dt", get_all_dtypes(no_none=True, no_bool=True, no_complex=True) + ) + def test_out(self, a_dt): + a = numpy.array( + [[1.0, 1.1, 1.5, 1.8], [-1.0, -1.1, -1.5, -1.8]], dtype=a_dt + ) + ia = dpnp.array(a) + + if a.dtype != numpy.float32 and has_support_aspect64(): + out_dt = numpy.float64 + else: + out_dt = numpy.float32 + out = numpy.zeros_like(a, dtype=out_dt) + iout = dpnp.array(out) + + result = dpnp.fix(ia, out=iout) + expected = numpy.fix(a, out=out) + assert_array_equal(result, expected) + + @pytest.mark.skipif(not has_support_aspect16(), reason="no fp16 support") + @pytest.mark.parametrize("dt", [bool, numpy.float16]) + def test_out_float16(self, dt): + a = numpy.array( + [[1.0, 1.1], [1.5, 1.8], [-1.0, -1.1], [-1.5, -1.8]], dtype=dt + ) + out = numpy.zeros_like(a, dtype=numpy.float16) + ia, iout = dpnp.array(a), dpnp.array(out) + + result = dpnp.fix(ia, out=iout) + expected = numpy.fix(a, out=out) + assert_array_equal(result, expected) + + @pytest.mark.parametrize("xp", [numpy, dpnp]) + @pytest.mark.parametrize("dt", [bool] + get_integer_dtypes()) + def test_out_invalid_dtype(self, xp, dt): + a = xp.array([[1.5, 1.8], [-1.0, -1.1]]) + out = xp.zeros_like(a, dtype=dt) + + with pytest.raises((ValueError, TypeError)): + xp.fix(a, out=out) + + def test_scalar(self): + assert_raises(TypeError, dpnp.fix, -3.4) + + class TestGradient: @pytest.mark.parametrize("dt", get_all_dtypes(no_none=True, no_bool=True)) def test_basic(self, dt): diff --git a/tests/test_sycl_queue.py b/tests/test_sycl_queue.py index b35c18d50d2..00c8b70c305 100644 --- a/tests/test_sycl_queue.py +++ b/tests/test_sycl_queue.py @@ -422,6 +422,7 @@ def test_meshgrid(device): pytest.param("exp2", [0.0, 1.0, 2.0]), pytest.param("expm1", [1.0e-10, 1.0, 2.0, 4.0, 7.0]), pytest.param("fabs", [-1.2, 1.2]), + pytest.param("fix", [2.1, 2.9, -2.1, -2.9]), pytest.param("flatnonzero", [-2, -1, 0, 1, 2]), pytest.param("floor", [-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0]), pytest.param("gradient", [1.0, 2.0, 4.0, 7.0, 11.0, 16.0]), diff --git a/tests/test_usm_type.py b/tests/test_usm_type.py index ace6fb35e98..41c77d7a298 100644 --- a/tests/test_usm_type.py +++ b/tests/test_usm_type.py @@ -553,6 +553,7 @@ def test_norm(usm_type, ord, axis): pytest.param("exp2", [0.0, 1.0, 2.0]), pytest.param("expm1", [1.0e-10, 1.0, 2.0, 4.0, 7.0]), pytest.param("fabs", [-1.2, 1.2]), + pytest.param("fix", [2.1, 2.9, -2.1, -2.9]), pytest.param("flatnonzero", [-2, -1, 0, 1, 2]), pytest.param("floor", [-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0]), pytest.param("gradient", [1, 2, 4, 7, 11, 16]), From 646c3d77b55a1840371fd10d261a03b7c6161cf2 Mon Sep 17 00:00:00 2001 From: Anton <100830759+antonwolfy@users.noreply.github.com> Date: Sun, 11 Aug 2024 06:47:36 +0200 Subject: [PATCH 3/3] Update dpnp/dpnp_iface_mathematical.py Co-authored-by: vtavana <120411540+vtavana@users.noreply.github.com> --- dpnp/dpnp_iface_mathematical.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpnp/dpnp_iface_mathematical.py b/dpnp/dpnp_iface_mathematical.py index c2ef88fe7f7..541380bdabf 100644 --- a/dpnp/dpnp_iface_mathematical.py +++ b/dpnp/dpnp_iface_mathematical.py @@ -1380,7 +1380,7 @@ def ediff1d(x1, to_end=None, to_begin=None): Parameters ---------- x : {dpnp.ndarray, usm_ndarray} - The array of numbers for which the absolute values are required. + An array of floats to be rounded. out : {None, dpnp.ndarray, usm_ndarray}, optional Output array to populate. Array must have the correct shape and the expected data type.