llama : refactor samplers internal implementation (#9370)

This commit is contained in:
slaren 2024-09-08 15:52:07 +02:00 committed by GitHub
parent 2a358fb0c4
commit 19f4a7b296
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 881 additions and 725 deletions

View file

@ -101,6 +101,10 @@ struct ring_buffer {
}
void push_back(const T & value) {
if (capacity == 0) {
throw std::runtime_error("ring buffer: capacity is zero");
}
if (sz == capacity) {
// advance the start when buffer is full
first = (first + 1) % capacity;