Skip to content

Commit 2035c0d

Browse files
committed
llama : expose API to retrieve devices used by model.
It's useful from the library to be able to do things like list the features being used by the loaded model.
1 parent 06c2b15 commit 2035c0d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

include/llama.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ extern "C" {
479479
LLAMA_API int32_t llama_model_n_layer (const struct llama_model * model);
480480
LLAMA_API int32_t llama_model_n_head (const struct llama_model * model);
481481
LLAMA_API int32_t llama_model_n_head_kv (const struct llama_model * model);
482+
LLAMA_API const ggml_backend_dev_t * llama_model_get_devices (const struct llama_model * model, size_t * out_len);
482483

483484
// Get the model's RoPE frequency scaling factor
484485
LLAMA_API float llama_model_rope_freq_scale_train(const struct llama_model * model);

src/llama-model.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3845,6 +3845,11 @@ int32_t llama_model_n_head_kv(const struct llama_model * model) {
38453845
return model->hparams.n_head_kv();
38463846
}
38473847

3848+
const ggml_backend_dev_t * llama_model_get_devices (const struct llama_model * model, size_t * out_len) {
3849+
*out_len = model->devices.size();
3850+
return model->devices.data();
3851+
}
3852+
38483853
// deprecated
38493854
int32_t llama_n_ctx_train(const struct llama_model * model) {
38503855
return llama_model_n_ctx_train(model);

0 commit comments

Comments
 (0)