@@ -7894,9 +7894,9 @@ static int llama_decode_internal(
7894
7894
const auto n_batch = cparams.n_batch;
7895
7895
7896
7896
GGML_ASSERT(n_tokens <= n_batch);
7897
+ GGML_ASSERT((!batch.token && batch.embd) || (batch.token && !batch.embd)); // NOLINT
7897
7898
7898
7899
int n_threads = n_tokens == 1 ? cparams.n_threads : cparams.n_threads_batch;
7899
- GGML_ASSERT((!batch.token && batch.embd) || (batch.token && !batch.embd)); // NOLINT
7900
7900
7901
7901
const int64_t t_start_us = ggml_time_us();
7902
7902
@@ -10062,10 +10062,6 @@ void llama_sample_temp(struct llama_context * ctx, llama_token_data_array * cand
10062
10062
}
10063
10063
}
10064
10064
10065
- void llama_sample_temperature(struct llama_context * ctx, llama_token_data_array * candidates_p, float temp) {
10066
- llama_sample_temp(ctx, candidates_p, temp);
10067
- }
10068
-
10069
10065
void llama_sample_repetition_penalties(
10070
10066
struct llama_context * ctx,
10071
10067
llama_token_data_array * candidates,
@@ -10192,38 +10188,6 @@ void llama_sample_apply_guidance(
10192
10188
ctx->t_sample_us += ggml_time_us() - t_start_sample_us;
10193
10189
}
10194
10190
10195
- void llama_sample_classifier_free_guidance(
10196
- struct llama_context * ctx,
10197
- llama_token_data_array * candidates,
10198
- struct llama_context * guidance_ctx,
10199
- float scale) {
10200
- GGML_ASSERT(ctx);
10201
- int64_t t_start_sample_us;
10202
-
10203
- t_start_sample_us = ggml_time_us();
10204
- const size_t n_vocab = llama_n_vocab(llama_get_model(ctx));
10205
-
10206
- GGML_ASSERT(n_vocab == candidates->size);
10207
- GGML_ASSERT(!candidates->sorted);
10208
-
10209
- std::vector<float> logits_base(n_vocab);
10210
- for (size_t i = 0; i < n_vocab; ++i) {
10211
- logits_base[i] = candidates->data[i].logit;
10212
- }
10213
-
10214
- float * logits_guidance = llama_get_logits(guidance_ctx);
10215
-
10216
- ctx->t_sample_us += ggml_time_us() - t_start_sample_us;
10217
- llama_sample_apply_guidance(ctx, logits_base.data(), logits_guidance, scale);
10218
- t_start_sample_us = ggml_time_us();
10219
-
10220
- for (size_t i = 0; i < n_vocab; ++i) {
10221
- candidates->data[i].logit = logits_base[i];
10222
- }
10223
-
10224
- ctx->t_sample_us += ggml_time_us() - t_start_sample_us;
10225
- }
10226
-
10227
10191
llama_token llama_sample_token_mirostat(struct llama_context * ctx, llama_token_data_array * candidates, float tau, float eta, int32_t m, float * mu) {
10228
10192
GGML_ASSERT(ctx);
10229
10193
@@ -11724,15 +11688,6 @@ bool llama_supports_gpu_offload(void) {
11724
11688
#endif
11725
11689
}
11726
11690
11727
- // deprecated:
11728
- bool llama_mmap_supported(void) {
11729
- return llama_supports_mmap();
11730
- }
11731
-
11732
- bool llama_mlock_supported(void) {
11733
- return llama_supports_mlock();
11734
- }
11735
-
11736
11691
void llama_backend_init(void) {
11737
11692
ggml_time_init();
11738
11693
@@ -12244,15 +12199,6 @@ uint32_t llama_model_quantize(
12244
12199
}
12245
12200
}
12246
12201
12247
- int32_t llama_apply_lora_from_file(struct llama_context * ctx, const char * path_lora, float scale, const char * path_base_model, int32_t n_threads) {
12248
- try {
12249
- return llama_apply_lora_from_file_internal(ctx->model, path_lora, scale, path_base_model, n_threads);
12250
- } catch (const std::exception & err) {
12251
- LLAMA_LOG_ERROR("%s: failed to apply lora adapter: %s\n", __func__, err.what());
12252
- return 1;
12253
- }
12254
- }
12255
-
12256
12202
int32_t llama_model_apply_lora_from_file(const struct llama_model * model, const char * path_lora, float scale, const char * path_base_model, int32_t n_threads) {
12257
12203
try {
12258
12204
return llama_apply_lora_from_file_internal(*model, path_lora, scale, path_base_model, n_threads);
@@ -12802,38 +12748,6 @@ bool llama_save_session_file(struct llama_context * ctx, const char * path_sessi
12802
12748
return true;
12803
12749
}
12804
12750
12805
- int llama_eval(
12806
- struct llama_context * ctx,
12807
- llama_token * tokens,
12808
- int32_t n_tokens,
12809
- int32_t n_past) {
12810
- llama_kv_cache_seq_rm(ctx->kv_self, -1, n_past, -1);
12811
-
12812
- const int ret = llama_decode_internal(*ctx, llama_batch_get_one(tokens, n_tokens, n_past, 0));
12813
- if (ret < 0) {
12814
- LLAMA_LOG_ERROR("%s: failed to decode, ret = %d\n", __func__, ret);
12815
- }
12816
-
12817
- return ret;
12818
- }
12819
-
12820
- int llama_eval_embd(
12821
- struct llama_context * ctx,
12822
- float * embd,
12823
- int32_t n_tokens,
12824
- int32_t n_past) {
12825
- llama_kv_cache_seq_rm(ctx->kv_self, -1, n_past, -1);
12826
-
12827
- llama_batch batch = { n_tokens, nullptr, embd, nullptr, nullptr, nullptr, nullptr, n_past, 1, 0, };
12828
-
12829
- const int ret = llama_decode_internal(*ctx, batch);
12830
- if (ret < 0) {
12831
- LLAMA_LOG_ERROR("%s: failed to decode, ret = %d\n", __func__, ret);
12832
- }
12833
-
12834
- return ret;
12835
- }
12836
-
12837
12751
void llama_set_n_threads(struct llama_context * ctx, uint32_t n_threads, uint32_t n_threads_batch) {
12838
12752
ctx->cparams.n_threads = n_threads;
12839
12753
ctx->cparams.n_threads_batch = n_threads_batch;
0 commit comments