summaryrefslogtreecommitdiff
path: root/examples/llava/clip.cpp
diff options
context:
space:
mode:
authorM. Yusuf Sarıgöz <yusufsarigoz@gmail.com>2023-10-19 16:59:11 +0300
committerGitHub <noreply@github.com>2023-10-19 16:59:11 +0300
commit60abea9798f47b918a9f38c66edfd88c526d20f6 (patch)
tree1bc6d935abb42a048ff346b781343bd300abdc98 /examples/llava/clip.cpp
parent004797f6ac135383f8c1d1f5bd415ddee2f79318 (diff)
llava : avoid segfault in case of non-existent mmproj file (#3674)
Diffstat (limited to 'examples/llava/clip.cpp')
-rw-r--r--examples/llava/clip.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/llava/clip.cpp b/examples/llava/clip.cpp
index f4258b34..1ae9077b 100644
--- a/examples/llava/clip.cpp
+++ b/examples/llava/clip.cpp
@@ -112,8 +112,7 @@ static float get_f32(const gguf_context * ctx, const std::string & key) {
static struct ggml_tensor * get_tensor(struct ggml_context * ctx, const std::string & name) {
struct ggml_tensor * cur = ggml_get_tensor(ctx, name.c_str());
if (!cur) {
- printf("unable to find tensor %s\n", name.c_str());
- throw std::runtime_error(format("unable to find tensor %s\n", name.c_str()));
+ throw std::runtime_error(format("%s: unable to find tensor %s\n", __func__, name.c_str()));
}
return cur;
@@ -136,7 +135,7 @@ static std::string get_ftype(int ftype) {
case 8:
return "q8_0";
default:
- throw std::runtime_error(format("Unrecognized file type: %d\n", ftype));
+ throw std::runtime_error(format("%s: Unrecognized file type: %d\n", __func__, ftype));
}
}
@@ -462,6 +461,9 @@ struct clip_ctx * clip_model_load(const char * fname, const int verbosity = 1) {
};
struct gguf_context * ctx = gguf_init_from_file(fname, params);
+ if (!ctx) {
+ throw std::runtime_error(format("%s: failed to load CLIP model from %s. Does this file exist?\n", __func__, fname));
+ }
if (verbosity >= 1) {
const int n_tensors = gguf_get_n_tensors(ctx);