Skip to content
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

[Contrib] Enable fp16 for thrust sort #16887

Merged
merged 1 commit into from
Apr 16, 2024
Merged
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
14 changes: 13 additions & 1 deletion src/runtime/contrib/thrust/thrust.cu
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,19 @@ void thrust_sort(DLTensor* input, DLTensor* out_values, DLTensor* out_indices, b
void thrust_sort_common(DLTensor* input, DLTensor* values_out, DLTensor* indices_out,
bool is_ascend, int sort_len, std::string data_dtype, std::string out_dtype,
DLTensor* workspace) {
if (data_dtype == "float32") {
if (data_dtype == "float16") {
if (out_dtype == "int32") {
thrust_sort<half, int32_t>(input, values_out, indices_out, is_ascend, sort_len, workspace);
} else if (out_dtype == "int64") {
thrust_sort<half, int64_t>(input, values_out, indices_out, is_ascend, sort_len, workspace);
} else if (out_dtype == "float32") {
thrust_sort<half, float>(input, values_out, indices_out, is_ascend, sort_len, workspace);
} else if (out_dtype == "float64") {
thrust_sort<half, double>(input, values_out, indices_out, is_ascend, sort_len, workspace);
} else {
LOG(FATAL) << "Unsupported output dtype: " << out_dtype;
}
} else if (data_dtype == "float32") {
if (out_dtype == "int32") {
thrust_sort<float, int32_t>(input, values_out, indices_out, is_ascend, sort_len, workspace);
} else if (out_dtype == "int64") {
Expand Down
Loading