mirror of
https://github.com/ml-explore/mlx-examples.git
synced 2025-08-09 02:16:37 +08:00
Handle receiving 0 tokens gracefully (#231)
* handle 0 tokens gracefully * Formatting * Move no token check to statistics section
This commit is contained in:
parent
12c9bafbf5
commit
4fa659acbd
@ -46,6 +46,9 @@ def generate(
|
||||
print(tokenizer.decode(tokens)[skip:], flush=True)
|
||||
gen_time = time.time() - tic
|
||||
print("=" * 10)
|
||||
if len(tokens) == 0:
|
||||
print("No tokens generated for this prompt")
|
||||
return
|
||||
prompt_tps = prompt.size / prompt_time
|
||||
gen_tps = (len(tokens) - 1) / gen_time
|
||||
print(f"Prompt: {prompt_tps:.3f} tokens-per-sec")
|
||||
|
Loading…
Reference in New Issue
Block a user