File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -853,9 +853,16 @@ const mtmd_image_tokens * mtmd_input_chunk_get_tokens_image(const mtmd_input_chu
853
853
return nullptr ;
854
854
}
855
855
856
- mtmd_input_chunk * mtmd_input_chunk_release (mtmd_input_chunk * chunk) {
857
- mtmd_input_chunk * copy = new mtmd_input_chunk;
858
- *copy = std::move (*chunk);
856
+ mtmd_input_chunk * mtmd_input_chunk_copy (const mtmd_input_chunk * chunk) {
857
+ mtmd_input_chunk * copy = new mtmd_input_chunk{
858
+ chunk->type ,
859
+ chunk->tokens_text ,
860
+ mtmd_image_tokens_ptr (),
861
+ };
862
+ if (chunk->tokens_image ) {
863
+ // copy the image tokens
864
+ copy->tokens_image = mtmd_image_tokens_ptr (new mtmd_image_tokens (*chunk->tokens_image ));
865
+ }
859
866
return copy;
860
867
}
861
868
Original file line number Diff line number Diff line change @@ -124,11 +124,10 @@ MTMD_API const llama_token * mtmd_input_chunk_get_tokens_text (const mtmd
124
124
MTMD_API const mtmd_image_tokens * mtmd_input_chunk_get_tokens_image (const mtmd_input_chunk * chunk);
125
125
126
126
// in case you want to use custom logic to handle the chunk (i.e. KV cache management)
127
- // you can move the chunk ownership to your own code
128
- // this will release the chunk from the list of input chunks
127
+ // you can move the chunk ownership to your own code by copying it
129
128
// remember to free the chunk when you are done with it
130
- MTMD_API mtmd_input_chunk * mtmd_input_chunk_release ( mtmd_input_chunk * chunk);
131
- MTMD_API void mtmd_input_chunk_free (mtmd_input_chunk * chunk);
129
+ MTMD_API mtmd_input_chunk * mtmd_input_chunk_copy ( const mtmd_input_chunk * chunk);
130
+ MTMD_API void mtmd_input_chunk_free (mtmd_input_chunk * chunk);
132
131
133
132
134
133
// mtmd_image_tokens
You can’t perform that action at this time.
0 commit comments