mirror of
https://github.com/ggerganov/llama.cpp
synced 2026-04-27 11:01:47 +02:00
* llama : add fd-based model loading via llama_model_load_from_fd * llama : address review feedback for fd-based model loading * llama : use FILE pointer instead of fd in public API * llama : use FILE pointer consistently, address review feedback * fixup * fix tensor names * fix llama-model-saver * roundtrip tests * fixup * refactor tests * fix prints * fix model saving * fix CI, disable Chameleon * print seed --------- Co-authored-by: Siddhesh2377 <siddheshsonar2377@gmail.com>
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include "gguf.h"
|
|
#include "llama.h"
|
|
#include "llama-arch.h"
|
|
|
|
#include <vector>
|
|
|
|
// FIXME temporary function for better error messages
|
|
bool llama_model_saver_supports_arch(llm_arch arch);
|
|
|
|
struct llama_model_saver {
|
|
struct gguf_context * gguf_ctx = nullptr;
|
|
const bool gguf_ctx_owned;
|
|
const struct llama_model * model;
|
|
const struct LLM_KV llm_kv;
|
|
|
|
llama_model_saver(const struct llama_model * model);
|
|
llama_model_saver(enum llm_arch arch, struct gguf_context * gguf_ctx);
|
|
~llama_model_saver();
|
|
|
|
void add_kv(enum llm_kv key, uint32_t value);
|
|
void add_kv(enum llm_kv key, int32_t value);
|
|
void add_kv(enum llm_kv key, float value);
|
|
void add_kv(enum llm_kv key, bool value);
|
|
void add_kv(enum llm_kv key, const char * value);
|
|
|
|
[[noreturn]]
|
|
void add_kv(enum llm_kv key, char value); // needed to make the template below compile
|
|
|
|
template <typename Container>
|
|
void add_kv(enum llm_kv key, const Container & value, bool per_layer = false);
|
|
|
|
void add_kv(enum llm_kv key, const std::vector<std::string> & value);
|
|
|
|
void add_tensor(const struct ggml_tensor * tensor);
|
|
|
|
void add_kv_from_model();
|
|
|
|
void add_tensors_from_model();
|
|
|
|
void save(const std::string & path_model);
|
|
void save(FILE * file);
|
|
};
|