mirror of
https://gitlab.com/niansa/libjustlm.git
synced 2025-03-06 20:49:17 +01:00
Check for correct magic value in llama
This commit is contained in:
parent
cb683aa8fc
commit
7cd3899dd0
3 changed files with 3 additions and 8 deletions
|
@ -57,8 +57,7 @@ endif()
|
|||
if (LM_LLAMA)
|
||||
add_library(justlm_llama SHARED llama.cpp justlm_llama.hpp)
|
||||
target_link_libraries(justlm_llama PRIVATE ggml_mainline llama_mainline)
|
||||
target_compile_definitions(justlm_llama PRIVATE
|
||||
LLAMA_VERSIONS=>=3 LLAMA_DATE=999999)
|
||||
target_compile_definitions(justlm_llama PRIVATE LLAMA_DATE=999999)
|
||||
target_justlm_setup(justlm_llama)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class LLaMAInference final : public Inference {
|
|||
|
||||
// Create context
|
||||
state->model = llama_load_model_from_file(weights_path.c_str(), lparams);
|
||||
if (!state->ctx) {
|
||||
if (!state->model) {
|
||||
LM_THROW("Failed to initialize llama model from file", LM_BOOL_ERROR);
|
||||
}
|
||||
state->ctx = llama_new_context_with_model(state->model, lparams);
|
||||
|
|
|
@ -18,11 +18,7 @@ bool magic_match(std::istream& f) {
|
|||
// Check magic
|
||||
uint32_t magic = 0;
|
||||
f.read(reinterpret_cast<char*>(&magic), sizeof(magic));
|
||||
if (magic != 0x67676a74) return false;
|
||||
// Check version
|
||||
uint32_t version = 0;
|
||||
f.read(reinterpret_cast<char*>(&version), sizeof(version));
|
||||
return version LLAMA_VERSIONS;
|
||||
return magic == 0x46554747;
|
||||
}
|
||||
|
||||
LM::Inference *construct(const std::string &weights_path, std::ifstream& f, const LM::Inference::Params &p) {
|
||||
|
|
Loading…
Add table
Reference in a new issue