Skip to content

Commit b2958b3

Browse files
authored
Merge pull request #33 from NexaAI/weili/dev
fix clip allocation size error for 81-series vlm models
2 parents 97267e6 + b86cded commit b2958b3

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

examples/omni-vlm/clip.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,16 +1927,20 @@ int clip_n_patches(const struct clip_ctx * ctx) {
19271927

19281928
int n_patches = (params.image_size / params.patch_size) * (params.image_size / params.patch_size);
19291929

1930-
if (ctx->proj_type == PROJECTOR_TYPE_LDP || ctx->proj_type == PROJECTOR_TYPE_LDPV2) {
1931-
n_patches /= 4;
1932-
} else if (ctx->proj_type == PROJECTOR_TYPE_RESAMPLER) {
1933-
if (ctx->minicpmv_version == 2) {
1934-
n_patches = 96;
1935-
}
1936-
else if (ctx->minicpmv_version == 3) {
1937-
n_patches = 64;
1938-
}
1939-
}
1930+
if(ctx->omni_vlm_ver_type == omni_vlm_version_type::VLM_81_OCR
1931+
|| ctx->omni_vlm_ver_type == omni_vlm_version_type::VLM_81_INSTRUCT) {
1932+
n_patches /= 9;
1933+
}
1934+
// if (ctx->proj_type == PROJECTOR_TYPE_LDP || ctx->proj_type == PROJECTOR_TYPE_LDPV2) {
1935+
// n_patches /= 4;
1936+
// } else if (ctx->proj_type == PROJECTOR_TYPE_RESAMPLER) {
1937+
// if (ctx->minicpmv_version == 2) {
1938+
// n_patches = 96;
1939+
// }
1940+
// else if (ctx->minicpmv_version == 3) {
1941+
// n_patches = 64;
1942+
// }
1943+
// }
19401944

19411945
return n_patches;
19421946
}

0 commit comments

Comments
 (0)