llama : move sampling code into llama-sampling

ggml-ci
This commit is contained in:
Georgi Gerganov
2024-07-19 18:15:36 +03:00
parent 081fe431aa
commit 0ddc8e361c
7 changed files with 758 additions and 699 deletions

21
src/llama-sampling.h Normal file
View File

@@ -0,0 +1,21 @@
#pragma once
#include "llama-impl.h"
struct llama_sampling {
llama_sampling(int32_t n_vocab) : n_vocab(n_vocab) {}
std::mt19937 rng;
int64_t t_sample_us = 0;
int32_t n_sample = 0;
int32_t n_vocab = 0;
void reset_timings() {
t_sample_us = 0;
n_sample = 0;
}
};
struct llama_sampling * llama_get_sampling(struct llama_context * ctx);