Skip to content

Throw exception in py_sort if inputs are not C-contiguous #1838

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 2 commits into from
Sep 16, 2024
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: 2 additions & 2 deletions dpctl/tensor/libtensor/source/sorting/argsort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ py_argsort(const dpctl::tensor::usm_ndarray &src,
"Output index array must have data type int32 or int64");
}

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

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

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

using dpctl::tensor::kernels::sort_contig_fn_ptr_t;
Expand Down
4 changes: 2 additions & 2 deletions dpctl/tensor/libtensor/source/sorting/sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ py_sort(const dpctl::tensor::usm_ndarray &src,
"the same value data type");
}

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

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

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

using dpctl::tensor::kernels::sort_contig_fn_ptr_t;
Expand Down
Loading