Update Clif wrapper to work with latest gemma.cpp and add simple example

PiperOrigin-RevId: 628134201
This commit is contained in:
Phil Culliton 2024-04-25 11:16:34 -07:00 committed by Copybara-Service
parent 2d4de6b08b
commit 9e0ac5de34
1 changed files with 6 additions and 2 deletions

View File

@ -80,8 +80,7 @@ class AppArgs : public ArgsBase<AppArgs> {
void ChooseNumThreads() {
if (num_threads == kDefaultNumThreads) {
// This is a rough heuristic, replace with something better in the future.
num_threads = static_cast<size_t>(std::clamp(
static_cast<int>(std::thread::hardware_concurrency()) - 2, 1, 18));
num_threads = GetSupportedThreadCount();
}
}
@ -91,6 +90,11 @@ class AppArgs : public ArgsBase<AppArgs> {
ChooseNumThreads();
}
static inline size_t GetSupportedThreadCount() {
return static_cast<size_t>(std::clamp(
static_cast<int>(std::thread::hardware_concurrency()) - 2, 1, 18));
}
Path log; // output
int verbosity;
size_t num_threads;