From 57921ca6db53e08eb90010fba99add85be28b5a1 Mon Sep 17 00:00:00 2001 From: wzy <32936898+Freed-Wu@users.noreply.github.com> Date: Sun, 23 Jul 2023 21:33:02 +0800 Subject: 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 --- examples/common.cpp | 3 +++ 1 file changed, 3 insertions(+) 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; -- cgit v1.2.3