File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -470,6 +470,8 @@ extern "C" {
470
470
471
471
LLAMA_API const struct llama_model * llama_get_model (const struct llama_context * ctx);
472
472
LLAMA_API enum llama_pooling_type llama_pooling_type (const struct llama_context * ctx);
473
+ LLAMA_API size_t llama_n_backends (const struct llama_context * ctx);
474
+ LLAMA_API size_t llama_get_backends (const struct llama_context * ctx, ggml_backend_t * out_buf, size_t out_len);
473
475
474
476
LLAMA_API const struct llama_vocab * llama_model_get_vocab (const struct llama_model * model);
475
477
LLAMA_API enum llama_rope_type llama_model_rope_type (const struct llama_model * model);
@@ -479,6 +481,7 @@ extern "C" {
479
481
LLAMA_API int32_t llama_model_n_layer (const struct llama_model * model);
480
482
LLAMA_API int32_t llama_model_n_head (const struct llama_model * model);
481
483
LLAMA_API int32_t llama_model_n_head_kv (const struct llama_model * model);
484
+ LLAMA_API const ggml_backend_dev_t * llama_model_get_devices (const struct llama_model * model, size_t * out_len);
482
485
483
486
// Get the model's RoPE frequency scaling factor
484
487
LLAMA_API float llama_model_rope_freq_scale_train (const struct llama_model * model);
Original file line number Diff line number Diff line change @@ -610,6 +610,18 @@ enum llama_pooling_type llama_pooling_type(const struct llama_context * ctx) {
610
610
return ctx->cparams .pooling_type ;
611
611
}
612
612
613
+ size_t llama_n_backends (const struct llama_context * ctx) {
614
+ return ctx->backends .size ();
615
+ }
616
+
617
+ size_t llama_get_backends (const struct llama_context * ctx, ggml_backend_t * out, size_t out_len) {
618
+ size_t return_len = std::min (ctx->backends .size (), out_len);
619
+ for (size_t i = 0 ; i < return_len; i++) {
620
+ out[i] = ctx->backends [i].get ();
621
+ }
622
+ return return_len;
623
+ }
624
+
613
625
void llama_attach_threadpool (
614
626
struct llama_context * ctx,
615
627
ggml_threadpool_t threadpool,
Original file line number Diff line number Diff line change @@ -3845,6 +3845,11 @@ int32_t llama_model_n_head_kv(const struct llama_model * model) {
3845
3845
return model->hparams .n_head_kv ();
3846
3846
}
3847
3847
3848
+ const ggml_backend_dev_t * llama_model_get_devices (const struct llama_model * model, size_t * out_len) {
3849
+ *out_len = model->devices .size ();
3850
+ return model->devices .data ();
3851
+ }
3852
+
3848
3853
// deprecated
3849
3854
int32_t llama_n_ctx_train (const struct llama_model * model) {
3850
3855
return llama_model_n_ctx_train (model);
You can’t perform that action at this time.
0 commit comments