Skip to content

Commit edf8ca2

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 745aa53 commit edf8ca2

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
@@ -510,6 +510,7 @@ extern "C" {
510510
LLAMA_API int32_t llama_model_n_head (const struct llama_model * model);
511511
LLAMA_API int32_t llama_model_n_head_kv (const struct llama_model * model);
512512
LLAMA_API int32_t llama_model_n_swa (const struct llama_model * model);
513+
LLAMA_API const ggml_backend_dev_t * llama_model_get_devices (const struct llama_model * model, size_t * out_len);
513514

514515
// Get the model's RoPE frequency scaling factor
515516
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
@@ -13628,6 +13628,11 @@ const char * llama_model_cls_label(const struct llama_model * model, uint32_t i)
1362813628
return nullptr;
1362913629
}
1363013630

13631+
const ggml_backend_dev_t * llama_model_get_devices (const struct llama_model * model, size_t * out_len) {
13632+
*out_len = model->devices.size();
13633+
return model->devices.data();
13634+
}
13635+
1363113636
// deprecated
1363213637
int32_t llama_n_ctx_train(const llama_model * model) {
1363313638
return llama_model_n_ctx_train(model);

0 commit comments

Comments
 (0)