@@ -2039,8 +2039,8 @@ std::string fs_get_cache_file(const std::string & filename) {
2039
2039
//
2040
2040
// Model utils
2041
2041
//
2042
-
2043
- std::tuple< struct llama_model *, struct llama_context *> llama_init_from_gpt_params (gpt_params & params) {
2042
+ struct llama_init_result llama_init_from_gpt_params (gpt_params & params) {
2043
+ llama_init_result iparams;
2044
2044
auto mparams = llama_model_params_from_gpt_params (params);
2045
2045
2046
2046
llama_model * model = nullptr ;
@@ -2055,7 +2055,7 @@ std::tuple<struct llama_model *, struct llama_context *> llama_init_from_gpt_par
2055
2055
2056
2056
if (model == NULL ) {
2057
2057
fprintf (stderr, " %s: error: failed to load model '%s'\n " , __func__, params.model .c_str ());
2058
- return std::make_tuple ( nullptr , nullptr ) ;
2058
+ return iparams ;
2059
2059
}
2060
2060
2061
2061
auto cparams = llama_context_params_from_gpt_params (params);
@@ -2064,7 +2064,7 @@ std::tuple<struct llama_model *, struct llama_context *> llama_init_from_gpt_par
2064
2064
if (lctx == NULL ) {
2065
2065
fprintf (stderr, " %s: error: failed to create context with model '%s'\n " , __func__, params.model .c_str ());
2066
2066
llama_free_model (model);
2067
- return std::make_tuple ( nullptr , nullptr ) ;
2067
+ return iparams ;
2068
2068
}
2069
2069
2070
2070
if (!params.control_vectors .empty ()) {
@@ -2075,7 +2075,7 @@ std::tuple<struct llama_model *, struct llama_context *> llama_init_from_gpt_par
2075
2075
if (cvec.n_embd == -1 ) {
2076
2076
llama_free (lctx);
2077
2077
llama_free_model (model);
2078
- return std::make_tuple ( nullptr , nullptr ) ;
2078
+ return iparams ;
2079
2079
}
2080
2080
2081
2081
int err = llama_control_vector_apply (lctx,
@@ -2087,7 +2087,7 @@ std::tuple<struct llama_model *, struct llama_context *> llama_init_from_gpt_par
2087
2087
if (err) {
2088
2088
llama_free (lctx);
2089
2089
llama_free_model (model);
2090
- return std::make_tuple ( nullptr , nullptr ) ;
2090
+ return iparams ;
2091
2091
}
2092
2092
}
2093
2093
@@ -2099,7 +2099,7 @@ std::tuple<struct llama_model *, struct llama_context *> llama_init_from_gpt_par
2099
2099
fprintf (stderr, " %s: error: failed to apply lora adapter\n " , __func__);
2100
2100
llama_free (lctx);
2101
2101
llama_free_model (model);
2102
- return std::make_tuple ( nullptr , nullptr ) ;
2102
+ return iparams ;
2103
2103
}
2104
2104
llama_lora_adapter_set (lctx, adapter, lora_scale);
2105
2105
}
@@ -2135,7 +2135,9 @@ std::tuple<struct llama_model *, struct llama_context *> llama_init_from_gpt_par
2135
2135
llama_reset_timings (lctx);
2136
2136
}
2137
2137
2138
- return std::make_tuple (model, lctx);
2138
+ iparams.model = model;
2139
+ iparams.context = lctx;
2140
+ return iparams;
2139
2141
}
2140
2142
2141
2143
struct llama_model_params llama_model_params_from_gpt_params (const gpt_params & params) {
0 commit comments