Skip to content

Commit b291cdc

Browse files
dm4jwcolin
authored andcommitted
llava: add more helper functions to check projector types in clip context (ggml-org#12824)
Signed-off-by: dm4 <sunrisedm4@gmail.com>
1 parent b344da6 commit b291cdc

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

examples/llava/clip.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2840,10 +2840,19 @@ int clip_is_minicpmv(const struct clip_ctx * ctx) {
28402840
bool clip_is_glm(const struct clip_ctx * ctx) {
28412841
return ctx->has_glm_projector;
28422842
}
2843+
28432844
bool clip_is_qwen2vl(const struct clip_ctx * ctx) {
28442845
return ctx->has_qwen2vl_merger;
28452846
}
28462847

2848+
bool clip_is_llava(const struct clip_ctx * ctx) {
2849+
return ctx->has_llava_projector;
2850+
}
2851+
2852+
bool clip_is_gemma3(const struct clip_ctx * ctx) {
2853+
return ctx->proj_type == PROJECTOR_TYPE_GEMMA3;
2854+
}
2855+
28472856
// Determine the number of encoder layers to iterate over
28482857
int get_deepest_feature_layer(const struct clip_ctx * ctx) {
28492858
// Get the index of the second to last layer; this is the

examples/llava/clip.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ CLIP_API bool clip_model_quantize(const char * fname_inp, const char * fname_out
106106
CLIP_API int clip_is_minicpmv(const struct clip_ctx * ctx);
107107
CLIP_API bool clip_is_glm(const struct clip_ctx * ctx);
108108
CLIP_API bool clip_is_qwen2vl(const struct clip_ctx * ctx);
109+
CLIP_API bool clip_is_llava(const struct clip_ctx * ctx);
110+
CLIP_API bool clip_is_gemma3(const struct clip_ctx * ctx);
109111

110112
CLIP_API int get_deepest_feature_layer(const struct clip_ctx * ctx);
111113

0 commit comments

Comments
 (0)