[update] positions and patch merge permute

This commit is contained in:
megemini 2026-01-14 13:39:04 +08:00
parent 65e43e43f9
commit d54c871ddd
2 changed files with 3 additions and 6 deletions

View File

@ -3533,8 +3533,8 @@ bool clip_image_batch_encode(clip_ctx * ctx, const int n_threads, const clip_ima
const int ph = image_size_height / patch_size;
std::vector<int> positions(n_pos * 4);
int ptr = 0;
for (int dy = 0; dy < 2; dy++) {
for (int y = 0; y < ph; y += merge_ratio) {
for (int y = 0; y < ph; y += merge_ratio) {
for (int dy = 0; dy < 2; dy++) {
for (int x = 0; x < pw; x += merge_ratio) {
for (int dx = 0; dx < 2; dx++) {
positions[ ptr] = y + dy;

View File

@ -36,10 +36,7 @@ ggml_cgraph * clip_graph_paddleocr::build() {
NORM_TYPE_NORMAL, proj_norm_eps, -1);
const int scale_factor = model.hparams.n_merge;
int width = img.nx / patch_size;
int height = img.ny / patch_size;
cur = ggml_reshape_3d(ctx0, cur, n_embd * scale_factor * scale_factor, width / scale_factor * height / scale_factor, 1);
cur = build_patch_merge_permute(cur, scale_factor);
cur = build_ffn(cur,
model.mm_1_w, model.mm_1_b,
nullptr, nullptr,