[quant][graphmode][fx] Add reference quantized linear module (#63627)
authorJerry Zhang <jerryzh@fb.com>
Sat, 28 Aug 2021 03:58:20 +0000 (20:58 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Sat, 28 Aug 2021 05:53:24 +0000 (22:53 -0700)
commit0d0605eaa9243c938faddd3fb60f922c4a48c953
treebc040192b74cefd7063cd5070f4be7ef073c5cf1
parenta3a7a67048c11ee74fbdd54037a6dbaf90367964
[quant][graphmode][fx] Add reference quantized linear module (#63627)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/63627

Added reference quantized linear module for the custom backend flow, the reference quantized module will
have the following code:
```
        w(float) -- quant - dequant \
        x(float) ------------- F.linear ---
```
In the full model, we will see
```
        w(float) -- quant - *dequant \
        x -- quant --- *dequant --  *F.linear --- *quant - dequant
```
and the backend should be able to fuse the ops with `*` into a quantized linear

Test Plan:
python test/test_quantization.py TestQuantizeFx.test_conv_linear_reference

Imported from OSS

Reviewed By: vkuzo

Differential Revision: D30504750

fbshipit-source-id: 5729921745c2b6a0fb344efc3689f3b170e89500
test/quantization/core/test_quantized_module.py
test/quantization/fx/test_quantize_fx.py
torch/nn/intrinsic/quantized/_reference/modules/__init__.py
torch/nn/intrinsic/quantized/_reference/modules/linear_relu.py [deleted file]
torch/nn/quantized/_reference/modules/linear.py
torch/nn/quantized/_reference/modules/utils.py [new file with mode: 0644]
torch/quantization/fx/quantization_patterns.py
torch/quantization/quantization_mappings.py