Skip to content

Commit

Permalink
initial copy (#1414)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbogunowicz committed Nov 20, 2023
1 parent d6d1d6b commit 9383653
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/deepsparse/transformers/utils/token_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9383653

Please sign in to comment.