Skip to content

Commit

Permalink
Changed closed-form test to be strict except on non-Intel CPUs
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandr-pavlyk committed Mar 31, 2024
1 parent 89d6850 commit b1219af
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions dpctl/tests/test_tensor_accumulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from helper import get_queue_or_skip, skip_if_dtype_not_supported

import dpctl.tensor as dpt
from dpctl.utils import ExecutionPlacementError
from dpctl.utils import ExecutionPlacementError, intel_device_info

sint_types = [
dpt.int8,
Expand Down Expand Up @@ -408,11 +408,18 @@ def test_cumulative_logsumexp_closed_form(fpdt):
r = dpt.cumulative_logsumexp(dpt.arange(-n, 0, dtype=fpdt, device=q))
expected = geometric_series_closed_form(n, dtype=fpdt, device=q)

tol = 32 * dpt.finfo(fpdt).eps
atol = tol
rtol = 8 * tol
if not dpt.allclose(r, expected, atol=atol, rtol=rtol):
tol = 4 * dpt.finfo(fpdt).eps

idi = intel_device_info(r.sycl_device)
if not r.sycl_device.has_aspect_cpu or ("device_id" in idi):
assert dpt.allclose(r, expected, atol=tol, rtol=tol)
else:
# on AMD CPUs (in CI) some failures are present
# to be investigated
tol = 2 * tol
atol = tol
rtol = 4 * tol

ad = dpt.abs(r - expected)
viols = ad > atol + rtol * dpt.maximum(dpt.abs(r), dpt.abs(expected))
viols_count = dpt.sum(viols)
Expand Down

0 comments on commit b1219af

Please sign in to comment.