1
0

llava.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef LLAVA_H
  2. #define LLAVA_H
  3. #include "ggml.h"
  4. #ifdef LLAMA_SHARED
  5. # if defined(_WIN32) && !defined(__MINGW32__)
  6. # ifdef LLAMA_BUILD
  7. # define LLAVA_API __declspec(dllexport)
  8. # else
  9. # define LLAVA_API __declspec(dllimport)
  10. # endif
  11. # else
  12. # define LLAVA_API __attribute__ ((visibility ("default")))
  13. # endif
  14. #else
  15. # define LLAVA_API
  16. #endif
  17. struct clip_ctx;
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. struct llava_image_embed {
  22. float * embed;
  23. int n_image_pos;
  24. };
  25. /** sanity check for clip <-> llava embed size match */
  26. LLAVA_API bool llava_validate_embed_size(const llama_context * ctx_llama, const clip_ctx * ctx_clip);
  27. /** build an image embed from image file bytes */
  28. LLAVA_API struct llava_image_embed * llava_image_embed_make_with_bytes(struct clip_ctx * ctx_clip, int n_threads, const unsigned char * image_bytes, int image_bytes_length);
  29. /** build an image embed from a path to an image filename */
  30. LLAVA_API struct llava_image_embed * llava_image_embed_make_with_filename(struct clip_ctx * ctx_clip, int n_threads, const char * image_path);
  31. LLAVA_API void llava_image_embed_free(struct llava_image_embed * embed);
  32. /** free an embedding made with llava_image_embed_make_* */
  33. /** write the image represented by embed into the llama context with batch size n_batch, starting at context pos n_past. on completion, n_past points to the next position in the context after the image embed. */
  34. LLAVA_API bool llava_eval_image_embed(struct llama_context * ctx_llama, const struct llava_image_embed * embed, int n_batch, int * n_past);
  35. #ifdef __cplusplus
  36. }
  37. #endif
  38. #endif