Skip to content

Commit 79242d8

Browse files
committed
llama : expose layer device type via C API
1 parent 186415d commit 79242d8

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
@@ -481,6 +481,7 @@ extern "C" {
481481
LLAMA_API int32_t llama_model_n_ctx_train(const struct llama_model * model);
482482
LLAMA_API int32_t llama_model_n_embd (const struct llama_model * model);
483483
LLAMA_API int32_t llama_model_n_layer (const struct llama_model * model);
484+
LLAMA_API int32_t llama_model_dev_layer (const struct llama_model * model, int32_t il);
484485
LLAMA_API int32_t llama_model_n_head (const struct llama_model * model);
485486
LLAMA_API int32_t llama_model_n_head_kv (const struct llama_model * model);
486487
LLAMA_API int32_t llama_model_n_swa (const struct llama_model * model);

src/llama-model.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19192,6 +19192,11 @@ int32_t llama_model_n_layer(const llama_model * model) {
1919219192
return model->hparams.n_layer;
1919319193
}
1919419194

19195+
int32_t llama_model_dev_layer(const llama_model * model, int32_t il) {
19196+
ggml_backend_dev_t dev = model->dev_layer(il);
19197+
return static_cast<int32_t>(ggml_backend_dev_type(dev));
19198+
}
19199+
1919519200
int32_t llama_model_n_head(const llama_model * model) {
1919619201
return model->hparams.n_head();
1919719202
}

0 commit comments

Comments
 (0)