Skip to content

Commit

Permalink
Improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
yinggeh committed Jul 19, 2024
1 parent ea51c02 commit e6c7cb9
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/libtorch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1937,21 +1937,17 @@ SetStringInputTensor(
}
#endif // TRITON_ENABLE_GPU

auto callback = [](torch::List<std::string>* input_list, const char* content,
const uint32_t len) {
// Set string value
input_list->push_back(std::string(content, len));
};
auto fn = std::bind(
callback, input_list, std::placeholders::_2, std::placeholders::_3);

std::vector<std::pair<const char*, const uint32_t>> str_list;
err = ValidateStringBuffer(
content, content_byte_size, request_element_cnt, name, &element_idx, fn);
content, content_byte_size, request_element_cnt, name, &str_list);
// Set string values.
for (const auto& [addr, len] : str_list) {
input_list->push_back(std::string(addr, len));
}

if (err != nullptr) {
RESPOND_AND_SET_NULL_IF_ERROR(response, err);
if (element_idx < request_element_cnt) {
FillStringTensor(input_list, request_element_cnt - element_idx);
}
FillStringTensor(input_list, request_element_cnt - element_idx);
}
return cuda_copy;
}
Expand Down

0 comments on commit e6c7cb9

Please sign in to comment.