Skip to content

Commit

Permalink
fix crash with return alternative on CUDA (#1733)
Browse files Browse the repository at this point in the history
  • Loading branch information
minhthuc2502 authored Jun 27, 2024
1 parent 72a461a commit 451c27b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/decoding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ namespace ctranslate2 {
StorageView& ids) {
if (!decoder.output_layer_is_updated())
return;
ctranslate2::Device device = ids.device();
if (device != Device::CPU)
ids = ids.to(Device::CPU);
auto* ids_data = ids.data<int32_t>();
for (dim_t i = 0; i < ids.size(); ++i)
ids_data[i] = decoder.to_original_word_id(ids_data[i]);
if (ids.device() != device)
ids = ids.to(device);
}

template <typename T>
Expand Down

0 comments on commit 451c27b

Please sign in to comment.