Skip to content

Commit 6845028

Browse files
committed
Attempt to improve cumulative_logsumexp testing by computing running logsumexp of test array
1 parent 20ee0de commit 6845028

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

dpctl/tests/test_tensor_accumulation.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
from random import randrange
1818

19-
import numpy as np
2019
import pytest
2120
from helper import get_queue_or_skip, skip_if_dtype_not_supported
2221

@@ -379,8 +378,10 @@ def test_logcumsumexp_basic():
379378
x = dpt.ones(100, dtype=dt)
380379
r = dpt.cumulative_logsumexp(x)
381380

382-
x_np = dpt.asnumpy(x)
383-
expected = np.logaddexp.accumulate(x_np, dtype=dt)
384-
381+
sums = []
382+
for i in range(x.size):
383+
r_i = dpt.logsumexp(x[: i + 1], dtype=dt)
384+
sums.append(r_i)
385+
expected = dpt.concat(sums, axis=None)
385386
tol = 32 * dpt.finfo(dt).resolution
386-
assert np.allclose(dpt.asnumpy(r), expected, atol=tol, rtol=tol)
387+
assert dpt.allclose(r, expected, atol=tol, rtol=tol)

0 commit comments

Comments
 (0)