-
Notifications
You must be signed in to change notification settings - Fork 22
Reuse dpctl.tensor.floor_divide() function. #1427
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
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ | |
from .dpnp_algo.dpnp_elementwise_common import ( | ||
dpnp_add, | ||
dpnp_divide, | ||
dpnp_floor_divide, | ||
dpnp_multiply, | ||
dpnp_subtract | ||
) | ||
|
@@ -737,7 +738,7 @@ 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. | ||
|
||
|
@@ -746,7 +747,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`. | ||
npolina4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
@@ -767,42 +768,7 @@ def floor_divide(x1, x2, dtype=None, out=None, where=True, **kwargs): | |
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please update an example, since the output has different format now |
||
""" | ||
|
||
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) | ||
|
||
|
||
def fmax(*args, **kwargs): | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,9 +147,10 @@ def test_divide(self, dtype, lhs, rhs): | |
def test_fmod(self, dtype, lhs, rhs): | ||
self._test_mathematical('fmod', dtype, lhs, rhs) | ||
|
||
@pytest.mark.usefixtures("allow_fall_back_on_numpy") | ||
@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) | ||
@pytest.mark.parametrize("dtype", get_all_dtypes(no_complex=True)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we unmute tests from tests/third_party/cupy/math_tests/test_arithmetic.py ? |
||
def test_floor_divide(self, dtype, lhs, rhs): | ||
antonwolfy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if dtype == dpnp.float32 and rhs == 0.3: | ||
pytest.skip("In this case, a different result, but similar to xp.floor(xp.divide(lhs, rhs).") | ||
self._test_mathematical('floor_divide', dtype, lhs, rhs) | ||
|
||
@pytest.mark.usefixtures("allow_fall_back_on_numpy") | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.