Commit Graph

15 Commits

Author SHA1 Message Date
Zafar
04a8412b86 [quant] Quantizable LSTM (#49671)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/49671

- Introduces the `torch.nn.quantizable` namespace
- Adds the `torch.nn.quantizable.LSTM` module

The point of the `quantizable` namespace is to segregate the purely quantized modules with the modules that could be quantized through a normal quantization flow, but are not using the quantized kernels explicitly.
That means the quantizable modules are functionally and numerically equivalent to the FP ones and can be used instead of the FP ones without any loss.

The main difference between the `torch.nn.LSTM` and the `torch.nn.quantizable.LSTM` is that the former one does not support observation for the linear layers, because all the computation is internal to the `aten` namespace.
The `torch.nn.quantizable.LSTM`, however, uses explicit linear layers that can be observed for further quantization.

Test Plan: Imported from OSS

Differential Revision: D25663870

Reviewed By: vkuzo

Pulled By: z-a-f

fbshipit-source-id: 70ff5463bd759b9a7922571a5712d3409dfdfa06
2020-12-30 15:21:38 -08:00
Jane Xu
4affbbd9f8 minor style edits to torch/testing/_internal/common_quantized.py (#44807)
Summary:
style nits

Pull Request resolved: https://github.com/pytorch/pytorch/pull/44807

Reviewed By: malfet

Differential Revision: D23742537

Pulled By: janeyx99

fbshipit-source-id: 446343822d61f8fd9ef6dfcb8e5da4feff6522b6
2020-09-17 08:02:43 -07:00
Xiang Gao
20ac736200 Remove py2 compatible future imports (#44735)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/44735

Reviewed By: mruberry

Differential Revision: D23731306

Pulled By: ezyang

fbshipit-source-id: 0ba009a99e475ddbe22981be8ac636f8a1c8b02f
2020-09-16 12:55:57 -07:00
Edmund Williams Jr
465138ec39 refactoring TestQuantizeScript (#39677)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/39677

Test Plan:
Moved a test class suite between files, wanted to have same functionality (simple code refactor) so tested to make sure the test output was the same before/after the refactor.
Image below shows the output of TestGraphModePostTrainingStatic before refactor

{F239676498}

This image shows the output of TestQuantizeScript (renamed version that is in test_quantize_script.py instead of test_quantize.py)

{F239676509}

Differential Revision: D21940638

Pulled By: edmundw314

fbshipit-source-id: 54160a5151aadf3a34bdac2bcaeb52904e6653ed
2020-06-19 11:47:00 -07:00
Supriya Rao
9cacbe29e5 [quant] Add reduce_range argument for qlinear_dynamic (#39041)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/39041

reduce_range option restricts the activation tensor to 7 bits instead of 8.
This is necessary to enable per channel quant for RNNs and LSTMs

Test Plan:
python test/test_quantization.py TestDynamicQuantizedLinear

Imported from OSS

Reviewed By: akinh

Differential Revision: D21769691

fbshipit-source-id: ef0e9873367f3c1b34091b0b3af788233ef60c6c
2020-05-29 18:19:36 -07:00
Presley Graham
ff2e29144c Refactor backward compatibility tests to use override_qengines decorator (#38838)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/38838

Test Plan: Imported from OSS

Differential Revision: D21676032

Pulled By: durumu

fbshipit-source-id: 5cbe56e0d72d322f540bccffb60bcdbb15385ee8
2020-05-27 15:37:47 -07:00
Supriya Rao
138476389e [quant] Disable qnnpack test when TSAN is enabled (#38153)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/38153

Test fails when opt-tsan is enabled

Test Plan: buck test mode/opt-tsan //caffe2/test:quantization -- 'test_single_linear_dynamic \(quantization\.test_quantize\.TestGraphModePostTrainingStatic\)' --run-disabled

Reviewed By: vkuzo

Differential Revision: D21482799

fbshipit-source-id: fe6d1d84f525387081fabb90ce876c7c7dafd081
2020-05-08 16:52:36 -07:00
Supriya Rao
76c964dfb0 Reland [quant][tests] Enable tests to run on all qengine backends (#37943)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/37943

Refactor tests to use supported_qengines

Test Plan:
python test/test_quantization.py

Imported from OSS

Differential Revision: D21435514

fbshipit-source-id: 8004ef2535e1cc65036f331c00af27ded1c04a6b
2020-05-06 22:38:50 -07:00
Supriya Rao
b33b46a950 [quant] Enable qnnpack tests for test_quantize and test_numeric_suite (#37351)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/37351

Test Plan:
python test/test_quantization.py PostTrainingStaticQuant

Imported from OSS

Differential Revision: D21293704

fbshipit-source-id: 621f3ac60315b61f99b9b41da691ac3473e974cc
2020-04-29 19:28:22 -07:00
Mike Ruberry
dcd8a1b399 Revert D21286660: [quant] Generalizing _calculate_dynamic_qparams in quantized test
Test Plan: revert-hammer

Differential Revision:
D21286660

Original commit changeset: 98d90cdb34ac

fbshipit-source-id: a4194193c9aa53fb2dc9bbc04fde9c2925aa378f
2020-04-28 18:01:44 -07:00
Zafar Takhirov
239ce75a74 [quant] Generalizing _calculate_dynamic_qparams in quantized test (#37451)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/37451

Test Plan: Imported from OSS

Differential Revision: D21286660

Pulled By: z-a-f

fbshipit-source-id: 98d90cdb34ac3d0ef33f7ebe1c9f32001d4e80b6
2020-04-28 16:55:51 -07:00
Zafar Takhirov
f463586739 Revert D20984966: [quant] Generalizing _calculate_dynamic_qparams in quantized test
Test Plan: revert-hammer

Differential Revision:
D20984966

Original commit changeset: 17437297adae

fbshipit-source-id: 30b9f7a2b2a772b2bf1c4b81cf99bddf37d4b179
2020-04-27 14:36:44 -07:00
Zafar
205c6ffbc5 [quant] Generalizing _calculate_dynamic_qparams in quantized test (#36449)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/36449

Test Plan: Imported from OSS

Differential Revision: D20984966

Pulled By: z-a-f

fbshipit-source-id: 17437297adae813bc5c6fa43c6c7514f72ce2f6c
2020-04-25 17:06:40 -07:00
Supriya Rao
169541871a Add operator support for dynamic quant on mobile (#32479)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32479

Run dynamic quantization on mobile (similar to FBGEMM). Currently only implemented on linear operator

Test Plan:
python test/test_quantized.py TestDynamicQuantizedLinear.test_qlinear

Imported from OSS

Differential Revision: D19542980

fbshipit-source-id: c9f6e5e8ded4d62ae0f2ed99e478c8307dde22ed
2020-01-24 17:51:54 -08:00
Pritam Damania
f050b16dd9 Move pytorch distributed tests to separate folder for contbuild. (#30445)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30445

Create distributed and rpc directories under caffe/test for better management
of unit tests.

Differential Revision: D18702786

fbshipit-source-id: e9daeed0cfb846ef68806f6decfcb57c0e0e3606
2020-01-22 21:16:59 -08:00