准备
- 类torch.ao.quantization.prepare(model, inplace=False, allow_list=None, observer_non_leaf_module_list=None, prepare_custom_config_dict=None)[源代码]
-
为量化校准或量化的感知训练准备模型的副本。
量化配置应提前分配给各个子模块的.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 } }