Skip to content

Commit d947ba8

Browse files
committed
Reduce size of array in test_logcumsumexp_basic
1 parent 6845028 commit d947ba8

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

dpctl/tests/test_tensor_accumulation.py

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

1717
from random import randrange
1818

19+
import numpy as np
1920
import pytest
2021
from helper import get_queue_or_skip, skip_if_dtype_not_supported
2122

@@ -375,13 +376,11 @@ def test_logcumsumexp_basic():
375376
get_queue_or_skip()
376377

377378
dt = dpt.float32
378-
x = dpt.ones(100, dtype=dt)
379+
x = dpt.ones(10, dtype=dt)
379380
r = dpt.cumulative_logsumexp(x)
380381

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)
382+
x_np = dpt.asnumpy(x)
383+
expected = np.logaddexp.accumulate(x_np, dtype=dt)
384+
386385
tol = 32 * dpt.finfo(dt).resolution
387-
assert dpt.allclose(r, expected, atol=tol, rtol=tol)
386+
assert np.allclose(dpt.asnumpy(r), expected, atol=tol, rtol=tol)

0 commit comments

Comments
 (0)