Skip to content

Commit

Permalink
Fix num_threads flag being ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
setzer22 committed Apr 3, 2023
1 parent 57440bf commit 25b1487
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions llama-cli/src/cli_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub struct Args {
}
impl Args {
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
pub(crate) fn num_threads(&self) -> usize {
pub(crate) fn autodetect_num_threads(&self) -> usize {
std::process::Command::new("sysctl")
.arg("-n")
.arg("hw.perflevel0.physicalcpu")
Expand All @@ -137,9 +137,13 @@ impl Args {
}

#[cfg(not(all(target_os = "macos", target_arch = "aarch64")))]
pub(crate) fn num_threads(&self) -> usize {
pub(crate) fn autodetect_num_threads(&self) -> usize {
num_cpus::get_physical()
}

pub(crate) fn num_threads(&self) -> usize {
self.num_threads.unwrap_or_else(|| self.autodetect_num_threads())
}
}

fn parse_bias(s: &str) -> Result<TokenBias, String> {
Expand Down

0 comments on commit 25b1487

Please sign in to comment.