@@ -94,10 +94,19 @@ class mtmd_input_chunk_type(enum.IntEnum):
9494mtmd_bitmap_p = NewType ("mtmd_bitmap_p" , int )
9595mtmd_bitmap_p_ctypes = c_void_p
9696
97+ # // position indexing for decoder model
98+ # enum mtmd_pos_type {
99+ # MTMD_POS_TYPE_NORMAL, // number of positions equals to number of tokens
100+ # MTMD_POS_TYPE_MROPE, // qwen-vl mrope style, each image takes max(t,h,w) position indexes
101+ # };
102+ class mtmd_pos_type (enum .IntEnum ):
103+ MTMD_POS_TYPE_NORMAL = 0 # number of positions equals to number of tokens
104+ MTMD_POS_TYPE_MROPE = 1 # qwen-vl mrope style, each image takes max(t,h,w) position indexes
105+
97106# struct mtmd_image_tokens {
98107# uint32_t nx; // number of tokens in x direction
99108# uint32_t ny; // number of tokens in y direction
100- # bool use_mrope_pos = false; // use M-RoPE position counting (the whole image is 1 temporal position)
109+ # mtmd_pos_type pos = MTMD_POS_TYPE_NORMAL;
101110# uint32_t n_tokens() const { return nx * ny; }
102111# clip_image_f32_batch batch_f32; // preprocessed image patches
103112# std::string id; // optional user-defined ID, useful for KV cache tracking
@@ -269,36 +278,37 @@ def mtmd_free(ctx: mtmd_context_p):
269278 ...
270279
271280# // whether we need to set non-causal mask before llama_decode
272- # MTMD_API bool mtmd_decode_use_non_causal(mtmd_context * ctx);
281+ # // if chunk is nullptr, we assume the default case where chunk is an image chunk
282+ # MTMD_API bool mtmd_decode_use_non_causal(const mtmd_context * ctx, const mtmd_input_chunk * chunk);
273283@ctypes_function_mtmd (
274- "mtmd_decode_use_non_causal" , [mtmd_context_p_ctypes ], c_bool )
275- def mtmd_decode_use_non_causal (ctx : mtmd_context_p ) -> c_bool :
284+ "mtmd_decode_use_non_causal" , [mtmd_context_p_ctypes , mtmd_input_chunk_p_ctypes ], c_bool )
285+ def mtmd_decode_use_non_causal (ctx : mtmd_context_p , chunk : mtmd_input_chunk_p ) -> c_bool :
276286 ...
277287
278288# // whether the current model use M-RoPE for llama_decode
279- # MTMD_API bool mtmd_decode_use_mrope(mtmd_context * ctx);
289+ # MTMD_API bool mtmd_decode_use_mrope(const mtmd_context * ctx);
280290@ctypes_function_mtmd (
281291 "mtmd_decode_use_mrope" , [mtmd_context_p_ctypes ], c_bool )
282292def mtmd_decode_use_mrope (ctx : mtmd_context_p ) -> c_bool :
283293 ...
284294
285295# // whether the current model supports vision input
286- # MTMD_API bool mtmd_support_vision(mtmd_context * ctx);
296+ # MTMD_API bool mtmd_support_vision(const mtmd_context * ctx);
287297@ctypes_function_mtmd (
288298 "mtmd_support_vision" , [mtmd_context_p_ctypes ], c_bool )
289299def mtmd_support_vision (ctx : mtmd_context_p ) -> c_bool :
290300 ...
291301
292302# // whether the current model supports audio input
293- # MTMD_API bool mtmd_support_audio(mtmd_context * ctx);
303+ # MTMD_API bool mtmd_support_audio(const mtmd_context * ctx);
294304@ctypes_function_mtmd (
295305 "mtmd_support_audio" , [mtmd_context_p_ctypes ], c_bool )
296306def mtmd_support_audio (ctx : mtmd_context_p ) -> c_bool :
297307 ...
298308
299309# // get audio sample rate in Hz, for example 16000 for Whisper
300310# // return -1 if audio is not supported
301- # MTMD_API int mtmd_get_audio_sample_rate(mtmd_context * ctx);
311+ # MTMD_API int mtmd_get_audio_sample_rate(const mtmd_context * ctx);
302312@ctypes_function_mtmd (
303313 "mtmd_get_audio_sample_rate" , [mtmd_context_p_ctypes ], c_int )
304314def mtmd_get_audio_sample_rate (ctx : mtmd_context_p ) -> c_int :
0 commit comments