快捷方式

convert

class torch.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 – convert 函数的自定义配置字典

  • use_precomputed_fake_quant – 一个标志,用于启用预计算的 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
    }
}

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得问题解答

查看资源