prepare¶
- 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 – 要就地修改的输入模型
inplace – 就地执行模型转换,原始模块将被修改
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 } }