• 文档 >
  • 量化 >
  • 量化 API 参考 >
  • 准备
快捷键

准备 ¶

class torch.ao.quantization.prepare(model, inplace=False, allow_list=None, observer_non_leaf_module_list=None, prepare_custom_config_dict=None)[source][source]

准备模型的副本以进行量化校准或量化感知训练。

应预先将量化配置分配给各个子模块的.qconfig 属性中。

模型将附加观察器或伪量化模块,并将 qconfig 进行传播。

参数:
  • model – 要就地修改的输入模型

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

  • allow_list – 可量化的模块列表

  • observer_non_leaf_module_list – 我们想要添加观察器的非叶模块列表

  • prepare_custom_config_dict – 为 prepare 函数定制的配置字典

# Example of prepare_custom_config_dict:
prepare_custom_config_dict = {
    # user will manually define the corresponding observed
    # module class which has a from_float class method that converts
    # float custom module to observed custom module
    "float_to_observed_custom_module_class": {
        CustomModule: ObservedCustomModule
    }
 }

© 版权所有 PyTorch 贡献者。

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

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

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

查看教程

资源

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

查看资源