Skip to content

Commit 12c286e

Browse files
committed
llama : expose layer device type via C API
1 parent 67d1ef2 commit 12c286e

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
@@ -511,6 +511,7 @@ extern "C" {
511511
LLAMA_API int32_t llama_model_n_ctx_train(const struct llama_model * model);
512512
LLAMA_API int32_t llama_model_n_embd (const struct llama_model * model);
513513
LLAMA_API int32_t llama_model_n_layer (const struct llama_model * model);
514+
LLAMA_API int32_t llama_model_dev_layer (const struct llama_model * model, int32_t il);
514515
LLAMA_API int32_t llama_model_n_head (const struct llama_model * model);
515516
LLAMA_API int32_t llama_model_n_head_kv (const struct llama_model * model);
516517
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
@@ -15103,6 +15103,11 @@ int32_t llama_model_n_layer(const llama_model * model) {
1510315103
return model->hparams.n_layer;
1510415104
}
1510515105

15106+
int32_t llama_model_dev_layer(const llama_model * model, int32_t il) {
15107+
ggml_backend_dev_t dev = model->dev_layer(il);
15108+
return static_cast<int32_t>(ggml_backend_dev_type(dev));
15109+
}
15110+
1510615111
int32_t llama_model_n_head(const llama_model * model) {
1510715112
return model->hparams.n_head();
1510815113
}

0 commit comments

Comments
 (0)