Skip to content

Commit 45ce08b

Browse files
Merge pull request #1838 from IntelPython/py-sorting-correction
Throw exception in py_sort if inputs are not C-contiguous
2 parents 8c47c65 + 85d5cb9 commit 45ce08b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

dpctl/tensor/libtensor/source/sorting/argsort.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ py_argsort(const dpctl::tensor::usm_ndarray &src,
125125
"Output index array must have data type int32 or int64");
126126
}
127127

128-
// handle special case when both reduction and iteration are 1D contiguous
129128
bool is_src_c_contig = src.is_c_contiguous();
130129
bool is_dst_c_contig = dst.is_c_contiguous();
131130

@@ -150,7 +149,8 @@ py_argsort(const dpctl::tensor::usm_ndarray &src,
150149
return std::make_pair(keep_args_alive_ev, comp_ev);
151150
}
152151

153-
return std::make_pair(sycl::event(), sycl::event());
152+
throw py::value_error(
153+
"Both source and destination arrays must be C-contiguous");
154154
}
155155

156156
using dpctl::tensor::kernels::sort_contig_fn_ptr_t;

dpctl/tensor/libtensor/source/sorting/sort.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ py_sort(const dpctl::tensor::usm_ndarray &src,
123123
"the same value data type");
124124
}
125125

126-
// handle special case when both reduction and iteration are 1D contiguous
127126
bool is_src_c_contig = src.is_c_contiguous();
128127
bool is_dst_c_contig = dst.is_c_contiguous();
129128

@@ -144,7 +143,8 @@ py_sort(const dpctl::tensor::usm_ndarray &src,
144143
return std::make_pair(keep_args_alive_ev, comp_ev);
145144
}
146145

147-
return std::make_pair(sycl::event(), sycl::event());
146+
throw py::value_error(
147+
"Both source and destination arrays must be C-contiguous");
148148
}
149149

150150
using dpctl::tensor::kernels::sort_contig_fn_ptr_t;

0 commit comments

Comments
 (0)