aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwzy <32936898+Freed-Wu@users.noreply.github.com>2023-07-23 21:33:02 +0800
committerGitHub <noreply@github.com>2023-07-23 16:33:02 +0300
commit57921ca6db53e08eb90010fba99add85be28b5a1 (patch)
tree073f913817878e9b213e838791c174b9ffb20eb4
parent3602ac4255fd4cd589821346290b464a64b955d1 (diff)
common : n_threads == -1 uses std::thread::hardware_concurrency() (#2347)
* Fix #2345, fix incorrect n_threads * Update examples/common.cpp --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
-rw-r--r--examples/common.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/examples/common.cpp b/examples/common.cpp
index 5608ca8..7a1928f 100644
--- a/examples/common.cpp
+++ b/examples/common.cpp
@@ -117,6 +117,9 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
break;
}
params.n_threads = std::stoi(argv[i]);
+ if (params.n_threads <= 0) {
+ params.n_threads = std::thread::hardware_concurrency();
+ }
} else if (arg == "-p" || arg == "--prompt") {
if (++i >= argc) {
invalid_param = true;