clip : bring back GPU support (#12322)

* clip : bring back GPU support

* use n_gpu_layers param

* fix double free

* ggml_backend_init_by_type

* clean up
This commit is contained in:
Xuan-Son Nguyen 2025-03-11 09:20:16 +01:00 committed by GitHub
parent 2c9f833d17
commit 96e1280839
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 89 additions and 77 deletions

View file

@ -86,7 +86,11 @@ static struct clip_ctx * clip_init_context(common_params * params) {
if (prompt.empty()) {
prompt = "describe the image in detail.";
}
auto * ctx_clip = clip_model_load(clip_path, /*verbosity=*/ 1);
struct clip_context_params clip_params = {
/* use_gpu */ params->n_gpu_layers != 0,
/* verbosity */ params->verbosity,
};
auto * ctx_clip = clip_init(clip_path, clip_params);
return ctx_clip;
}