Skip to content

Commit 06da346

Browse files
jerryzh168facebook-github-bot
authored andcommitted
Add support for mul and mul_relu
Summary: X-link: pytorch/pytorch#107930 att Reviewed By: kimishpatel Differential Revision: D48588121 fbshipit-source-id: 04f9930effa14dcb111eb42ba5bb219e656cad12
1 parent 17fa8f8 commit 06da346

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

examples/models/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,5 @@ class OptimizationOptions(object):
155155
"add": OptimizationOptions(True, True),
156156
"add_mul": OptimizationOptions(True, True),
157157
"mv2": OptimizationOptions(True, True),
158+
"mv3": OptimizationOptions(True, False),
158159
}

examples/quantization/example.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def verify_xnnpack_quantizer_matching_fx_quant_model(model_name, model, example_
4646
m = prepare_pt2e(m, quantizer)
4747
# calibration
4848
after_prepare_result = m(*example_inputs)
49+
print("pt2e prepare:", m)
4950
m = convert_pt2e(m)
5051
after_quant_result = m(*example_inputs)
5152

@@ -57,6 +58,7 @@ def verify_xnnpack_quantizer_matching_fx_quant_model(model_name, model, example_
5758
m_copy, qconfig_mapping, example_inputs, backend_config=backend_config
5859
)
5960
after_prepare_result_fx = m_fx(*example_inputs)
61+
print("fx prepare:", m_fx)
6062
m_fx = _convert_to_reference_decomposed_fx(m_fx, backend_config=backend_config)
6163
after_quant_result_fx = m_fx(*example_inputs)
6264

@@ -69,10 +71,10 @@ def verify_xnnpack_quantizer_matching_fx_quant_model(model_name, model, example_
6971
print("m_fx:", m_fx)
7072
print("prepare sqnr:", compute_sqnr(after_prepare_result, after_prepare_result_fx))
7173
assert compute_sqnr(after_prepare_result, after_prepare_result_fx) > 100
72-
print("quant diff max:", torch.max(after_quant_result - after_quant_result_fx))
74+
print("diff max:", torch.max(after_quant_result - after_quant_result_fx))
75+
print("sqnr:", compute_sqnr(after_quant_result, after_quant_result_fx))
7376
assert torch.max(after_quant_result - after_quant_result_fx) < 1e-1
74-
print("quant sqnr:", compute_sqnr(after_quant_result, after_quant_result_fx))
75-
assert compute_sqnr(after_quant_result, after_quant_result_fx) > 30
77+
assert compute_sqnr(after_quant_result, after_quant_result_fx) > 35
7678

7779

7880
if __name__ == "__main__":
@@ -121,7 +123,7 @@ def verify_xnnpack_quantizer_matching_fx_quant_model(model_name, model, example_
121123
raise RuntimeError(
122124
f"Model {args.model_name} is not a valid name. or not quantizable right now, "
123125
"please contact executorch team if you want to learn why or how to support "
124-
"quantization for the requested model"
126+
"quantization for the requested model "
125127
f"Available models are {list(MODEL_NAME_TO_OPTIONS.keys())}."
126128
)
127129

0 commit comments

Comments
 (0)