llama-model-saver.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma once
  2. #include "llama.h"
  3. #include "llama-arch.h"
  4. #include <vector>
  5. struct llama_model_saver {
  6. struct gguf_context * gguf_ctx = nullptr;
  7. const struct llama_model & model;
  8. const struct LLM_KV llm_kv;
  9. llama_model_saver(const struct llama_model & model);
  10. ~llama_model_saver();
  11. void add_kv(enum llm_kv key, uint32_t value);
  12. void add_kv(enum llm_kv key, int32_t value);
  13. void add_kv(enum llm_kv key, float value);
  14. void add_kv(enum llm_kv key, bool value);
  15. void add_kv(enum llm_kv key, const char * value);
  16. [[noreturn]]
  17. void add_kv(enum llm_kv key, char value); // needed to make the template below compile
  18. template <typename Container>
  19. void add_kv(enum llm_kv key, const Container & value, bool per_layer = false);
  20. void add_kv(enum llm_kv key, const std::vector<std::string> & value);
  21. void add_tensor(const struct ggml_tensor * tensor);
  22. void add_kv_from_model();
  23. void add_tensors_from_model();
  24. void save(const std::string & path_model);
  25. };