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

Implement support CFD for dpnp.isclose and dpnp.allclose functions #1937

Merged
merged 11 commits into from
Jul 26, 2024
6 changes: 3 additions & 3 deletions dpnp/dpnp_iface_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,17 +640,17 @@ def isclose(a, b, rtol=1e-05, atol=1e-08, equal_nan=False):

# make sure b is an inexact type to avoid bad behavior on abs(MIN_INT)
if dpnp.isscalar(b):
npolina4 marked this conversation as resolved.
Show resolved Hide resolved
dt = dpnp.result_type(a, b, 1.0)
dt = dpnp.result_type(a, b, 1.0, rtol, atol)
b = dpnp.asarray(
npolina4 marked this conversation as resolved.
Show resolved Hide resolved
b, dtype=dt, sycl_queue=a.sycl_queue, usm_type=a.usm_type
)
elif dpnp.issubdtype(b, dpnp.integer):
dt = dpnp.result_type(b, 1.0)
dt = dpnp.result_type(b, 1.0, rtol, atol)
b = dpnp.astype(b, dtype=dt)

# Firstly handle finite values:
# result = absolute(a - b) <= atol + rtol * absolute(b)
_b = dpnp.abs(b)
_b = dpnp.abs(b).astype(dpnp.result_type(b, rtol, atol), copy=False)
npolina4 marked this conversation as resolved.
Show resolved Hide resolved
_b *= rtol
_b += atol
result = less_equal(dpnp.abs(a - b), _b)
Expand Down
Loading