@@ -7894,9 +7894,9 @@ static int llama_decode_internal(
78947894 const auto n_batch = cparams.n_batch;
78957895
78967896 GGML_ASSERT(n_tokens <= n_batch);
7897+ GGML_ASSERT((!batch.token && batch.embd) || (batch.token && !batch.embd)); // NOLINT
78977898
78987899 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
79007900
79017901 const int64_t t_start_us = ggml_time_us();
79027902
@@ -10062,10 +10062,6 @@ void llama_sample_temp(struct llama_context * ctx, llama_token_data_array * cand
1006210062 }
1006310063}
1006410064
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-
1006910065void llama_sample_repetition_penalties(
1007010066 struct llama_context * ctx,
1007110067 llama_token_data_array * candidates,
@@ -10192,38 +10188,6 @@ void llama_sample_apply_guidance(
1019210188 ctx->t_sample_us += ggml_time_us() - t_start_sample_us;
1019310189}
1019410190
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-
1022710191llama_token llama_sample_token_mirostat(struct llama_context * ctx, llama_token_data_array * candidates, float tau, float eta, int32_t m, float * mu) {
1022810192 GGML_ASSERT(ctx);
1022910193
@@ -11724,15 +11688,6 @@ bool llama_supports_gpu_offload(void) {
1172411688#endif
1172511689}
1172611690
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-
1173611691void llama_backend_init(void) {
1173711692 ggml_time_init();
1173811693
@@ -12244,15 +12199,6 @@ uint32_t llama_model_quantize(
1224412199 }
1224512200}
1224612201
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-
1225612202int32_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) {
1225712203 try {
1225812204 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
1280212748 return true;
1280312749}
1280412750
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-
1283712751void llama_set_n_threads(struct llama_context * ctx, uint32_t n_threads, uint32_t n_threads_batch) {
1283812752 ctx->cparams.n_threads = n_threads;
1283912753 ctx->cparams.n_threads_batch = n_threads_batch;
0 commit comments