Skip to content

Commit 5a63738

Browse files
ngxsonjwcolin
authored andcommitted
clip : use smart pointer (⚠️ breaking change) (ggml-org#12869)
* clip : use smart pointers * fix warmup * add forward declaration * misisng include * fix include (2) * composite * simplify batch ptr * fix conflict
1 parent bd07fca commit 5a63738

File tree

5 files changed

+255
-254
lines changed

5 files changed

+255
-254
lines changed

examples/llava/clip-impl.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "ggml.h"
22
#include "gguf.h"
3+
#include "clip.h"
34

45
#include "clip.h"
56

@@ -202,23 +203,31 @@ static void clip_log_internal(enum ggml_log_level level, const char * format, ..
202203
// cpp wrappers
203204
//
204205

206+
// wrapper for clip_image_size
207+
struct clip_image_size_deleter {
208+
void operator()(clip_image_size * val) { clip_image_size_free(val); }
209+
};
210+
typedef std::unique_ptr<clip_image_size, clip_image_size_deleter> clip_image_size_ptr;
211+
212+
// wrapper for clip_image_u8
205213
struct clip_image_u8_deleter {
206214
void operator()(clip_image_u8 * val) { clip_image_u8_free(val); }
207215
};
216+
typedef std::unique_ptr<clip_image_u8, clip_image_u8_deleter> clip_image_u8_ptr;
208217

218+
// wrapper for clip_image_f32
209219
struct clip_image_f32_deleter {
210220
void operator()(clip_image_f32 * val) { clip_image_f32_free(val); }
211221
};
222+
typedef std::unique_ptr<clip_image_f32, clip_image_f32_deleter> clip_image_f32_ptr;
212223

213-
struct clip_image_f32_batch_deleter {
214-
void operator()(clip_image_f32_batch * val) { clip_image_f32_batch_free(val); }
224+
struct clip_image_u8_batch {
225+
std::vector<clip_image_u8_ptr> entries;
215226
};
216227

217-
typedef std::unique_ptr<clip_image_u8, clip_image_u8_deleter> clip_image_u8_ptr;
218-
typedef std::unique_ptr<clip_image_f32, clip_image_f32_deleter> clip_image_f32_ptr;
219-
typedef std::unique_ptr<clip_image_f32_batch, clip_image_f32_batch_deleter> clip_image_f32_batch_ptr;
220-
221-
// TODO @ngxson : we're currently having a naming clash between struct clip_image_size and function clip_image_size()
228+
struct clip_image_f32_batch {
229+
std::vector<clip_image_f32_ptr> entries;
230+
};
222231

223232
//
224233
// common utils

0 commit comments

Comments
 (0)