From 8ee736370a0bb66601a221ded9c0925c2db234e9 Mon Sep 17 00:00:00 2001 From: goerch Date: Sun, 22 Oct 2023 18:36:35 +0200 Subject: [PATCH] Revert code motion --- llama.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/llama.cpp b/llama.cpp index e42962986..3893bf5e2 100644 --- a/llama.cpp +++ b/llama.cpp @@ -975,6 +975,21 @@ static void llama_nop(struct ggml_tensor * tensor) { // don't offload by default (void) tensor; } +static std::string llama_token_to_piece(const struct llama_context * ctx, llama_token token) { + std::vector result(8, 0); + const int n_tokens = llama_token_to_piece(llama_get_model(ctx), token, result.data(), result.size()); + if (n_tokens < 0) { + result.resize(-n_tokens); + int check = llama_token_to_piece(llama_get_model(ctx), token, result.data(), result.size()); + GGML_ASSERT(check == -n_tokens); + } + else { + result.resize(n_tokens); + } + + return std::string(result.data(), result.size()); +} + // // globals // @@ -7447,21 +7462,6 @@ void llama_sample_repetition_penalties( } } -static std::string llama_token_to_piece(const struct llama_context* ctx, llama_token token) { - std::vector result(8, 0); - const int n_tokens = llama_token_to_piece(llama_get_model(ctx), token, result.data(), result.size()); - if (n_tokens < 0) { - result.resize(-n_tokens); - int check = llama_token_to_piece(llama_get_model(ctx), token, result.data(), result.size()); - GGML_ASSERT(check == -n_tokens); - } - else { - result.resize(n_tokens); - } - - return std::string(result.data(), result.size()); -} - void llama_sample_grammar(struct llama_context * ctx, llama_token_data_array * candidates, const struct llama_grammar * grammar) { GGML_ASSERT(ctx); const int64_t t_start_sample_us = ggml_time_us();