fix copy.deepcopy on LinearPackedParams (#64367)
authorVasiliy Kuznetsov <vasiliy@fb.com>
Thu, 2 Sep 2021 13:12:07 +0000 (06:12 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Thu, 2 Sep 2021 13:30:42 +0000 (06:30 -0700)
commitb2c7c1dfcf9c366ecef5db635b201954981c609f
tree07da2383e191ae506952de1016eab80819bd855e
parent99b064fac4b24a5a76808b52107b88425a402c60
fix copy.deepcopy on LinearPackedParams (#64367)

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

This is the same thing as https://github.com/pytorch/pytorch/pull/56154
but for quantized linear. It fixes the behavior of `copy.deepcopy` on
these modules. Before this PR, copied instances of `LinearPackedParams`
were not properly initialized, and inspecting them raised errors of
missing `_modules`. After this PR, inspecting and using the copies
works.

Test Plan:
```
python test/test_quantization.py TestStaticQuantizedModule.test_linear_api
```

Imported from OSS

Reviewed By: jerryzh168

Differential Revision: D30702667

fbshipit-source-id: 38c26d1e72663416eeb989985b77ffc2052c12b9
test/quantization/core/test_quantized_module.py
torch/nn/quantized/modules/linear.py