Skip to content

Enable quantization for inception_v3 #426

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
8 changes: 8 additions & 0 deletions examples/quantization/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def verify_xnnpack_quantizer_matching_fx_quant_model(model_name, model, example_
m = prepare_pt2e(m, quantizer)
# calibration
after_prepare_result = m(*example_inputs)
logging.info(f"prepare_pt2e: {m}")
m = convert_pt2e(m)
after_quant_result = m(*example_inputs)

Expand All @@ -66,11 +67,18 @@ def verify_xnnpack_quantizer_matching_fx_quant_model(model_name, model, example_
m_copy, qconfig_mapping, example_inputs, backend_config=backend_config
)
after_prepare_result_fx = m_fx(*example_inputs)
logging.info(f"prepare_fx: {m_fx}")
m_fx = _convert_to_reference_decomposed_fx(m_fx, backend_config=backend_config)
after_quant_result_fx = m_fx(*example_inputs)

# 3. compare results
if model_name == "ic3":
# we don't want to compare results of inception_v3 with fx, since mul op with Scalar
# input is quantized differently in fx, and we don't want to replicate the behavior
# in XNNPACKQuantizer
return
if model_name == "dl3":
# dl3 output format: {"out": a, "aux": b}
after_prepare_result = after_prepare_result["out"]
after_prepare_result_fx = after_prepare_result_fx["out"]
after_quant_result = after_quant_result["out"]
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 @@ -19,6 +19,7 @@ class OptimizationOptions(object):
"add_mul": OptimizationOptions(True, True),
"mv2": OptimizationOptions(True, True),
"mv3": OptimizationOptions(False, True),
"ic3": OptimizationOptions(True, False),
"ic4": OptimizationOptions(
True, False
), # TODO[T163161310]: takes a long time to export to exec prog and save inception_v4 quantized model
Expand Down