pytorch/test/quantization
Andrew Or c7b4eec233 [Quant][fx][bc-breaking] Replace qconfig_dict with a config object (#78452)
**Summary:** Previously, FX graph mode quantization configurations
were specified through a dictionary of qconfigs. However, this
API was not in line with other core APIs in PyTorch. This commit
replaces this dictionary with a config object that users will
create and pass to prepare and convert. This leads to better
type safety and better user experience in notebook settings
due to improved auto completion.

The new API is as follows:

```
from torch.ao.quantization import QConfigMapping
from torch.ao.quantization.quantize_fx import prepare_fx

qconfig_mapping = QConfigMapping()
    .set_global(qconfig)
    .set_object_type(torch.nn.Linear, qconfig)
    .set_module_name_regex("foo.*bar", qconfig)
    .set_module_name("mod", qconfig)

prepare_fx(model, qconfig_mapping)
```

For backwards compatibility, `prepare_fx`, `prepare_qat_fx`,
and `convert_fx` will continue to accept qconfig_dicts, which
will be converted to QuantizationConfigs internally.

Note that this commit does not modify existing tests to use the
new API; they will continue to pass in qconfig_dict as before,
which still works but triggers a deprecation warning. This will
be handled in a future commit.

**Test Plan:**
python test/test_quantization.py TestQuantizeFx
python test/test_quantization.py TestQuantizeFxOps

**Reviewers:** jerryzh168, vkuzo

**Subscribers:** jerryzh168, vkuzo

Differential Revision: D36747998

Pull Request resolved: https://github.com/pytorch/pytorch/pull/78452
Approved by: https://github.com/jerryzh168
2022-05-30 18:30:07 +00:00
..
ao_migration [quant][ao_migration] Base package in tests 2022-05-20 18:43:37 +00:00
bc [quant][fx][bc-breaking] Add required example_args argument to prepare_fx and prepare_qat_fx (#249) (#77608) 2022-05-21 21:03:48 +00:00
core [reland][quant] Add utility function get_fqn_to_example_inputs 2022-05-25 23:31:51 +00:00
dbr [quant][fx][bc-breaking] Add required example_args argument to prepare_fx and prepare_qat_fx (#249) (#77608) 2022-05-21 21:03:48 +00:00
eager Fix ONNX ATen fallback for non-caffe2 engines 2022-04-14 23:18:45 +00:00
fx [Quant][fx][bc-breaking] Replace qconfig_dict with a config object (#78452) 2022-05-30 18:30:07 +00:00
jit extend replaceConvolutionWithAtenConv to handle conv_transpose3d (#76888) 2022-05-13 16:40:12 +00:00
serialized [Quant][fx] Reenable serialization test after convert refactor (#74204) 2022-03-15 03:51:14 +00:00
__init__.py remediation of S205607 2020-07-17 17:19:47 -07:00