File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -231,6 +231,15 @@ struct clip_image_u8_batch {
231231
232232struct clip_image_f32_batch {
233233 std::vector<clip_image_f32_ptr> entries;
234+
235+ clip_image_f32_batch clone () const {
236+ clip_image_f32_batch new_batch;
237+ new_batch.entries .reserve (entries.size ());
238+ for (const auto & entry : entries) {
239+ new_batch.entries .emplace_back (new clip_image_f32 (*entry));
240+ }
241+ return new_batch;
242+ }
234243};
235244
236245//
Original file line number Diff line number Diff line change @@ -166,6 +166,16 @@ struct mtmd_image_tokens {
166166 uint32_t n_tokens () const { return nx * ny; }
167167 clip_image_f32_batch batch_f32; // preprocessed image patches
168168 std::string id; // optional user-defined ID, useful for KV cache tracking
169+
170+ mtmd_image_tokens clone () {
171+ return mtmd_image_tokens{
172+ nx,
173+ ny,
174+ use_mrope_pos,
175+ batch_f32.clone (),
176+ id
177+ };
178+ }
169179};
170180
171181mtmd_context * mtmd_init_from_file (const char * mmproj_fname,
@@ -861,7 +871,8 @@ mtmd_input_chunk * mtmd_input_chunk_copy(const mtmd_input_chunk * chunk) {
861871 };
862872 if (chunk->tokens_image ) {
863873 // copy the image tokens
864- copy->tokens_image = mtmd_image_tokens_ptr (new mtmd_image_tokens (*chunk->tokens_image ));
874+ copy->tokens_image = mtmd_image_tokens_ptr (new mtmd_image_tokens ());
875+ *copy->tokens_image = chunk->tokens_image ->clone ();
865876 }
866877 return copy;
867878}
You can’t perform that action at this time.
0 commit comments