Skip to content

Update dynamic quantization tutorial #693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions advanced_source/dynamic_quantization_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ def print_size_of_model(model):

######################################################################
# Second, we see faster inference time, with no difference in evaluation loss:
#
# Note: we number of threads to one for single threaded comparison, since quantized
# models run single threaded.

torch.set_num_threads(1)

def time_model_evaluation(model, test_data):
s = time.time()
Expand All @@ -280,6 +285,9 @@ def time_model_evaluation(model, test_data):
time_model_evaluation(quantized_model, test_data)

######################################################################
# Running this locally on a MacBook Pro, without quantization, inference takes about 200 seconds,
# and with quantization it takes just about 100 seconds.
#
# Conclusion
# ----------
#
Expand Down