|
1 | 1 | #include "ggml.h" |
2 | 2 | #include "gguf.h" |
| 3 | +#include "clip.h" |
3 | 4 |
|
4 | 5 | #include <climits> |
5 | 6 | #include <cstdarg> |
@@ -178,6 +179,42 @@ static void clip_log_internal(enum ggml_log_level level, const char * format, .. |
178 | 179 | #define LOG_DBG(...) LOG_TMPL(GGML_LOG_LEVEL_DEBUG, __VA_ARGS__) |
179 | 180 | #define LOG_CNT(...) LOG_TMPL(GGML_LOG_LEVEL_CONT, __VA_ARGS__) |
180 | 181 |
|
| 182 | +// |
| 183 | +// cpp wrappers |
| 184 | +// |
| 185 | + |
| 186 | +struct clip_image_u8_deleter { |
| 187 | + void operator()(clip_image_u8 * val) { clip_image_u8_free(val); } |
| 188 | +}; |
| 189 | + |
| 190 | +struct clip_image_f32_deleter { |
| 191 | + void operator()(clip_image_f32 * val) { clip_image_f32_free(val); } |
| 192 | +}; |
| 193 | + |
| 194 | +struct clip_image_size_deleter { |
| 195 | + void operator()(clip_image_size * val) { clip_image_size_free(val); } |
| 196 | +}; |
| 197 | + |
| 198 | +struct clip_image_u8_ptr : std::unique_ptr<clip_image_u8, clip_image_u8_deleter> { |
| 199 | + clip_image_u8_ptr() : std::unique_ptr<clip_image_u8, clip_image_u8_deleter>(clip_image_u8_init()) {} |
| 200 | +}; |
| 201 | + |
| 202 | +struct clip_image_f32_ptr : std::unique_ptr<clip_image_f32, clip_image_f32_deleter> { |
| 203 | + clip_image_f32_ptr() : std::unique_ptr<clip_image_f32, clip_image_f32_deleter>(clip_image_f32_init()) {} |
| 204 | +}; |
| 205 | + |
| 206 | +typedef std::unique_ptr<clip_image_size, clip_image_size_deleter> clip_image_size_ptr; |
| 207 | + |
| 208 | +// these need to be struct to maintain compatibility with C interface |
| 209 | +struct clip_image_u8_batch : std::vector<clip_image_u8_ptr> { |
| 210 | + clip_image_u8_batch() : std::vector<clip_image_u8_ptr>() {} |
| 211 | +}; |
| 212 | +struct clip_image_f32_batch : std::vector<clip_image_f32_ptr> { |
| 213 | + clip_image_f32_batch() : std::vector<clip_image_f32_ptr>() {} |
| 214 | + ~clip_image_f32_batch() {} |
| 215 | +}; |
| 216 | + |
| 217 | + |
181 | 218 | // |
182 | 219 | // common utils |
183 | 220 | // |
|
0 commit comments