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 {
231
231
232
232
struct clip_image_f32_batch {
233
233
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
+ }
234
243
};
235
244
236
245
//
Original file line number Diff line number Diff line change @@ -166,6 +166,16 @@ struct mtmd_image_tokens {
166
166
uint32_t n_tokens () const { return nx * ny; }
167
167
clip_image_f32_batch batch_f32; // preprocessed image patches
168
168
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
+ }
169
179
};
170
180
171
181
mtmd_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) {
861
871
};
862
872
if (chunk->tokens_image ) {
863
873
// 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 ();
865
876
}
866
877
return copy;
867
878
}
You can’t perform that action at this time.
0 commit comments