From e6c7cb95550bb2506c2fbf43903de6f10abe910b Mon Sep 17 00:00:00 2001 From: Yingge He Date: Fri, 19 Jul 2024 15:54:36 -0700 Subject: [PATCH] Improve readability --- src/libtorch.cc | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/libtorch.cc b/src/libtorch.cc index 3aca4da..7ce5c58 100644 --- a/src/libtorch.cc +++ b/src/libtorch.cc @@ -1937,21 +1937,17 @@ SetStringInputTensor( } #endif // TRITON_ENABLE_GPU - auto callback = [](torch::List* 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> 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; }