Skip to content

Fix gh-1539 #1563

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

Merged
merged 4 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions dpnp/dpnp_iface_mathematical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2485,9 +2485,23 @@ def sum(
elif where is not True:
pass
else:
if len(x.shape) == 2 and (
(axis == (0,) and x.flags.c_contiguous)
or (axis == (1,) and x.flags.f_contiguous)
if (
len(x.shape) == 2
and x.itemsize == 4
and (
(
axis == (0,)
and x.flags.c_contiguous
and 32 <= x.shape[1] <= 1024
and x.shape[0] > x.shape[1]
)
or (
axis == (1,)
and x.flags.f_contiguous
and 32 <= x.shape[0] <= 1024
and x.shape[1] > x.shape[0]
)
)
):
from dpctl.tensor._reduction import _default_reduction_dtype

Expand Down
7 changes: 5 additions & 2 deletions tests/test_mathematical.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,15 +1220,18 @@ def test_sum_empty_out(dtype):
(0, 6),
(10, 1),
(1, 10),
(35, 40),
(40, 35),
],
)
@pytest.mark.parametrize("dtype_in", get_all_dtypes())
@pytest.mark.parametrize("dtype_out", get_all_dtypes())
@pytest.mark.parametrize("transpose", [True, False])
@pytest.mark.parametrize("keepdims", [True, False])
def test_sum(shape, dtype_in, dtype_out, transpose, keepdims):
@pytest.mark.parametrize("order", ["C", "F"])
def test_sum(shape, dtype_in, dtype_out, transpose, keepdims, order):
size = numpy.prod(shape)
a_np = numpy.arange(size).astype(dtype_in).reshape(shape)
a_np = numpy.arange(size).astype(dtype_in).reshape(shape, order=order)
a = dpnp.asarray(a_np)

if transpose:
Expand Down