Skip to content

Commit

Permalink
fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyu-work committed May 14, 2024
1 parent 029fbb9 commit 1584693
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions examples/phi3/phi3.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def genai_run(prompt, model_path, max_length):
print("Generator created")

first = True
first_token_timestamp = None
new_tokens = []

print("\n", prompt)
Expand All @@ -200,12 +201,15 @@ def genai_run(prompt, model_path, max_length):
del generator

run_time = time.time() - started_timestamp
print(
"\n\n"
f"Prompt tokens: {len(input_tokens)}, New tokens: {len(new_tokens)},"
f" Time to first: {(first_token_timestamp - started_timestamp):.2f}s,"
f" New tokens per second: {len(new_tokens)/run_time:.2f} tps"
)
if first_token_timestamp is None:
print("\n\nNo tokens generated")
else:
print(
"\n\n"
f"Prompt tokens: {len(input_tokens)}, New tokens: {len(new_tokens)},"
f" Time to first: {(first_token_timestamp - started_timestamp):.2f}s,"
f" New tokens per second: {len(new_tokens)/run_time:.2f} tps"
)


if __name__ == "__main__":
Expand Down

0 comments on commit 1584693

Please sign in to comment.