Skip to content

Commit 49c0863

Browse files
Use max feature layer for postnorm
Signed-off-by: Alex-Brooks <[email protected]>
1 parent 8676316 commit 49c0863

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

examples/llava/clip.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,6 @@ static ggml_cgraph * clip_image_build_graph(clip_ctx * ctx, const clip_image_f32
655655
const int hidden_size = hparams.hidden_size;
656656
const int n_head = hparams.n_head;
657657
const int d_head = hidden_size / n_head;
658-
int n_layer = hparams.n_layer;
659658
const float eps = hparams.eps;
660659
int mrope_sections[4] = {d_head/4, d_head/4, d_head/4, d_head/4};
661660

@@ -859,15 +858,15 @@ static ggml_cgraph * clip_image_build_graph(clip_ctx * ctx, const clip_image_f32
859858
}
860859

861860
// post-layernorm
862-
if (ctx->has_post_norm && ctx->max_feature_layer == n_layer) {
861+
if (ctx->has_post_norm) {
863862
embeddings = ggml_norm(ctx0, embeddings, eps);
864863
ggml_set_name(embeddings, "post_ln");
865864

866865
embeddings = ggml_add(ctx0, ggml_mul(ctx0, embeddings, model.post_ln_w), model.post_ln_b);
867866
}
868867

869868
// final layer is a vision feature layer
870-
if (vision_feature_layer.find(n_layer) != vision_feature_layer.end()) {
869+
if (vision_feature_layer.find(ctx->max_feature_layer) != vision_feature_layer.end()) {
871870
embedding_stack.push_back(embeddings);
872871
}
873872

0 commit comments

Comments
 (0)