Skip to content

Commit

Permalink
update NS for FX tutorial for PyTorch v1.13 (#2089)
Browse files Browse the repository at this point in the history
* update NS for FX tutorial for PyTorch v1.13

Summary:

Makes a couple of updates to ensure this tutorial still runs on 1.13:
1. changes the `qconfig_dict` argument of `prepare_fx` to `qconfig_mapping`
2. adds `example_inputs` to `prepare_fx`

Test plan:

Run the tutorial, it runs without errors on master

* Pin importlib_metadata<5.0 for python <= 3.7 in requirements.txt (#2091)

v5.0.0 causes issues with python 3.7: python/importlib_metadata#411

* Enable the FX tutorial

Co-authored-by: Max Balandat <Balandat@users.noreply.github.com>
Co-authored-by: Svetlana Karslioglu <svekars@fb.com>
  • Loading branch information
3 people authored Oct 22, 2022
1 parent 67a4eb7 commit 14028f7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion .jenkins/validate_tutorials_built.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"recipes/Captum_Recipe",
"hyperparameter_tuning_tutorial",
"flask_rest_api_tutorial",
"fx_numeric_suite_tutorial", # remove when https://github.com/pytorch/tutorials/pull/2089 is fixed
"ax_multiobjective_nas_tutorial",
]

Expand Down
4 changes: 2 additions & 2 deletions prototype_source/fx_numeric_suite_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ def plot(xdata, ydata, xlabel, ylabel, title):
# Note: quantization APIs are inplace, so we save a copy of the float model for
# later comparison to the quantized model. This is done throughout the
# tutorial.
mobilenetv2_prepared = quantize_fx.prepare_fx(
copy.deepcopy(mobilenetv2_float), qconfig_dict)
datum = torch.randn(1, 3, 224, 224)
mobilenetv2_prepared = quantize_fx.prepare_fx(
copy.deepcopy(mobilenetv2_float), qconfig_dict, (datum,))
mobilenetv2_prepared(datum)
# Note: there is a long standing issue that we cannot copy.deepcopy a
# quantized model. Since quantization APIs are inplace and we need to use
Expand Down

0 comments on commit 14028f7

Please sign in to comment.