Skip to content

Commit f13fa9b

Browse files
committed
llama : expose layer device type via C API
1 parent 8846aac commit f13fa9b

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
@@ -14698,6 +14698,11 @@ int32_t llama_model_n_layer(const llama_model * model) {
1469814698
return model->hparams.n_layer;
1469914699
}
1470014700

14701+
int32_t llama_model_dev_layer(const llama_model * model, int32_t il) {
14702+
ggml_backend_dev_t dev = model->dev_layer(il);
14703+
return static_cast<int32_t>(ggml_backend_dev_type(dev));
14704+
}
14705+
1470114706
int32_t llama_model_n_head(const llama_model * model) {
1470214707
return model->hparams.n_head();
1470314708
}

0 commit comments

Comments
 (0)