Fixed segfault during context swap introduced by commit 3d6ed185

This commit is contained in:
Jan Ploski 2023-06-17 04:00:07 +02:00
parent 5005d07f45
commit 04bd2e408e

View file

@ -359,6 +359,8 @@ int main(int argc, char ** argv) {
if (n_past + (int) embd.size() > n_ctx) {
const int n_left = n_past - params.n_keep;
n_past = params.n_keep;
// insert n_left/2 tokens at the start of embd from last_n_tokens
embd.insert(embd.begin(), last_n_tokens.begin() + n_ctx - n_left/2 - embd.size(), last_n_tokens.end() - embd.size());