mtmd: add mtmd_image_tokens_get_decoder_pos() API#21851
Merged
Conversation
Collaborator
Author
|
Tests seem ok: |
Collaborator
Author
|
pinging @ggml-org/maintainers for approval |
ServeurpersoCom
approved these changes
Apr 14, 2026
pwilkin
approved these changes
Apr 14, 2026
mengqin
pushed a commit
to mengqin/llama.cpp
that referenced
this pull request
Apr 20, 2026
* mtmd: add mtmd_image_tokens_get_decoder_pos() API * consistent naming * fix build
ArberSephirotheca
pushed a commit
to ArberSephirotheca/llama.cpp
that referenced
this pull request
Apr 21, 2026
* mtmd: add mtmd_image_tokens_get_decoder_pos() API * consistent naming * fix build
arthw
pushed a commit
to arthw/llama.cpp
that referenced
this pull request
Apr 23, 2026
* mtmd: add mtmd_image_tokens_get_decoder_pos() API * consistent naming * fix build
rsenthilkumar6
pushed a commit
to rsenthilkumar6/llama.cpp
that referenced
this pull request
May 1, 2026
* mtmd: add mtmd_image_tokens_get_decoder_pos() API * consistent naming * fix build
ljubomirj
pushed a commit
to ljubomirj/llama.cpp
that referenced
this pull request
May 6, 2026
* mtmd: add mtmd_image_tokens_get_decoder_pos() API * consistent naming * fix build
my-other-github-account
pushed a commit
to my-other-github-account/llama.cpp
that referenced
this pull request
May 15, 2026
* mtmd: add mtmd_image_tokens_get_decoder_pos() API * consistent naming * fix build
my-other-github-account
pushed a commit
to my-other-github-account/llama.cpp
that referenced
this pull request
May 15, 2026
* mtmd: add mtmd_image_tokens_get_decoder_pos() API * consistent naming * fix build
fewtarius
pushed a commit
to fewtarius/llama.cpp
that referenced
this pull request
May 30, 2026
* mtmd: add mtmd_image_tokens_get_decoder_pos() API * consistent naming * fix build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
mtmd_image_tokens_get_decoder_pos()mtmd_image_tokens_get_nx/ny()Additional information
Target support #21045
The mentioned PR proposes a new API
mtmd_image_tokens_get_n_prefixwhich is not very flexible.mtmd_image_tokens_get_decoder_posaddresses this issue by providing non-linear t,x,y positions for each of the token.In the case of falcon-ocr,
mtmd_image_tokens_get_decoder_posreturns linear temporaltand x=0;y=0 for the first few text tokens, then switch to spatial position for image tokens:<|image_cls|>: t=0,x=0,y=0<|image_reg_1|>: t=1,x=0,y=0<|image_reg_4|>: t=4,x=0,y=0Requirements