Skip to content

Enable quantization for deeplabv3 #398

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
14 changes: 10 additions & 4 deletions examples/quantization/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,21 @@ def verify_xnnpack_quantizer_matching_fx_quant_model(model_name, model, example_
after_quant_result_fx = m_fx(*example_inputs)

# 3. compare results
# NB: this check is more useful for QAT since for PTQ we are only inserting observers that does not change the
# output of a model, so it's just testing the numerical difference for different captures in PTQ
# for QAT it is also testing whether the fake quant placement match or not
# not exactly the same due to capture changing numerics, but still really close
if model_name == "dl3":
after_prepare_result = after_prepare_result["out"]
after_prepare_result_fx = after_prepare_result_fx["out"]
after_quant_result = after_quant_result["out"]
after_quant_result_fx = after_quant_result_fx["out"]
logging.info(f"m: {m}")
logging.info(f"m_fx: {m_fx}")
logging.info(
f"prepare sqnr: {compute_sqnr(after_prepare_result, after_prepare_result_fx)}"
)

# NB: this check is more useful for QAT since for PTQ we are only inserting observers that does not change the
# output of a model, so it's just testing the numerical difference for different captures in PTQ
# for QAT it is also testing whether the fake quant placement match or not
# not exactly the same due to capture changing numerics, but still really close
assert compute_sqnr(after_prepare_result, after_prepare_result_fx) > 100
logging.info(
f"quant diff max: {torch.max(after_quant_result - after_quant_result_fx)}"
Expand Down
1 change: 1 addition & 0 deletions examples/recipes/xnnpack_optimization/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ class OptimizationOptions(object):
True, False
), # TODO[T163161310]: takes a long time to export to exec prog and save inception_v4 quantized model
"w2l": OptimizationOptions(False, True),
"dl3": OptimizationOptions(True, False),
}