mllama.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef MLLAMA_H
  2. #define MLLAMA_H
  3. #include <stddef.h>
  4. #include <stdint.h>
  5. #ifdef LLAMA_SHARED
  6. #if defined(_WIN32) && !defined(__MINGW32__)
  7. #ifdef LLAMA_BUILD
  8. #define MLLAMA_API __declspec(dllexport)
  9. #else
  10. #define MLLAMA_API __declspec(dllimport)
  11. #endif
  12. #else
  13. #define MLLAMA_API __attribute__((visibility("default")))
  14. #endif
  15. #else
  16. #define MLLAMA_API
  17. #endif
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. struct mllama_ctx;
  22. struct mllama_image_batch {
  23. struct mllama_image *data;
  24. size_t size;
  25. };
  26. MLLAMA_API struct mllama_ctx *mllama_model_load(const char *fname, int verbosity);
  27. MLLAMA_API struct mllama_ctx *mllama_model_load_cpu(const char *fname, int verbosity);
  28. MLLAMA_API void mllama_free(struct mllama_ctx *ctx);
  29. MLLAMA_API int32_t mllama_image_size(const struct mllama_ctx *ctx);
  30. MLLAMA_API int32_t mllama_patch_size(const struct mllama_ctx *ctx);
  31. MLLAMA_API int32_t mllama_hidden_size(const struct mllama_ctx *ctx);
  32. MLLAMA_API int mllama_n_patches(const struct mllama_ctx *ctx);
  33. MLLAMA_API int mllama_n_positions(const struct mllama_ctx *ctx);
  34. MLLAMA_API int mllama_n_tiles(const struct mllama_ctx *ctx);
  35. MLLAMA_API int mllama_n_embd(const struct mllama_ctx *ctx);
  36. MLLAMA_API size_t mllama_n_embd_bytes(const struct mllama_ctx *ctx);
  37. MLLAMA_API struct mllama_image *mllama_image_init();
  38. MLLAMA_API void mllama_image_free(struct mllama_image *img);
  39. MLLAMA_API void mllama_image_batch_free(struct mllama_image_batch *batch);
  40. MLLAMA_API bool mllama_image_load_from_data(const void *data, const int n, const int nx, const int ny, const int nc, const int nt, const int aspect_ratio_id, struct mllama_image *img);
  41. MLLAMA_API bool mllama_image_encode(struct mllama_ctx *ctx, int n_threads, struct mllama_image *img, float *vec);
  42. MLLAMA_API bool mllama_image_batch_encode(struct mllama_ctx *ctx, int n_threads, const struct mllama_image_batch *imgs, float *vec);
  43. #ifdef __cplusplus
  44. }
  45. #endif
  46. #endif // MLLAMA_H