mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/64916 AO Team is migrating the existing torch.quantization into torch.ao.quantization. We are doing it one file at a time to make sure that the internal callsites are updated properly. This migrates the quant_type.py from torch.quantization to torch.ao.quantization. At this point both locations will be supported. Eventually the torch.quantization will be deprecated. Test Plan: `buck test mode/dev //caffe2/test:quantization -- TestAOMigrationQuantization` Reviewed By: vkuzo Differential Revision: D30898422 fbshipit-source-id: 3e6126b49f0565a4136d6928cea9eb25368927ff
122 lines
3.9 KiB
Python
122 lines
3.9 KiB
Python
from .common import AOMigrationTestCase
|
|
|
|
|
|
class TestAOMigrationQuantization(AOMigrationTestCase):
|
|
r"""Modules and functions related to the
|
|
`torch/quantization` migration to `torch/ao/quantization`.
|
|
"""
|
|
def test_package_import_quantize(self):
|
|
self._test_package_import('quantize')
|
|
|
|
def test_function_import_quantize(self):
|
|
function_list = [
|
|
'_convert',
|
|
'_observer_forward_hook',
|
|
'_propagate_qconfig_helper',
|
|
'_remove_activation_post_process',
|
|
'_remove_qconfig',
|
|
'add_observer_',
|
|
'add_quant_dequant',
|
|
'convert',
|
|
'get_observer_dict',
|
|
'get_unique_devices_',
|
|
'is_activation_post_process',
|
|
'prepare',
|
|
'prepare_qat',
|
|
'propagate_qconfig_',
|
|
'quantize',
|
|
'quantize_dynamic',
|
|
'quantize_qat',
|
|
'register_activation_post_process_hook',
|
|
'swap_module',
|
|
]
|
|
self._test_function_import('quantize', function_list)
|
|
|
|
def test_package_import_stubs(self):
|
|
self._test_package_import('stubs')
|
|
|
|
def test_function_import_stubs(self):
|
|
function_list = [
|
|
'QuantStub',
|
|
'DeQuantStub',
|
|
'QuantWrapper',
|
|
]
|
|
self._test_function_import('stubs', function_list)
|
|
|
|
def test_package_import_quantize_jit(self):
|
|
self._test_package_import('quantize_jit')
|
|
|
|
def test_function_import_quantize_jit(self):
|
|
function_list = [
|
|
'_check_is_script_module',
|
|
'_check_forward_method',
|
|
'script_qconfig',
|
|
'script_qconfig_dict',
|
|
'fuse_conv_bn_jit',
|
|
'_prepare_jit',
|
|
'prepare_jit',
|
|
'prepare_dynamic_jit',
|
|
'_convert_jit',
|
|
'convert_jit',
|
|
'convert_dynamic_jit',
|
|
'_quantize_jit',
|
|
'quantize_jit',
|
|
'quantize_dynamic_jit',
|
|
]
|
|
self._test_function_import('quantize_jit', function_list)
|
|
|
|
def test_package_import_fake_quantize(self):
|
|
self._test_package_import('fake_quantize')
|
|
|
|
def test_function_import_fake_quantize(self):
|
|
function_list = [
|
|
'_is_per_channel',
|
|
'_is_per_tensor',
|
|
'_is_symmetric_quant',
|
|
'FakeQuantizeBase',
|
|
'FakeQuantize',
|
|
'FixedQParamsFakeQuantize',
|
|
'FusedMovingAvgObsFakeQuantize',
|
|
'default_fake_quant',
|
|
'default_weight_fake_quant',
|
|
'default_symmetric_fixed_qparams_fake_quant',
|
|
'default_affine_fixed_qparams_fake_quant',
|
|
'default_per_channel_weight_fake_quant',
|
|
'default_histogram_fake_quant',
|
|
'default_fused_act_fake_quant',
|
|
'default_fused_wt_fake_quant',
|
|
'default_fused_per_channel_wt_fake_quant',
|
|
'_is_fake_quant_script_module',
|
|
'disable_fake_quant',
|
|
'enable_fake_quant',
|
|
'disable_observer',
|
|
'enable_observer',
|
|
]
|
|
self._test_function_import('fake_quantize', function_list)
|
|
|
|
def test_package_import_fuse_modules(self):
|
|
self._test_package_import('fuse_modules')
|
|
|
|
def test_function_import_fuse_modules(self):
|
|
function_list = [
|
|
'_fuse_modules',
|
|
'_get_module',
|
|
'_set_module',
|
|
'fuse_conv_bn',
|
|
'fuse_conv_bn_relu',
|
|
'fuse_known_modules',
|
|
'fuse_modules',
|
|
'get_fuser_method',
|
|
]
|
|
self._test_function_import('fuse_modules', function_list)
|
|
|
|
def test_package_import_quant_type(self):
|
|
self._test_package_import('quant_type')
|
|
|
|
def test_function_import_quant_type(self):
|
|
function_list = [
|
|
'QuantType',
|
|
'quant_type_to_str',
|
|
]
|
|
self._test_function_import('quant_type', function_list)
|