Skip to content

Commit 7b23e99

Browse files
committed
add comments
1 parent e7f5e7d commit 7b23e99

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

examples/dynamo/engine_caching_example.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ def dynamo_path(iterations=3):
4141
model, args=example_inputs, dynamic_shapes={"x": {0: batch}}
4242
)
4343

44+
# The 1st iteration is to measure the compilation time without engine caching
45+
# The 2nd and 3rd iterations are to measure the compilation time with engine caching.
46+
# Since the 2nd iteration needs to compile and save the engine, it will be slower than the 1st iteration.
47+
# The 3rd iteration should be faster than the 1st iteration because it loads the cached engine.
4448
for i in range(iterations):
4549
inputs = [torch.rand((100 + i, 3, 224, 224)).to("cuda")]
4650
remove_timing_cache() # remove timing cache for engine caching messurement
@@ -133,6 +137,10 @@ def compile_path(iterations=3):
133137
start = torch.cuda.Event(enable_timing=True)
134138
end = torch.cuda.Event(enable_timing=True)
135139

140+
# The 1st iteration is to measure the compilation time without engine caching
141+
# The 2nd and 3rd iterations are to measure the compilation time with engine caching.
142+
# Since the 2nd iteration needs to compile and save the engine, it will be slower than the 1st iteration.
143+
# The 3rd iteration should be faster than the 1st iteration because it loads the cached engine.
136144
for i in range(iterations):
137145
inputs = [torch.rand(size).to("cuda")]
138146
# remove timing cache and reset dynamo for engine caching messurement

0 commit comments

Comments
 (0)