diff --git a/dpnp/dpnp_iface_mathematical.py b/dpnp/dpnp_iface_mathematical.py index 6f636c061bbc..822772768246 100644 --- a/dpnp/dpnp_iface_mathematical.py +++ b/dpnp/dpnp_iface_mathematical.py @@ -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 diff --git a/tests/test_mathematical.py b/tests/test_mathematical.py index 336aace0388e..46dbab5c30a1 100644 --- a/tests/test_mathematical.py +++ b/tests/test_mathematical.py @@ -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: