評價此頁

prepare#

class torch.ao.quantization.prepare(model, inplace=False, allow_list=None, observer_non_leaf_module_list=None, prepare_custom_config_dict=None)[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}
}