File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,10 @@ bool LLamaModel::loadModel(const std::string &modelPath)
162
162
d_ptr->ctx_params .seed = params.seed ;
163
163
d_ptr->ctx_params .f16_kv = params.memory_f16 ;
164
164
165
+ d_ptr->n_threads = std::min (4 , (int32_t ) std::thread::hardware_concurrency ());
166
+ d_ptr->ctx_params .n_threads = d_ptr->n_threads ;
167
+ d_ptr->ctx_params .n_threads_batch = d_ptr->n_threads ;
168
+
165
169
#ifdef GGML_USE_METAL
166
170
if (llama_verbose ()) {
167
171
std::cerr << " llama.cpp: using Metal" << std::endl;
@@ -206,14 +210,14 @@ bool LLamaModel::loadModel(const std::string &modelPath)
206
210
}
207
211
#endif
208
212
209
- d_ptr->n_threads = std::min (4 , (int32_t ) std::thread::hardware_concurrency ());
210
213
d_ptr->modelLoaded = true ;
211
214
fflush (stderr);
212
215
return true ;
213
216
}
214
217
215
218
void LLamaModel::setThreadCount (int32_t n_threads) {
216
219
d_ptr->n_threads = n_threads;
220
+ llama_set_n_threads (d_ptr->ctx , n_threads, n_threads);
217
221
}
218
222
219
223
int32_t LLamaModel::threadCount () const {
You can’t perform that action at this time.
0 commit comments