try-catch

This commit is contained in:
jon-chuang 2023-04-13 13:14:15 +08:00
parent f181c28edd
commit 8694318c71

View file

@ -42,8 +42,10 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
while (std::getline(cpuinfo, line)) {
if (line.find("cpu cores") != std::string::npos) {
line.erase(0, line.find(": ") + 2);
try {
params.n_threads = std::stoul(line);
break;
} catch (std::invalid_argument& e) {} // Ignore if we could not parse
}
}
#elif defined(__APPLE__) && defined(__MACH__)