Optimize copy-2d for metal. (#2024)

* Optimize copy-2d for metal.

* Add a hacky stopping rule for moondream.
This commit is contained in:
Laurent Mazare
2024-04-07 12:34:16 +02:00
committed by GitHub
parent 33c9b66554
commit 7f354473cf
3 changed files with 58 additions and 21 deletions

View File

@ -123,7 +123,7 @@ impl TextGeneration {
let next_token = self.logits_processor.sample(&logits)?;
tokens.push(next_token);
generated_tokens += 1;
if next_token == eos_token {
if next_token == eos_token || tokens.ends_with(&[27, 10619, 29] /* <END> */) {
break;
}
let token = self.tokenizer.decode(&[next_token], true).map_err(E::msg)?;