fix override tensors string matching issue (+2 squashed commit)

Squashed commit:

[850340501] will be deleted later, quick test

[eb4f569a7] debug buffer types
This commit is contained in:
Concedo
2025-12-18 18:37:31 +08:00
parent 30fecac3a3
commit fae2ff6d2d
+13
View File
@@ -187,6 +187,17 @@ inline bool LogitsDuplicated(std::vector<float> & arr1, std::vector<float> & arr
return true;
}
static inline void string_trim_whitespace(std::string & s) {
auto nul = std::find(s.begin(), s.end(), '\0'); //remove everything after the first NUL
if (nul != s.end()) {
s.erase(nul, s.end());
}
if (s.empty()) return;
// trim leading whitespace
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) { return !std::isspace(ch); }));
// trim trailing whitespace
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) { return !std::isspace(ch); }).base(), s.end());
}
static std::string FileFormatTokenizeID(int id, FileFormat file_format, bool return_special = false)
{
@@ -2414,6 +2425,8 @@ ModelLoadResult gpttype_load_model(const load_model_inputs inputs, FileFormat in
}
std::string tensor_name = overrider.substr(0, pos);
std::string buffer_type = overrider.substr(pos + 1);
string_trim_whitespace(tensor_name);
string_trim_whitespace(buffer_type);
if (buft_list.find(buffer_type) == buft_list.end()) {
printf("\nUnknown Buffer Type: %s\n",buffer_type.c_str());