mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01:00
Summary: - ~~Add a unit test for the Dynamic Quantized Linear operator (```torch.fbgemm_linear_quantize_weight```, ```torch.fbgemm_pack_quantized_matrix```, and ```torch.fbgemm_linear_int8_weight```) in ```test_quantized.py```.~~ Move this to D16404027 for a separate review. - Add the Dynamic Quantized Linear module in ```torch/nn/quantized/modules/linear.py```. ~~This is in a rudimentary stage. Will add more functions later~~. - Add the torch.quantize logic (prepare, eval, convert) for dynamic quantization. - Add a unit test for the Dynamic Quantized Linear module in ```test_nn_quantized.py```. - Add a unit test for the Model-level Quantization API Pull Request resolved: https://github.com/pytorch/pytorch/pull/23128 ghstack-source-id: 88257232 Differential Revision: D16258664 fbshipit-source-id: 4be3ac39ee27c088b341c741d3f09f51d5a23ef0
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
from .quantize import * # noqa: F401
|
|
from .observer import * # noqa: F401
|
|
from .QConfig import * # noqa: F401
|
|
from .fake_quantize import * # noqa: F401
|
|
from .fuse_modules import fuse_modules # noqa: F401
|
|
|
|
def default_eval_fn(model, calib_data):
|
|
r"""
|
|
Default evaluation function takes a torch.utils.data.Dataset or a list of
|
|
input Tensors and run the model on the dataset
|
|
"""
|
|
for data, target in calib_data:
|
|
model(data)
|
|
|
|
_all__ = [
|
|
'QuantWrapper', 'QuantStub', 'DeQuantStub', 'DEFAULT_MODULE_MAPPING',
|
|
# Top level API for quantizing a float model
|
|
'quantize',
|
|
# Sub functions called by quantize
|
|
'prepare', 'convert',
|
|
# Sub functions for `prepare` and `swap_module`
|
|
'propagate_qconfig', 'add_quant_dequant', 'add_observer', 'swap_module',
|
|
'default_eval_fn',
|
|
# Observers
|
|
'Observer', 'WeightObserver', 'observer', 'default_observer',
|
|
'default_weight_observer',
|
|
# QConfig
|
|
'QConfig', 'default_qconfig',
|
|
# QAT utilities
|
|
'default_qat_qconfig', 'prepare_qat', 'quantize_qat',
|
|
# module transformations
|
|
'fuse_modules',
|
|
# Dynamic quantization utilities
|
|
'quantize_dynamic',
|
|
]
|