• 文档 >
  • 量化 >
  • 量化 API 参考 >
  • 转换
快捷键

转换 ¶

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)[source][source]

将输入模块中的子模块转换为不同的模块,根据映射调用目标模块类的 from_float 方法。如果 remove_qconfig 设置为 True,则在最后删除 qconfig。

参数:
  • module – 准备和校准的模块

  • 映射 – 从源模块类型到目标模块类型的映射字典,可以重写以允许交换用户定义的模块

  • 原地执行 – 在原地执行模型转换,原始模块被修改

  • 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
    }
}

© 版权所有 PyTorch 贡献者。

使用 Sphinx 构建,主题由 Read the Docs 提供。

文档

查看 PyTorch 的全面开发者文档

查看文档

教程

深入了解初学者和高级开发者的教程

查看教程

资源

查找开发资源并获得您的疑问解答

查看资源