Skip to content

Commit 747ef6c

Browse files
Fix gh-1539 (#1563)
* Fix gh-1539 * Update dpnp.sum function * Added tests for dpnp.sum function --------- Co-authored-by: Vladislav Perevezentsev <[email protected]>
1 parent 329f36e commit 747ef6c

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

dpnp/dpnp_iface_mathematical.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -2485,9 +2485,23 @@ def sum(
24852485
elif where is not True:
24862486
pass
24872487
else:
2488-
if len(x.shape) == 2 and (
2489-
(axis == (0,) and x.flags.c_contiguous)
2490-
or (axis == (1,) and x.flags.f_contiguous)
2488+
if (
2489+
len(x.shape) == 2
2490+
and x.itemsize == 4
2491+
and (
2492+
(
2493+
axis == (0,)
2494+
and x.flags.c_contiguous
2495+
and 32 <= x.shape[1] <= 1024
2496+
and x.shape[0] > x.shape[1]
2497+
)
2498+
or (
2499+
axis == (1,)
2500+
and x.flags.f_contiguous
2501+
and 32 <= x.shape[0] <= 1024
2502+
and x.shape[1] > x.shape[0]
2503+
)
2504+
)
24912505
):
24922506
from dpctl.tensor._reduction import _default_reduction_dtype
24932507

tests/test_mathematical.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1220,15 +1220,18 @@ def test_sum_empty_out(dtype):
12201220
(0, 6),
12211221
(10, 1),
12221222
(1, 10),
1223+
(35, 40),
1224+
(40, 35),
12231225
],
12241226
)
12251227
@pytest.mark.parametrize("dtype_in", get_all_dtypes())
12261228
@pytest.mark.parametrize("dtype_out", get_all_dtypes())
12271229
@pytest.mark.parametrize("transpose", [True, False])
12281230
@pytest.mark.parametrize("keepdims", [True, False])
1229-
def test_sum(shape, dtype_in, dtype_out, transpose, keepdims):
1231+
@pytest.mark.parametrize("order", ["C", "F"])
1232+
def test_sum(shape, dtype_in, dtype_out, transpose, keepdims, order):
12301233
size = numpy.prod(shape)
1231-
a_np = numpy.arange(size).astype(dtype_in).reshape(shape)
1234+
a_np = numpy.arange(size).astype(dtype_in).reshape(shape, order=order)
12321235
a = dpnp.asarray(a_np)
12331236

12341237
if transpose:

0 commit comments

Comments
 (0)