Skip to content

Commit 049ae24

Browse files
committed
add warning about breaking changes
1 parent e9f7ff9 commit 049ae24

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

tools/llava/mtmd.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ const mtmd_image_tokens * mtmd_input_chunk_get_tokens_image(const mtmd_input_chu
859859
return nullptr;
860860
}
861861

862-
const mtmd_input_chunk * mtmd_input_chunk_copy(const mtmd_input_chunk * chunk) {
862+
mtmd_input_chunk * mtmd_input_chunk_copy(const mtmd_input_chunk * chunk) {
863863
mtmd_input_chunk * copy = new mtmd_input_chunk{
864864
chunk->type,
865865
chunk->tokens_text,

tools/llava/mtmd.h

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515
#include <memory>
1616
#endif
1717

18+
/**
19+
* libmtmd: A library for multimodal support in llama.cpp.
20+
*
21+
* WARNING: This API is experimental and subject to many BREAKING CHANGES.
22+
* Issues related to API usage may receive lower priority support.
23+
*
24+
* For the usage, see an example in mtmd-cli.cpp
25+
*/
26+
1827
#ifdef LLAMA_SHARED
1928
# if defined(_WIN32) && !defined(__MINGW32__)
2029
# ifdef LLAMA_BUILD
@@ -126,8 +135,8 @@ MTMD_API const mtmd_image_tokens * mtmd_input_chunk_get_tokens_image(const mtmd
126135
// in case you want to use custom logic to handle the chunk (i.e. KV cache management)
127136
// you can move the chunk ownership to your own code by copying it
128137
// remember to free the chunk when you are done with it
129-
MTMD_API const mtmd_input_chunk * mtmd_input_chunk_copy(const mtmd_input_chunk * chunk);
130-
MTMD_API void mtmd_input_chunk_free(mtmd_input_chunk * chunk);
138+
MTMD_API mtmd_input_chunk * mtmd_input_chunk_copy(const mtmd_input_chunk * chunk);
139+
MTMD_API void mtmd_input_chunk_free(mtmd_input_chunk * chunk);
131140

132141

133142
// mtmd_image_tokens
@@ -172,9 +181,10 @@ MTMD_API float * mtmd_get_output_embd(mtmd_context * ctx);
172181
/////////////////////////////////////////
173182

174183
//
175-
// helper functions (can be implemented based on other functions)
184+
// Helper functions (can be implemented based on other functions)
176185
//
177-
// please note that these helpers are not guaranteed to be stable, there can be breaking changes in the future
186+
// Please note that these helpers are not guaranteed to be stable.
187+
// BREAKING CHANGES are expected.
178188
//
179189

180190
// helper function to construct a mtmd_bitmap from a file
@@ -192,6 +202,7 @@ MTMD_API mtmd_bitmap * mtmd_helper_bitmap_init_from_buf(const unsigned char * bu
192202
MTMD_API size_t mtmd_helper_get_n_tokens(const mtmd_input_chunks * chunks);
193203

194204
// helper to count the total position of tokens from a list of chunks, useful to keep track of n_past
205+
// normally, n_pos is equal to n_tokens, but for M-RoPE it is different
195206
MTMD_API llama_pos mtmd_helper_get_n_pos(const mtmd_input_chunks * chunks);
196207

197208
// helper function that automatically:
@@ -230,7 +241,7 @@ MTMD_API mtmd_input_chunks * mtmd_test_create_input_chunks(void);
230241
#endif
231242

232243
//
233-
// C++ wrapper
244+
// C++ wrappers
234245
//
235246

236247
#ifdef __cplusplus
@@ -252,6 +263,11 @@ struct mtmd_input_chunks_deleter {
252263
};
253264
using input_chunks_ptr = std::unique_ptr<mtmd_input_chunks, mtmd_input_chunks_deleter>;
254265

266+
struct mtmd_input_chunk_deleter {
267+
void operator()(mtmd_input_chunk * val) { mtmd_input_chunk_free(val); }
268+
};
269+
using input_chunk_ptr = std::unique_ptr<mtmd_input_chunk, mtmd_input_chunk_deleter>;
270+
255271
struct bitmap {
256272
bitmap_ptr ptr;
257273
bitmap() : ptr(nullptr) {}

0 commit comments

Comments
 (0)