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