Skip to content

Commit 3853cf0

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 d7cfe1f commit 3853cf0

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
@@ -478,6 +478,7 @@ extern "C" {
478478
LLAMA_API int32_t llama_model_n_layer (const struct llama_model * model);
479479
LLAMA_API int32_t llama_model_n_head (const struct llama_model * model);
480480
LLAMA_API int32_t llama_model_n_head_kv (const struct llama_model * model);
481+
LLAMA_API const ggml_backend_dev_t * llama_model_get_devices (const struct llama_model * model, size_t * out_len);
481482

482483
// Get the model's RoPE frequency scaling factor
483484
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
@@ -3842,6 +3842,11 @@ int32_t llama_model_n_head_kv(const struct llama_model * model) {
38423842
return model->hparams.n_head_kv();
38433843
}
38443844

3845+
const ggml_backend_dev_t * llama_model_get_devices (const struct llama_model * model, size_t * out_len) {
3846+
*out_len = model->devices.size();
3847+
return model->devices.data();
3848+
}
3849+
38453850
// deprecated
38463851
int32_t llama_n_ctx_train(const struct llama_model * model) {
38473852
return llama_model_n_ctx_train(model);

0 commit comments

Comments
 (0)