转换
- classtorch.ao.quantization.convert(module, mapping=None, inplace=False, remove_qconfig=True, is_reference=False, convert_custom_config_dict=None, use_precomputed_fake_quant=False)[源代码]
-
根据mapping,使用目标模块类的from_float方法将输入模块中的子模块转换为不同的模块。如果
remove_qconfig
设置为True
,则在最后移除qconfig
。- 参数
-
-
module – 已经准备和校准的模块
-
mapping — 一个字典,将源模块类型映射为目标模块类型,并且可以被覆盖以允许交换用户自定义的模块。
-
inplace - 在原地执行模型转换,原始模块将会被修改
-
convert_custom_config_dict - 转换函数的自定义配置字典
-
use_precomputed_fake_quant — 一个标志,用于启用预计算假量化的功能
-
# Example of convert_custom_config_dict: convert_custom_config_dict = { # user will manually define the corresponding quantized # module class which has a from_observed class method that converts # observed custom module to quantized custom module "observed_to_quantized_custom_module_class": { ObservedCustomModule: QuantizedCustomModule } }