Skip to content
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
4 changes: 3 additions & 1 deletion dpctl/tensor/libtensor/source/sum_reductions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ std::pair<sycl::event, sycl::event> py_sum_over_axis(
return std::make_pair(keep_args_event, sum_over_axis_contig_ev);
}
}
else if (is_src_f_contig & is_dst_c_contig) {
else if (is_src_f_contig &&
((is_dst_c_contig && dst_nd == 1) || dst.is_f_contiguous()))
{
auto fn = sum_over_axis0_contig_atomic_dispatch_table[src_typeid]
[dst_typeid];
if (fn != nullptr) {
Expand Down
15 changes: 15 additions & 0 deletions dpctl/tests/test_tensor_sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,18 @@ def test_largish_reduction(arg_dtype, n):

assert dpt.all(dpt.equal(y1, y2))
assert dpt.all(dpt.equal(y1, n * m))


def test_axis0_bug():
"gh-1391"
get_queue_or_skip()

sh = (1, 2, 3)
a = dpt.arange(sh[0] * sh[1] * sh[2], dtype="i4")
a = dpt.reshape(a, sh)
aT = dpt.permute_dims(a, (2, 1, 0))

s = dpt.sum(aT, axis=2)
expected = dpt.asarray([[0, 3], [1, 4], [2, 5]])

assert dpt.all(s == expected)