From 0f5f23ffb412c9e291ae3a0beeb12418aa62279b Mon Sep 17 00:00:00 2001 From: Damian Date: Fri, 17 Nov 2023 10:06:02 +0000 Subject: [PATCH] initial copy --- src/deepsparse/transformers/utils/token_generator.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/deepsparse/transformers/utils/token_generator.py b/src/deepsparse/transformers/utils/token_generator.py index 0421da06e2..af498a6477 100644 --- a/src/deepsparse/transformers/utils/token_generator.py +++ b/src/deepsparse/transformers/utils/token_generator.py @@ -77,6 +77,10 @@ def generate(self, logits: numpy.ndarray) -> numpy.ndarray: :param logits: the logits from the model with shape (vocab_size,) :return: the sampled token """ + # make a copy of logits to avoid modifying the original + # logits distribution in-place + logits = logits.copy() + if self.deterministic: token = numpy.argmax(logits) self.tokens.append(token)