Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
lixiang007666 committed Aug 9, 2024
1 parent 8d0f589 commit 42c4300
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import torch
import time
from contextlib import contextmanager

import torch


@contextmanager
def track_inference_time(warmup=False, use_cuda=True):
"""
Expand All @@ -16,7 +18,7 @@ def track_inference_time(warmup=False, use_cuda=True):
start.record()
else:
start_time = time.time()

try:
yield
finally:
Expand All @@ -26,9 +28,8 @@ def track_inference_time(warmup=False, use_cuda=True):
elapsed_time = start.elapsed_time(end) / 1000.0
else:
elapsed_time = time.time() - start_time

if warmup:
print(f"Warmup run - Execution time: {elapsed_time:.2f} seconds")
else:
print(f"Normal run - Execution time: {elapsed_time:.2f} seconds")

1 change: 0 additions & 1 deletion src/onediff/infer_compiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,3 @@ python3 ./benchmarks/text_to_image.py \
--compiler-config '{"mode": "max-optimize:max-autotune:low-precision", "memory_format": "channels_last", "dynamic": true}' \
--run_multiple_resolutions 1
```

0 comments on commit 42c4300

Please sign in to comment.