Skip to content

Merge master to gold/2021 #1484

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 25 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a1a9b14
Check dtype support of each array in resulting tuple in call_origin (…
vlad-perevezentsev Jun 29, 2023
07d3a3e
Reuse dpctl.tensor comparison functions. (#1458)
npolina4 Jun 30, 2023
bcecead
Reuse dpctl.tensor.floor_divide() function.
npolina4 Jun 30, 2023
93a0e2a
Update dpnp/dpnp_iface_mathematical.py
npolina4 Jun 30, 2023
0d4ce80
Exclude docker image removal (#1465)
antonwolfy Jul 5, 2023
b240844
Fix to continue parallel uploading in case of error (#1466)
antonwolfy Jul 6, 2023
f49da0e
Improve dpnp.log() implementation (#1469)
antonwolfy Jul 7, 2023
f82cdc4
Improve dpnp.cos() and dpnp.sin() implementations (#1471)
antonwolfy Jul 7, 2023
fd9ce2b
Update dpnp.sqrt using dpctl and OneMKL implementations (#1470)
vlad-perevezentsev Jul 8, 2023
f294dfd
Reuse logical operations from dpctl.tensor (#1464)
antonwolfy Jul 9, 2023
725de87
Improve dpnp.square() implementation
antonwolfy Jul 10, 2023
124303c
Merge branch 'master' into reuse_floor_divide_func
npolina4 Jul 10, 2023
457fb55
Merge pull request #1473 from IntelPython/dpctl_square
npolina4 Jul 10, 2023
9349223
Merge branch 'master' into reuse_floor_divide_func
npolina4 Jul 10, 2023
10a656d
Merge pull request #1462 from IntelPython/reuse_floor_divide_func
npolina4 Jul 11, 2023
cfac723
Add metadata to setup.py (#1460)
DenisScherbakov Jul 13, 2023
771653b
Update test_linalg.py to run on Iris Xe (#1474)
vlad-perevezentsev Jul 13, 2023
326c451
Removed extra copy for transpose arrays in dot() (#1477)
antonwolfy Jul 17, 2023
ed4fa58
Corrected name of OneAPI compiler package (#1478)
antonwolfy Jul 17, 2023
977b597
Required Cython<3 until source code is updated (#1480)
antonwolfy Jul 17, 2023
c4d8719
Add specialized kernel for sum(axis=0) as extension (#1479)
AlexanderKalistratov Jul 18, 2023
4d995f6
Added changelog for 0.12.1 (#1482)
antonwolfy Jul 18, 2023
89f4120
Pinned to dpctl 0.14.5 (#1481)
antonwolfy Jul 18, 2023
af1af29
Updated version to 0.12.1 (#1483)
antonwolfy Jul 18, 2023
321c942
Merge branch 'master' into merge_to_gold
antonwolfy Jul 18, 2023
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
2 changes: 0 additions & 2 deletions dpnp/dpnp_algo/dpnp_algo.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ cdef extern from "dpnp_iface_fptr.hpp" namespace "DPNPFuncName": # need this na
DPNP_FN_FLATTEN_EXT
DPNP_FN_FLOOR
DPNP_FN_FLOOR_EXT
DPNP_FN_FLOOR_DIVIDE
DPNP_FN_FLOOR_DIVIDE_EXT
DPNP_FN_FMOD
DPNP_FN_FMOD_EXT
DPNP_FN_FULL
Expand Down
9 changes: 0 additions & 9 deletions dpnp/dpnp_algo/dpnp_algo_mathematical.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ __all__ += [
"dpnp_ediff1d",
"dpnp_fabs",
"dpnp_floor",
"dpnp_floor_divide",
"dpnp_fmod",
"dpnp_gradient",
'dpnp_hypot',
Expand Down Expand Up @@ -301,14 +300,6 @@ cpdef utils.dpnp_descriptor dpnp_floor(utils.dpnp_descriptor x1, utils.dpnp_desc
return call_fptr_1in_1out_strides(DPNP_FN_FLOOR_EXT, x1, dtype=None, out=out, where=True, func_name='floor')


cpdef utils.dpnp_descriptor dpnp_floor_divide(utils.dpnp_descriptor x1_obj,
utils.dpnp_descriptor x2_obj,
object dtype=None,
utils.dpnp_descriptor out=None,
object where=True):
return call_fptr_2in_1out(DPNP_FN_FLOOR_DIVIDE_EXT, x1_obj, x2_obj, dtype, out, where)


cpdef utils.dpnp_descriptor dpnp_fmod(utils.dpnp_descriptor x1_obj,
utils.dpnp_descriptor x2_obj,
object dtype=None,
Expand Down
43 changes: 43 additions & 0 deletions dpnp/dpnp_algo/dpnp_elementwise_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"dpnp_cos",
"dpnp_divide",
"dpnp_equal",
"dpnp_floor_divide",
"dpnp_greater",
"dpnp_greater_equal",
"dpnp_less",
Expand Down Expand Up @@ -342,6 +343,48 @@ def dpnp_equal(x1, x2, out=None, order="K"):
return dpnp_array._create_from_usm_ndarray(res_usm)


_floor_divide_docstring_ = """
floor_divide(x1, x2, out=None, order="K")
Calculates the ratio for each element `x1_i` of the input array `x1` with
the respective element `x2_i` of the input array `x2` to the greatest
integer-value number that is not greater than the division result.
Args:
x1 (dpnp.ndarray):
First input array, expected to have numeric data type.
x2 (dpnp.ndarray):
Second input array, also expected to have numeric data type.
out ({None, dpnp.ndarray}, optional):
Output array to populate.
Array have the correct shape and the expected data type.
order ("C","F","A","K", None, optional):
Memory layout of the newly output array, if parameter `out` is `None`.
Default: "K".
Returns:
dpnp.ndarray:
an array containing the result of element-wise floor division.
The data type of the returned array is determined by the Type
Promotion Rules
"""


def dpnp_floor_divide(x1, x2, out=None, order="K"):
"""Invokes floor_divide() from dpctl.tensor implementation for floor_divide() function."""

# dpctl.tensor only works with usm_ndarray or scalar
x1_usm_or_scalar = dpnp.get_usm_ndarray_or_scalar(x1)
x2_usm_or_scalar = dpnp.get_usm_ndarray_or_scalar(x2)
out_usm = None if out is None else dpnp.get_usm_ndarray(out)

func = BinaryElementwiseFunc(
"floor_divide",
ti._floor_divide_result_type,
ti._floor_divide,
_floor_divide_docstring_,
)
res_usm = func(x1_usm_or_scalar, x2_usm_or_scalar, out=out_usm, order=order)
return dpnp_array._create_from_usm_ndarray(res_usm)


_greater_docstring_ = """
greater(x1, x2, out=None, order="K")

Expand Down
75 changes: 27 additions & 48 deletions dpnp/dpnp_iface_mathematical.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from .dpnp_algo.dpnp_elementwise_common import (
dpnp_add,
dpnp_divide,
dpnp_floor_divide,
dpnp_multiply,
dpnp_subtract,
)
Expand Down Expand Up @@ -821,7 +822,18 @@ def floor(x1, out=None, **kwargs):
return call_origin(numpy.floor, x1, out=out, **kwargs)


def floor_divide(x1, x2, dtype=None, out=None, where=True, **kwargs):
def floor_divide(
x1,
x2,
/,
out=None,
*,
where=True,
order="K",
dtype=None,
subok=True,
**kwargs,
):
"""
Compute the largest integer smaller or equal to the division of the inputs.

Expand All @@ -830,7 +842,7 @@ def floor_divide(x1, x2, dtype=None, out=None, where=True, **kwargs):
Limitations
-----------
Parameters ``x1`` and ``x2`` are supported as either :obj:`dpnp.ndarray` or scalar.
Parameters ``dtype``, ``out`` and ``where`` are supported with their default values.
Parameters ``where``, ``dtype`` and ``subok`` are supported with their default values.
Keyword arguments ``kwargs`` are currently unsupported.
Otherwise the functions will be executed sequentially on CPU.
Input array data types are limited by supported DPNP :ref:`Data types`.
Expand All @@ -845,55 +857,22 @@ def floor_divide(x1, x2, dtype=None, out=None, where=True, **kwargs):
Examples
--------
>>> import dpnp as np
>>> result = np.floor_divide(np.array([1, -1, -2, -9]), np.array([-2, -2, -2, -2]))
>>> [x for x in result]
[-1, 0, 1, 4]
>>> np.floor_divide(np.array([1, -1, -2, -9]), np.array([-2, -2, -2, -2]))
array([-1, 0, 1, 4])

"""

x1_is_scalar = dpnp.isscalar(x1)
x2_is_scalar = dpnp.isscalar(x2)
x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False)
x2_desc = dpnp.get_dpnp_descriptor(x2, copy_when_nondefault_queue=False)

if x1_desc and x2_desc and not kwargs:
if not x1_desc and not x1_is_scalar:
pass
elif not x2_desc and not x2_is_scalar:
pass
elif x1_is_scalar and x2_is_scalar:
pass
elif x1_desc and x1_desc.ndim == 0:
pass
elif x2_desc and x2_desc.ndim == 0:
pass
elif x2_is_scalar and not x2_desc:
pass
elif x1_desc and x2_desc and x1_desc.size != x2_desc.size:
# TODO: enable broadcasting
pass
elif x1_desc and x2_desc and x1_desc.shape != x2_desc.shape:
pass
elif dtype is not None:
pass
elif out is not None:
pass
elif not where:
pass
elif x1_is_scalar and x2_desc.ndim > 1:
pass
else:
out_desc = (
dpnp.get_dpnp_descriptor(out, copy_when_nondefault_queue=False)
if out is not None
else None
)
return dpnp_floor_divide(
x1_desc, x2_desc, dtype, out_desc, where
).get_pyobj()

return call_origin(
numpy.floor_divide, x1, x2, out=out, where=where, dtype=dtype, **kwargs
return _check_nd_call(
numpy.floor_divide,
dpnp_floor_divide,
x1,
x2,
out=out,
where=where,
order=order,
dtype=dtype,
subok=subok,
**kwargs,
)


Expand Down
7 changes: 0 additions & 7 deletions tests/skipped_tests.tbl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ tests/test_random.py::TestPermutationsTestShuffle::test_shuffle1[lambda x: dpnp.

tests/test_sycl_queue.py::test_1in_1out[opencl:gpu:0-trapz-data19]
tests/test_sycl_queue.py::test_1in_1out[opencl:cpu:0-trapz-data19]
tests/test_sycl_queue.py::test_broadcasting[opencl:gpu:0-floor_divide-data12-data22]
tests/test_sycl_queue.py::test_broadcasting[opencl:gpu:0-remainder-data15-data25]
tests/test_sycl_queue.py::test_broadcasting[opencl:cpu:0-floor_divide-data12-data22]
tests/test_sycl_queue.py::test_broadcasting[opencl:cpu:0-remainder-data15-data25]

tests/third_party/cupy/fft_tests/test_fft.py::TestFft2_param_1_{axes=None, norm=None, s=(1, None), shape=(3, 4)}::test_fft2
Expand Down Expand Up @@ -693,19 +691,15 @@ tests/third_party/cupy/manipulation_tests/test_tiling.py::TestTile_param_2_{reps
tests/third_party/cupy/manipulation_tests/test_tiling.py::TestTile_param_3_{reps=(0, 1)}::test_array_tile
tests/third_party/cupy/manipulation_tests/test_tiling.py::TestTile_param_4_{reps=(2, 3)}::test_array_tile
tests/third_party/cupy/manipulation_tests/test_tiling.py::TestTile_param_5_{reps=(2, 3, 4, 5)}::test_array_tile
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_455_{arg1=array([[1, 2, 3], [4, 5, 6]], dtype=int32), arg2=array([[0, 1, 2], [3, 4, 5]], dtype=int32), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_457_{arg1=array([[1, 2, 3], [4, 5, 6]], dtype=int32), arg2=array([[0, 1, 2], [3, 4, 5]], dtype=int32), dtype=float64, name='fmod', use_dtype=False}::test_binary
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_459_{arg1=array([[1, 2, 3], [4, 5, 6]], dtype=int32), arg2=array([[0, 1, 2], [3, 4, 5]], dtype=int32), dtype=float64, name='remainder', use_dtype=False}::test_binary
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_461_{arg1=array([[1, 2, 3], [4, 5, 6]], dtype=int32), arg2=array([[0, 1, 2], [3, 4, 5]], dtype=int32), dtype=float64, name='mod', use_dtype=False}::test_binary
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_463_{arg1=array([[1, 2, 3], [4, 5, 6]], dtype=int32), arg2=array([[0, 1, 2], [3, 4, 5]]), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_465_{arg1=array([[1, 2, 3], [4, 5, 6]], dtype=int32), arg2=array([[0, 1, 2], [3, 4, 5]]), dtype=float64, name='fmod', use_dtype=False}::test_binary
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_467_{arg1=array([[1, 2, 3], [4, 5, 6]], dtype=int32), arg2=array([[0, 1, 2], [3, 4, 5]]), dtype=float64, name='remainder', use_dtype=False}::test_binary
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_469_{arg1=array([[1, 2, 3], [4, 5, 6]], dtype=int32), arg2=array([[0, 1, 2], [3, 4, 5]]), dtype=float64, name='mod', use_dtype=False}::test_binary
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_535_{arg1=array([[1, 2, 3], [4, 5, 6]]), arg2=array([[0, 1, 2], [3, 4, 5]], dtype=int32), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_537_{arg1=array([[1, 2, 3], [4, 5, 6]]), arg2=array([[0, 1, 2], [3, 4, 5]], dtype=int32), dtype=float64, name='fmod', use_dtype=False}::test_binary
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_539_{arg1=array([[1, 2, 3], [4, 5, 6]]), arg2=array([[0, 1, 2], [3, 4, 5]], dtype=int32), dtype=float64, name='remainder', use_dtype=False}::test_binary
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_541_{arg1=array([[1, 2, 3], [4, 5, 6]]), arg2=array([[0, 1, 2], [3, 4, 5]], dtype=int32), dtype=float64, name='mod', use_dtype=False}::test_binary
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_543_{arg1=array([[1, 2, 3], [4, 5, 6]]), arg2=array([[0, 1, 2], [3, 4, 5]]), dtype=float64, name='floor_divide', use_dtype=False}::test_binary
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_545_{arg1=array([[1, 2, 3], [4, 5, 6]]), arg2=array([[0, 1, 2], [3, 4, 5]]), dtype=float64, name='fmod', use_dtype=False}::test_binary
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_547_{arg1=array([[1, 2, 3], [4, 5, 6]]), arg2=array([[0, 1, 2], [3, 4, 5]]), dtype=float64, name='remainder', use_dtype=False}::test_binary
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticBinary2_param_549_{arg1=array([[1, 2, 3], [4, 5, 6]]), arg2=array([[0, 1, 2], [3, 4, 5]]), dtype=float64, name='mod', use_dtype=False}::test_binary
Expand All @@ -714,7 +708,6 @@ tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticModf::test_m
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticRaisesWithNumpyInput_param_10_{name='remainder', nargs=2}::test_raises_with_numpy_input
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticRaisesWithNumpyInput_param_11_{name='mod', nargs=2}::test_raises_with_numpy_input
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticRaisesWithNumpyInput_param_1_{name='angle', nargs=1}::test_raises_with_numpy_input
tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticRaisesWithNumpyInput_param_8_{name='floor_divide', nargs=2}::test_raises_with_numpy_input

tests/third_party/cupy/math_tests/test_explog.py::TestExplog::test_logaddexp
tests/third_party/cupy/math_tests/test_explog.py::TestExplog::test_logaddexp2
Expand Down
Loading