Skip to content

Commit b78576e

Browse files
jerryzh168facebook-github-bot
authored andcommitted
Enable quantization for deeplabv3 (#398)
Summary: Pull Request resolved: #398 att, it's still slow in my devvm, but might be fine in CI Reviewed By: kimishpatel Differential Revision: D49379414 fbshipit-source-id: 78a18822ab1c36f743337df26f4883c3edcf6018
1 parent ebb752f commit b78576e

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

examples/quantization/example.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,21 @@ def verify_xnnpack_quantizer_matching_fx_quant_model(model_name, model, example_
7070
after_quant_result_fx = m_fx(*example_inputs)
7171

7272
# 3. compare results
73-
# NB: this check is more useful for QAT since for PTQ we are only inserting observers that does not change the
74-
# output of a model, so it's just testing the numerical difference for different captures in PTQ
75-
# for QAT it is also testing whether the fake quant placement match or not
76-
# not exactly the same due to capture changing numerics, but still really close
73+
if model_name == "dl3":
74+
after_prepare_result = after_prepare_result["out"]
75+
after_prepare_result_fx = after_prepare_result_fx["out"]
76+
after_quant_result = after_quant_result["out"]
77+
after_quant_result_fx = after_quant_result_fx["out"]
7778
logging.info(f"m: {m}")
7879
logging.info(f"m_fx: {m_fx}")
7980
logging.info(
8081
f"prepare sqnr: {compute_sqnr(after_prepare_result, after_prepare_result_fx)}"
8182
)
83+
84+
# NB: this check is more useful for QAT since for PTQ we are only inserting observers that does not change the
85+
# output of a model, so it's just testing the numerical difference for different captures in PTQ
86+
# for QAT it is also testing whether the fake quant placement match or not
87+
# not exactly the same due to capture changing numerics, but still really close
8288
assert compute_sqnr(after_prepare_result, after_prepare_result_fx) > 100
8389
logging.info(
8490
f"quant diff max: {torch.max(after_quant_result - after_quant_result_fx)}"

examples/recipes/xnnpack_optimization/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ class OptimizationOptions(object):
2323
True, False
2424
), # TODO[T163161310]: takes a long time to export to exec prog and save inception_v4 quantized model
2525
"w2l": OptimizationOptions(False, True),
26+
"dl3": OptimizationOptions(True, False),
2627
}

0 commit comments

Comments
 (0)