File tree Expand file tree Collapse file tree 3 files changed +18
-8
lines changed Expand file tree Collapse file tree 3 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ fn main() -> Result<()> {
62
62
..LlamaContextParams :: default ( )
63
63
} ;
64
64
65
- let mut ctx = model. new_context ( & backend, & ctx_params)
65
+ let mut ctx = model. new_context ( & backend, ctx_params)
66
66
. with_context ( || "unable to create the llama_context" ) ?;
67
67
68
68
// tokenize the prompt
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ impl From<RopeScalingType> for i8 {
43
43
}
44
44
45
45
/// A safe wrapper around `llama_context_params`.
46
- #[ derive( Debug , Clone , Copy , PartialEq ) ]
46
+ #[ derive( Debug , PartialEq ) ]
47
47
#[ allow(
48
48
missing_docs,
49
49
clippy:: struct_excessive_bools,
@@ -71,6 +71,8 @@ pub struct LlamaContextParams {
71
71
pub logits_all : bool ,
72
72
pub embedding : bool ,
73
73
pub offload_kqv : bool ,
74
+ pub cb_eval : llama_cpp_sys_2:: ggml_backend_sched_eval_callback ,
75
+ pub cb_eval_user_data : * mut std:: ffi:: c_void ,
74
76
}
75
77
76
78
/// Default parameters for `LlamaContext`. (as defined in llama.cpp by `llama_context_default_params`)
@@ -97,6 +99,8 @@ impl From<llama_context_params> for LlamaContextParams {
97
99
n_threads_batch,
98
100
rope_freq_base,
99
101
rope_freq_scale,
102
+ cb_eval,
103
+ cb_eval_user_data,
100
104
type_k,
101
105
type_v,
102
106
mul_mat_q,
@@ -131,6 +135,8 @@ impl From<llama_context_params> for LlamaContextParams {
131
135
yarn_beta_slow,
132
136
yarn_orig_ctx,
133
137
offload_kqv,
138
+ cb_eval,
139
+ cb_eval_user_data,
134
140
}
135
141
}
136
142
}
@@ -157,6 +163,8 @@ impl From<LlamaContextParams> for llama_context_params {
157
163
yarn_beta_slow,
158
164
yarn_orig_ctx,
159
165
offload_kqv,
166
+ cb_eval,
167
+ cb_eval_user_data,
160
168
} : LlamaContextParams ,
161
169
) -> Self {
162
170
llama_context_params {
@@ -179,6 +187,8 @@ impl From<LlamaContextParams> for llama_context_params {
179
187
yarn_beta_slow,
180
188
yarn_orig_ctx,
181
189
offload_kqv,
190
+ cb_eval,
191
+ cb_eval_user_data,
182
192
}
183
193
}
184
- }
194
+ }
Original file line number Diff line number Diff line change @@ -309,12 +309,12 @@ impl LlamaModel {
309
309
/// # Errors
310
310
///
311
311
/// There is many ways this can fail. See [`LlamaContextLoadError`] for more information.
312
- pub fn new_context < ' a > (
313
- & ' a self ,
312
+ pub fn new_context (
313
+ & self ,
314
314
_: & LlamaBackend ,
315
- params : & LlamaContextParams ,
316
- ) -> Result < LlamaContext < ' a > , LlamaContextLoadError > {
317
- let context_params = llama_context_params:: from ( * params) ;
315
+ params : LlamaContextParams ,
316
+ ) -> Result < LlamaContext , LlamaContextLoadError > {
317
+ let context_params = llama_context_params:: from ( params) ;
318
318
let context = unsafe {
319
319
llama_cpp_sys_2:: llama_new_context_with_model ( self . model . as_ptr ( ) , context_params)
320
320
} ;
You can’t perform that action at this time.
0 commit comments