Skip to content
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

update third party tests for newly added integr dtypes (int8, int16, uint8-uint64) #2239

Open
wants to merge 6 commits into
base: fix-test_product-for-new-dtypes
Choose a base branch
from

Conversation

vtavana
Copy link
Collaborator

@vtavana vtavana commented Dec 17, 2024

In this PR, third party tests are update to pass with newly added integer dtypes (int8, int16, uint8, uint16, uint32, uint64).
This PR is in continuation of #2233.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • If this PR is a work in progress, are you filing the PR as a draft?

@vtavana vtavana self-assigned this Dec 17, 2024
Copy link
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/pull/2239/index.html

@vtavana vtavana force-pushed the fix-cupy-tests-for-new-dtypes branch from 30287e0 to 22041d8 Compare December 18, 2024 17:20
@@ -7,7 +7,9 @@
class TestTrigonometric(unittest.TestCase):

@testing.for_all_dtypes(no_complex=True)
@testing.numpy_cupy_allclose(atol=1e-5, type_check=has_support_aspect64())
@testing.numpy_cupy_allclose(
atol=1e-4, rtol=0.001, type_check=has_support_aspect64()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to change tolerance because of cases where input is int8 which results in output dtype of float16. For such a case, running on gpu returns a result that is closer to numpy but running on cpu will generate a result which has a larger difference compared to numpy.

import numpy, dpnp
a_np = numpy.arange(1,7).reshape(2,3).astype(numpy.int8)
numpy.deg2rad(a_np)
# array([[0.01746, 0.0349 , 0.05237],
#       [0.0698 , 0.0873 , 0.10474]], dtype=float16)
       
a_gpu = dpnp.arange(1,7,device="gpu").reshape(2,3).astype(numpy.int8)  
dpnp.deg2rad(a_gpu)     
# array([[0.01746, 0.0349 , 0.05237],
#       [0.0698 , 0.0873 , 0.10474]], dtype=float16)

a_cpu = dpnp.arange(1,7,device="cpu").reshape(2,3).astype(numpy.int8)  
dpnp.deg2rad(a_cpu)     
# array([[0.01744, 0.03488, 0.0523 ],
#      [0.06976, 0.0872 , 0.1046 ]], dtype=float16)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that the same when input dtype is float16?
Is that due to sycl::radians behavior?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, a similar behavior is observed when float16 is used.

It is not specific to deg2rad. It happens for rad2deg as well on public CI.

Even when I run the code locally on Xeon with default tolerance of 1e-05, it happens for

trigonometric functions

============================================================== FAILURES ===============================================================
____________________________________________________ TestTrigonometric.test_arccos ____________________________________________________
dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py:43: in test_arccos
self.check_unary_unit("arccos")
dpnp/tests/third_party/cupy/testing/loops.py:1018: in test_func
impl
(*args, **kw)
dpnp/tests/third_party/cupy/testing/_loops.py:418: in test_func
check_func(cupy_r, numpy_r)
dpnp/tests/third_party/cupy/testing/_loops.py:597: in check_func
_array.assert_allclose(c, n, rtol1, atol1, err_msg, verbose)
dpnp/tests/third_party/cupy/testing/_array.py:25: in assert_allclose
numpy.testing.assert_allclose(
dpnp/tests/testing/array.py:44: in assert_allclose
_assert(assert_allclose_orig, result, expected, *args, **kwargs)
dpnp/tests/testing/array.py:40: in _assert
assert_func(result, expected, *args, **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-05
E
E Mismatched elements: 1 / 4 (25%)
E Max absolute difference among violations: 0.0004883
E Max relative difference among violations: 0.0005264
E ACTUAL: array([1.369 , 1.159 , 0.9277, 0.644 ], dtype=float16)
E DESIRED: array([1.369 , 1.159 , 0.9272, 0.644 ], dtype=float16)
____________________________________________________ TestTrigonometric.test_arcsin ____________________________________________________
dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py:40: in test_arcsin
self.check_unary_unit("arcsin")
dpnp/tests/third_party/cupy/testing/loops.py:1018: in test_func
impl
(*args, **kw)
dpnp/tests/third_party/cupy/testing/_loops.py:418: in test_func
check_func(cupy_r, numpy_r)
dpnp/tests/third_party/cupy/testing/_loops.py:597: in check_func
_array.assert_allclose(c, n, rtol1, atol1, err_msg, verbose)
dpnp/tests/third_party/cupy/testing/_array.py:25: in assert_allclose
numpy.testing.assert_allclose(
dpnp/tests/testing/array.py:44: in assert_allclose
_assert(assert_allclose_orig, result, expected, *args, **kwargs)
dpnp/tests/testing/array.py:40: in _assert
assert_func(result, expected, *args, **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-05
E
E Mismatched elements: 3 / 4 (75%)
E Max absolute difference among violations: 0.000977
E Max relative difference among violations: 0.001517
E ACTUAL: array([0.2013, 0.4111, 0.6426, 0.9263], dtype=float16)
E DESIRED: array([0.2013, 0.4114, 0.6436, 0.927 ], dtype=float16)
____________________________________________________ TestTrigonometric.test_arctan ____________________________________________________
dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py:46: in test_arctan
self.check_unary("arctan")
dpnp/tests/third_party/cupy/testing/loops.py:1018: in test_func
impl
(*args, **kw)
dpnp/tests/third_party/cupy/testing/_loops.py:418: in test_func
check_func(cupy_r, numpy_r)
dpnp/tests/third_party/cupy/testing/_loops.py:597: in check_func
_array.assert_allclose(c, n, rtol1, atol1, err_msg, verbose)
dpnp/tests/third_party/cupy/testing/_array.py:25: in assert_allclose
numpy.testing.assert_allclose(
dpnp/tests/testing/array.py:44: in assert_allclose
_assert(assert_allclose_orig, result, expected, *args, **kwargs)
dpnp/tests/testing/array.py:40: in _assert
assert_func(result, expected, *args, **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-05
E
E Mismatched elements: 3 / 6 (50%)
E Max absolute difference among violations: 0.000977
E Max relative difference among violations: 0.0008817
E ACTUAL: array([[0.7856, 1.106 , 1.249 ],
E [1.325 , 1.373 , 1.405 ]], dtype=float16)
E DESIRED: array([[0.785, 1.107, 1.249],
E [1.326, 1.373, 1.405]], dtype=float16)
___________________________________________________ TestTrigonometric.test_arctan2 ____________________________________________________
dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py:49: in test_arctan2
self.check_binary("arctan2")
dpnp/tests/third_party/cupy/testing/loops.py:1018: in test_func
impl
(*args, **kw)
dpnp/tests/third_party/cupy/testing/_loops.py:418: in test_func
check_func(cupy_r, numpy_r)
dpnp/tests/third_party/cupy/testing/_loops.py:597: in check_func
_array.assert_allclose(c, n, rtol1, atol1, err_msg, verbose)
dpnp/tests/third_party/cupy/testing/_array.py:25: in assert_allclose
numpy.testing.assert_allclose(
dpnp/tests/testing/array.py:44: in assert_allclose
_assert(assert_allclose_orig, result, expected, *args, **kwargs)
dpnp/tests/testing/array.py:40: in _assert
assert_func(result, expected, *args, **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-05
E
E Mismatched elements: 3 / 6 (50%)
E Max absolute difference among violations: 0.000977
E Max relative difference among violations: 0.00082
E ACTUAL: array([[0.1652, 0.3804, 0.6436],
E [0.927 , 1.189 , 1.405 ]], dtype=float16)
E DESIRED: array([[0.1652, 0.3806, 0.6436],
E [0.9272, 1.19 , 1.405 ]], dtype=float16)
_____________________________________________________ TestTrigonometric.test_cos ______________________________________________________
dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py:34: in test_cos
self.check_unary("cos")
dpnp/tests/third_party/cupy/testing/loops.py:1018: in test_func
impl
(*args, **kw)
dpnp/tests/third_party/cupy/testing/_loops.py:418: in test_func
check_func(cupy_r, numpy_r)
dpnp/tests/third_party/cupy/testing/_loops.py:597: in check_func
_array.assert_allclose(c, n, rtol1, atol1, err_msg, verbose)
dpnp/tests/third_party/cupy/testing/_array.py:25: in assert_allclose
numpy.testing.assert_allclose(
dpnp/tests/testing/array.py:44: in assert_allclose
_assert(assert_allclose_orig, result, expected, *args, **kwargs)
dpnp/tests/testing/array.py:40: in _assert
assert_func(result, expected, *args, **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-05
E
E Mismatched elements: 2 / 6 (33.3%)
E Max absolute difference among violations: 0.0004883
E Max relative difference among violations: 0.000509
E ACTUAL: array([[ 0.5405, -0.4163, -0.9897],
E [-0.654 , 0.2837, 0.9604]], dtype=float16)
E DESIRED: array([[ 0.5405, -0.4163, -0.99 ],
E [-0.654 , 0.2837, 0.96 ]], dtype=float16)
___________________________________________________ TestTrigonometric.test_deg2rad ____________________________________________________
dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py:55: in test_deg2rad
self.check_unary("deg2rad")
dpnp/tests/third_party/cupy/testing/loops.py:1018: in test_func
impl
(*args, **kw)
dpnp/tests/third_party/cupy/testing/_loops.py:418: in test_func
check_func(cupy_r, numpy_r)
dpnp/tests/third_party/cupy/testing/_loops.py:597: in check_func
_array.assert_allclose(c, n, rtol1, atol1, err_msg, verbose)
dpnp/tests/third_party/cupy/testing/_array.py:25: in assert_allclose
numpy.testing.assert_allclose(
dpnp/tests/testing/array.py:44: in assert_allclose
_assert(assert_allclose_orig, result, expected, *args, **kwargs)
dpnp/tests/testing/array.py:40: in _assert
assert_func(result, expected, *args, **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-05
E
E Mismatched elements: 6 / 6 (100%)
E Max absolute difference among violations: 0.0001221
E Max relative difference among violations: 0.001165
E ACTUAL: array([[0.01744, 0.03488, 0.0523 ],
E [0.06976, 0.0872 , 0.1046 ]], dtype=float16)
E DESIRED: array([[0.01746, 0.0349 , 0.05237],
E [0.0698 , 0.0873 , 0.10474]], dtype=float16)
___________________________________________________ TestTrigonometric.test_rad2deg ____________________________________________________
dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py:58: in test_rad2deg
self.check_unary("rad2deg")
dpnp/tests/third_party/cupy/testing/loops.py:1018: in test_func
impl
(*args, **kw)
dpnp/tests/third_party/cupy/testing/_loops.py:418: in test_func
check_func(cupy_r, numpy_r)
dpnp/tests/third_party/cupy/testing/_loops.py:597: in check_func
_array.assert_allclose(c, n, rtol1, atol1, err_msg, verbose)
dpnp/tests/third_party/cupy/testing/_array.py:25: in assert_allclose
numpy.testing.assert_allclose(
dpnp/tests/testing/array.py:44: in assert_allclose
_assert(assert_allclose_orig, result, expected, *args, **kwargs)
dpnp/tests/testing/array.py:40: in _assert
assert_func(result, expected, *args, **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-05
E
E Mismatched elements: 5 / 6 (83.3%)
E Max absolute difference among violations: 0.25
E Max relative difference among violations: 0.000727
E ACTUAL: array([[ 57.3, 114.6, 172. ],
E [229.2, 286.5, 344. ]], dtype=float16)
E DESIRED: array([[ 57.28, 114.56, 171.9 ],
E [229.1 , 286.5 , 343.8 ]], dtype=float16)
_____________________________________________________ TestTrigonometric.test_sin ______________________________________________________
dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py:31: in test_sin
self.check_unary("sin")
dpnp/tests/third_party/cupy/testing/loops.py:1018: in test_func
impl
(*args, **kw)
dpnp/tests/third_party/cupy/testing/_loops.py:418: in test_func
check_func(cupy_r, numpy_r)
dpnp/tests/third_party/cupy/testing/_loops.py:597: in check_func
_array.assert_allclose(c, n, rtol1, atol1, err_msg, verbose)
dpnp/tests/third_party/cupy/testing/_array.py:25: in assert_allclose
numpy.testing.assert_allclose(
dpnp/tests/testing/array.py:44: in assert_allclose
_assert(assert_allclose_orig, result, expected, *args, **kwargs)
dpnp/tests/testing/array.py:40: in _assert
assert_func(result, expected, *args, **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-05
E
E Mismatched elements: 3 / 6 (50%)
E Max absolute difference among violations: 0.0004883
E Max relative difference among violations: 0.000874
E ACTUAL: array([[ 0.8413, 0.9087, 0.1411],
E [-0.757 , -0.9585, -0.2795]], dtype=float16)
E DESIRED: array([[ 0.8413, 0.909 , 0.1411],
E [-0.757 , -0.959 , -0.2793]], dtype=float16)
_____________________________________________________ TestTrigonometric.test_tan ______________________________________________________
dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py:37: in test_tan
self.check_unary("tan")
dpnp/tests/third_party/cupy/testing/loops.py:1018: in test_func
impl
(*args, **kw)
dpnp/tests/third_party/cupy/testing/_loops.py:418: in test_func
check_func(cupy_r, numpy_r)
dpnp/tests/third_party/cupy/testing/_loops.py:597: in check_func
_array.assert_allclose(c, n, rtol1, atol1, err_msg, verbose)
dpnp/tests/third_party/cupy/testing/_array.py:25: in assert_allclose
numpy.testing.assert_allclose(
dpnp/tests/testing/array.py:44: in assert_allclose
_assert(assert_allclose_orig, result, expected, *args, **kwargs)
dpnp/tests/testing/array.py:40: in _assert
assert_func(result, expected, *args, **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-05
E
E Mismatched elements: 2 / 6 (33.3%)
E Max absolute difference among violations: 0.001953
E Max relative difference among violations: 0.0008936
E ACTUAL: array([[ 1.558 , -2.184 , -0.1426],
E [ 1.158 , -3.379 , -0.291 ]], dtype=float16)
E DESIRED: array([[ 1.558 , -2.186 , -0.1426],
E [ 1.158 , -3.38 , -0.291 ]], dtype=float16)
======================================================= short test summary info =======================================================
FAILED dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py::TestTrigonometric::test_arccos - AssertionError:
FAILED dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py::TestTrigonometric::test_arcsin - AssertionError:
FAILED dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py::TestTrigonometric::test_arctan - AssertionError:
FAILED dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py::TestTrigonometric::test_arctan2 - AssertionError:
FAILED dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py::TestTrigonometric::test_cos - AssertionError:
FAILED dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py::TestTrigonometric::test_deg2rad - AssertionError:
FAILED dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py::TestTrigonometric::test_rad2deg - AssertionError:
FAILED dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py::TestTrigonometric::test_sin - AssertionError:
FAILED dpnp/tests/third_party/cupy/math_tests/test_trigonometric.py::TestTrigonometric::test_tan - AssertionError:

hyperbolic functions

============================================================= FAILURES ===============================================================
_____________________________________________________ TestHyperbolic.test_arccosh _____________________________________________________
dpnp/tests/third_party/cupy/testing/loops.py:1018: in test_func
impl
(*args, **kw)
dpnp/tests/third_party/cupy/testing/_loops.py:418: in test_func
check_func(cupy_r, numpy_r)
dpnp/tests/third_party/cupy/testing/_loops.py:597: in check_func
_array.assert_allclose(c, n, rtol1, atol1, err_msg, verbose)
dpnp/tests/third_party/cupy/testing/_array.py:25: in assert_allclose
numpy.testing.assert_allclose(
dpnp/tests/testing/array.py:44: in assert_allclose
_assert(assert_allclose_orig, result, expected, *args, **kwargs)
dpnp/tests/testing/array.py:40: in _assert
assert_func(result, expected, *args, **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-05
E
E Mismatched elements: 2 / 3 (66.7%)
E Max absolute difference among violations: 0.000977
E Max relative difference among violations: 0.0007415
E ACTUAL: array([0. , 1.318, 1.764], dtype=float16)
E DESIRED: array([0. , 1.317, 1.763], dtype=float16)
_____________________________________________________ TestHyperbolic.test_arcsinh _____________________________________________________
dpnp/tests/third_party/cupy/math_tests/test_hyperbolic.py:31: in test_arcsinh
self.check_unary("arcsinh")
dpnp/tests/third_party/cupy/testing/loops.py:1018: in test_func
impl
(*args, **kw)
dpnp/tests/third_party/cupy/testing/_loops.py:418: in test_func
check_func(cupy_r, numpy_r)
dpnp/tests/third_party/cupy/testing/_loops.py:597: in check_func
_array.assert_allclose(c, n, rtol1, atol1, err_msg, verbose)
dpnp/tests/third_party/cupy/testing/_array.py:25: in assert_allclose
numpy.testing.assert_allclose(
dpnp/tests/testing/array.py:44: in assert_allclose
_assert(assert_allclose_orig, result, expected, *args, **kwargs)
dpnp/tests/testing/array.py:40: in _assert
assert_func(result, expected, *args, **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-05
E
E Mismatched elements: 2 / 6 (33.3%)
E Max absolute difference among violations: 0.001953
E Max relative difference among violations: 0.0009327
E ACTUAL: array([[0.8813, 1.443 , 1.819 ],
E [2.096 , 2.312 , 2.492 ]], dtype=float16)
E DESIRED: array([[0.8813, 1.443 , 1.818 ],
E [2.094 , 2.312 , 2.492 ]], dtype=float16)
_____________________________________________________ TestHyperbolic.test_arctanh _____________________________________________________
dpnp/tests/third_party/cupy/math_tests/test_hyperbolic.py:40: in test_arctanh
self.check_unary_unit("arctanh")
dpnp/tests/third_party/cupy/testing/loops.py:1018: in test_func
impl
(*args, **kw)
dpnp/tests/third_party/cupy/testing/_loops.py:418: in test_func
check_func(cupy_r, numpy_r)
dpnp/tests/third_party/cupy/testing/_loops.py:597: in check_func
_array.assert_allclose(c, n, rtol1, atol1, err_msg, verbose)
dpnp/tests/third_party/cupy/testing/_array.py:25: in assert_allclose
numpy.testing.assert_allclose(
dpnp/tests/testing/array.py:44: in assert_allclose
_assert(assert_allclose_orig, result, expected, *args, **kwargs)
dpnp/tests/testing/array.py:40: in _assert
assert_func(result, expected, *args, **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-05
E
E Mismatched elements: 1 / 4 (25%)
E Max absolute difference among violations: 0.000977
E Max relative difference among violations: 0.00089
E ACTUAL: array([0.2026, 0.4236, 0.6934, 1.099 ], dtype=float16)
E DESIRED: array([0.2026, 0.4236, 0.6934, 1.098 ], dtype=float16)
______________________________________________________ TestHyperbolic.test_cosh _______________________________________________________
dpnp/tests/third_party/cupy/math_tests/test_hyperbolic.py:25: in test_cosh
self.check_unary("cosh")
dpnp/tests/third_party/cupy/testing/loops.py:1018: in test_func
impl
(*args, **kw)
dpnp/tests/third_party/cupy/testing/_loops.py:418: in test_func
check_func(cupy_r, numpy_r)
dpnp/tests/third_party/cupy/testing/_loops.py:597: in check_func
_array.assert_allclose(c, n, rtol1, atol1, err_msg, verbose)
dpnp/tests/third_party/cupy/testing/_array.py:25: in assert_allclose
numpy.testing.assert_allclose(
dpnp/tests/testing/array.py:44: in assert_allclose
_assert(assert_allclose_orig, result, expected, *args, **kwargs)
dpnp/tests/testing/array.py:40: in _assert
assert_func(result, expected, *args, **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-05
E
E Mismatched elements: 1 / 6 (16.7%)
E Max absolute difference among violations: 0.001953
E Max relative difference among violations: 0.0005193
E ACTUAL: array([[ 1.543, 3.764, 10.07 ],
E [ 27.31 , 74.2 , 201.8 ]], dtype=float16)
E DESIRED: array([[ 1.543, 3.762, 10.07 ],
E [ 27.31 , 74.2 , 201.8 ]], dtype=float16)
______________________________________________________ TestHyperbolic.test_sinh _______________________________________________________
dpnp/tests/third_party/cupy/math_tests/test_hyperbolic.py:22: in test_sinh
self.check_unary("sinh")
dpnp/tests/third_party/cupy/testing/loops.py:1018: in test_func
impl
(*args, **kw)
dpnp/tests/third_party/cupy/testing/_loops.py:418: in test_func
check_func(cupy_r, numpy_r)
dpnp/tests/third_party/cupy/testing/_loops.py:597: in check_func
_array.assert_allclose(c, n, rtol1, atol1, err_msg, verbose)
dpnp/tests/third_party/cupy/testing/_array.py:25: in assert_allclose
numpy.testing.assert_allclose(
dpnp/tests/testing/array.py:44: in assert_allclose
_assert(assert_allclose_orig, result, expected, *args, **kwargs)
dpnp/tests/testing/array.py:40: in _assert
assert_func(result, expected, *args, **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-05
E
E Mismatched elements: 2 / 6 (33.3%)
E Max absolute difference among violations: 0.01563
E Max relative difference among violations: 0.000831
E ACTUAL: array([[ 1.176, 3.627, 10.016],
E [ 27.28 , 74.2 , 201.8 ]], dtype=float16)
E DESIRED: array([[ 1.175, 3.627, 10.016],
E [ 27.3 , 74.2 , 201.8 ]], dtype=float16)
______________________________________________________ TestHyperbolic.test_tanh _______________________________________________________
dpnp/tests/third_party/cupy/math_tests/test_hyperbolic.py:28: in test_tanh
self.check_unary("tanh")
dpnp/tests/third_party/cupy/testing/loops.py:1018: in test_func
impl
(*args, **kw)
dpnp/tests/third_party/cupy/testing/_loops.py:418: in test_func
check_func(cupy_r, numpy_r)
dpnp/tests/third_party/cupy/testing/_loops.py:597: in check_func
_array.assert_allclose(c, n, rtol1, atol1, err_msg, verbose)
dpnp/tests/third_party/cupy/testing/_array.py:25: in assert_allclose
numpy.testing.assert_allclose(
dpnp/tests/testing/array.py:44: in assert_allclose
_assert(assert_allclose_orig, result, expected, *args, **kwargs)
dpnp/tests/testing/array.py:40: in _assert
assert_func(result, expected, *args, **kwargs)
E AssertionError:
E Not equal to tolerance rtol=1e-07, atol=1e-05
E
E Mismatched elements: 4 / 6 (66.7%)
E Max absolute difference among violations: 0.001465
E Max relative difference among violations: 0.001465
E ACTUAL: array([[0.7617, 0.964 , 0.9946],
E [0.9985, 0.9985, 0.9985]], dtype=float16)
E DESIRED: array([[0.7617, 0.964 , 0.995 ],
E [0.9995, 1. , 1. ]], dtype=float16)
======================================================= short test summary info =======================================================
FAILED dpnp/tests/third_party/cupy/math_tests/test_hyperbolic.py::TestHyperbolic::test_arccosh - AssertionError:
FAILED dpnp/tests/third_party/cupy/math_tests/test_hyperbolic.py::TestHyperbolic::test_arcsinh - AssertionError:
FAILED dpnp/tests/third_party/cupy/math_tests/test_hyperbolic.py::TestHyperbolic::test_arctanh - AssertionError:
FAILED dpnp/tests/third_party/cupy/math_tests/test_hyperbolic.py::TestHyperbolic::test_cosh - AssertionError:
FAILED dpnp/tests/third_party/cupy/math_tests/test_hyperbolic.py::TestHyperbolic::test_sinh - AssertionError:
FAILED dpnp/tests/third_party/cupy/math_tests/test_hyperbolic.py::TestHyperbolic::test_tanh - AssertionError:

@@ -338,7 +338,7 @@ def test_astype_type(self, src_dtype, dst_dtype, order):
b = astype_without_warning(a, dst_dtype, order=order)
a_cpu = testing.shaped_arange((2, 3, 4), numpy, src_dtype)
b_cpu = astype_without_warning(a_cpu, dst_dtype, order=order)
assert b.dtype.type == b_cpu.dtype.type
assert b.dtype == b_cpu.dtype
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed it to only compare dtype because of such cases:

import numpy, dpnp
w=numpy.longlong(3)
a=numpy.ones(10, dtype=numpy.int32)
a.astype(type(w)).dtype
# dtype('int64')
a.astype(type(numpy.longlong(3))).dtype.type
# numpy.longlong

w=dpnp.longlong(3)
a=dpnp.ones(10, dtype=dpnp.int32)
a.astype(type(w)).dtype
# dtype('int64')
a.astype(type(w)).dtype.type
# numpy.int64

This is probably because dpctl.tensor does not have dpt.longlong.

@vtavana vtavana marked this pull request as ready for review December 19, 2024 15:11
@@ -594,7 +594,10 @@ def __call__(self, x, decimals=0, out=None, dtype=None):
dtype = x_usm.dtype

out_usm = None if out is None else dpnp.get_usm_ndarray(out)
x_usm = dpt.round(x_usm * 10**decimals, out=out_usm)
# the output of x_usm multiplied by 10^decimals should be
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the limitation input decimals? As I can see, NumPy supports it as single integer or 0d array convertible to index scalar. Have we check that also?
Will that impact the propose changes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works with 0d arrays as well.

import numpy, dpnp
a = numpy.array([12, 13], dtype=numpy.int8)
numpy.round(a, decimals=1)
# array([12, 13], dtype=int8)

b = dpnp.array(a)
dpnp.round(b, decimals=1)
# array([12, 13], dtype=int8)

b = dpnp.array(a)
dpnp.round(b, decimals=dpnp.array(1))
# array([12, 13], dtype=int8)

Also added new tests to test_sycl_queue.py and test_usm_type.py.

dtype_b,
dtype_a,
) in self.skip_dtypes:
pytest.skip("avoid overflow")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't numpy has such kind of issue and it works for it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this case or other similar cases that I have skipped, numpy or dpnp do not raise OverflowError. In fact, the test fails because the results are different. And the reason for difference, is that the output is out of bound for the dtype being used which is an undefined behavior. See a similar discussion in IntelPython/dpctl#1540.

For instance

import numpy, dpnp

a = numpy.array([[60, 60], [65, 65]], dtype=numpy.int8)
b = numpy.array([1, 1], dtype=numpy.int8)
numpy.dot(a, b)
# array([ 120, -126], dtype=int8)

a_gpu = dpnp.array([[60, 60], [65, 65]], dtype=numpy.int8, device="gpu")
b_gpu = dpnp.array([1, 1], dtype=numpy.int8, device="gpu")
dpnp.dot(a_gpu, b_gpu)
# array([ 120, -126], dtype=int8)

a_cpu = dpnp.array([[60, 60], [65, 65]], dtype=numpy.int8, device="cpu")
b_cpu = dpnp.array([1, 1], dtype=numpy.int8, device="cpu")
dpnp.dot(a_cpu, b_cpu)
# array([120, 127], dtype=int8)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the cases relate to int8 and uint8. Probably it would be better to add new keyword no_int8 to for_all_dtypes to cover that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants