zamroni111 commited on
Commit
964202b
·
verified ·
1 Parent(s): eb77e74

Update onnxgenairun.py

Browse files
Files changed (1) hide show
  1. onnxgenairun.py +7 -7
onnxgenairun.py CHANGED
@@ -55,8 +55,8 @@ def main(args):
55
  print("Output:\n", end='', flush=True)
56
 
57
  try:
58
- lastdecoded = ""
59
- currentdecoded = ""
60
  while not generator.is_done():
61
  generator.compute_logits()
62
  generator.generate_next_token()
@@ -70,13 +70,13 @@ def main(args):
70
  ###print(tokenizer_stream.decode(new_token), end='', flush=True)
71
 
72
 
73
- currentdecoded = tokenizer_stream.decode(new_token)
74
  ###if lastdecoded == "." and currentdecoded.startswith(" ") and (not currentdecoded.startswith(" *")):
75
- if re.findall("^[\x2E\x3A\x3B]$", lastdecoded) and currentdecoded.startswith(" ") and (not currentdecoded.startswith(" *")) :
76
- currentdecoded = "\n" + currentdecoded.replace(" ", "", 1)
77
 
78
- print(currentdecoded, end='', flush=True)
79
- lastdecoded = currentdecoded
80
 
81
  if args.timings: new_tokens.append(new_token)
82
  except KeyboardInterrupt:
 
55
  print("Output:\n", end='', flush=True)
56
 
57
  try:
58
+ vPreviousDecoded = ""
59
+ vNewDecoded = ""
60
  while not generator.is_done():
61
  generator.compute_logits()
62
  generator.generate_next_token()
 
70
  ###print(tokenizer_stream.decode(new_token), end='', flush=True)
71
 
72
 
73
+ vNewDecoded = tokenizer_stream.decode(new_token)
74
  ###if lastdecoded == "." and currentdecoded.startswith(" ") and (not currentdecoded.startswith(" *")):
75
+ if re.findall("^[\x2E\x3A\x3B]$", vPreviousDecoded) and vNewDecoded.startswith(" ") and (not vNewDecoded.startswith(" *")) :
76
+ vNewDecoded = "\n" + vNewDecoded.replace(" ", "", 1)
77
 
78
+ print(vNewDecoded, end='', flush=True)
79
+ vPreviousDecoded = vNewDecoded
80
 
81
  if args.timings: new_tokens.append(new_token)
82
  except KeyboardInterrupt: